Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Peg isolates to a thread, replace all usage of tokio threaded runtime with tokio's basic runtime #3844

Merged
merged 38 commits into from
Feb 3, 2020

Conversation

ry
Copy link
Member

@ry ry commented Jan 31, 2020

No description provided.

@ry ry changed the title Peg isolates to a single thread, replace all usage of tokio threaded runtime with tokio's basic runtime Peg isolates to a thread, replace all usage of tokio threaded runtime with tokio's basic runtime Jan 31, 2020
cli/compilers/ts.rs Outdated Show resolved Hide resolved
cli/ops/process.rs Outdated Show resolved Hide resolved
cli/ops/process.rs Outdated Show resolved Hide resolved
cli/state.rs Outdated Show resolved Hide resolved
Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, this patch is massive and requires a few more follow ups

cli/ops/process.rs Outdated Show resolved Hide resolved
cli/ops/process.rs Outdated Show resolved Hide resolved
cli/lib.rs Show resolved Hide resolved
cli/lib.rs Outdated Show resolved Hide resolved
@piscisaureus
Copy link
Member

So the Isolate is still a future if I'm reading this correctly.
Is there a way to make the V8 thread drive the tokio event loop instead of the other way around? Otherwise I don't see it going to help much with the Locker issue.

@piscisaureus
Copy link
Member

  1. Does this mean that all blocking ops (e.g. DNS resolution) are now actually blocking, or is there still a thread pool for that?

@ry
Copy link
Member Author

ry commented Feb 3, 2020

So the Isolate is still a future if I'm reading this correctly. Is there a way to make the V8 thread drive the tokio event loop instead of the other way around? Otherwise I don't see it going to help much with the Locker issue.

Probably. The event loop is basically defined the same as it was in deno_core::Isolate::poll. Now that they are all on their own threads we can start to dismantle that if we want to. I avoided making more changes than necessary to switch Tokio runtimes.

Does this mean that all blocking ops (e.g. DNS resolution) are now actually blocking, or is there still a thread pool for that?

In this patch all blocking ops are done on their own thread. I leave it to future work to optimize this.
https://github.com/ry/deno/blob/b5ca5e6f0aa2cbb732827f745bb5e7cf15641a17/cli/ops/dispatch_json.rs#L106-L113

@piscisaureus
Copy link
Member

In this patch all blocking ops are done on their own thread. I leave it to future work to optimize this.
https://github.com/ry/deno/blob/b5ca5e6f0aa2cbb732827f745bb5e7cf15641a17/cli/ops/dispatch_json.rs#L106-L113

Although the code looks fine from my perspective, I worry that it's going to hurt some benchmark performance badly. Do you have any numbers for e.g. module fetch / proxy performance?

pub struct Worker {
pub name: String,
pub isolate: Arc<AsyncMutex<Box<deno_core::EsIsolate>>>,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that we've gotten rid of this Arc Mutex

@ry
Copy link
Member Author

ry commented Feb 3, 2020

Although the code looks fine from my perspective, I worry that it's going to hurt some benchmark performance badly. Do you have any numbers for e.g. module fetch / proxy performance?

I don't think we measure any blocking ops in the benchmarks. Regarding compiling - we spawn a new thread for the TS compiler worker - so that's an async op.

@piscisaureus
Copy link
Member

In this patch all blocking ops are done on their own thread. I leave it to future work to optimize this.

I'm a bit afraid this is is never going to happen.

@ry ry merged commit 161cf7c into denoland:master Feb 3, 2020
@hustxiaoc
Copy link

Are we going to use threaded_scheduler runtime someday for handling async ops with multiple threading?

@ry
Copy link
Member Author

ry commented Apr 28, 2020

@hustxiaoc Unlikely - we have in the past and have found the single threaded runtime faster and simpler for our purposes. I'd be happy to describe this in more detail if you're interested...

@hustxiaoc
Copy link

Sure, I'm happy to learn more detail about this :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants