-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
feat: add bindings to run microtasks from Isolate #2793
feat: add bindings to run microtasks from Isolate #2793
Conversation
fb57c54
to
838e811
Compare
core/isolate.rs
Outdated
@@ -690,6 +695,7 @@ impl Future for Isolate { | |||
drop(locker); | |||
} | |||
|
|||
self.run_microtasks()?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might need to be inside a locker scope.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It shouldn't. Lock is being acquired already within libdeno::deno_run_microtasks
. We only need it on respond, because we don't create a lock in libdeno::deno_respond
. It might make sense to remove LockerScope, and just add a lock to the async part of libdeno::deno_respond
(We shouldn't need it for sync responses).
Results This PR
Latest release:
I'll profile V8 as well in the evening |
With
|
I'm not sure about this PR anymore... I still can't manage to get tests to pass even though I tried calling |
I managed to figure out the problems 😅feel a bit ashamed that I couldn't figure it out before Here are the benchmarks:
this PR
|
@bartlomieju so given the fix in #2858, is this an improvement? |
@ry I just checked benchmark:
That's significantly slower, I'd assume that now microtasks are run too rarely. |
Latest benchmarks
Side note: benchmarks are fluctuating a lot, maybe we should run each benchmark 3-5 times and average the results to smooth out charts? |
core/isolate.rs
Outdated
} | ||
|
||
// self.run_microtasks(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're not calling run_microtasks... I would think this will cause test failures
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ry I call isolate->RunMicrotasks()
in libdeno
code. Those commented bits need to be removed.
core/libdeno/api.cc
Outdated
@@ -198,6 +200,7 @@ void deno_respond(Deno* d_, void* user_data, deno_op_id op_id, deno_buf buf) { | |||
} | |||
|
|||
auto v = recv_->Call(context, context->Global(), argc, args); | |||
d->isolate_->RunMicrotasks(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is the same as kAuto... I benchmarked it and there's no change
master
~/src/deno> wrk http://127.0.0.1:4500/
Running 10s test @ http://127.0.0.1:4500/
2 threads and 10 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 291.26us 494.34us 11.83ms 96.74%
Req/Sec 20.33k 2.10k 32.32k 82.50%
404493 requests in 10.00s, 19.67MB read
Requests/sec: 40447.21
Transfer/sec: 1.97MB
~/src/deno> wrk http://127.0.0.1:4500/
Running 10s test @ http://127.0.0.1:4500/
2 threads and 10 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 272.21us 386.03us 6.74ms 97.01%
Req/Sec 20.61k 1.59k 24.46k 68.50%
410139 requests in 10.00s, 19.95MB read
Requests/sec: 41001.46
Transfer/sec: 1.99MB
this branch
~/src/deno> wrk http://127.0.0.1:4500/
Running 10s test @ http://127.0.0.1:4500/
2 threads and 10 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 272.63us 402.47us 6.44ms 97.03%
Req/Sec 20.81k 1.43k 28.58k 83.17%
418073 requests in 10.10s, 20.33MB read
Requests/sec: 41393.01
Transfer/sec: 2.01MB
~/src/deno> wrk http://127.0.0.1:4500/
Running 10s test @ http://127.0.0.1:4500/
2 threads and 10 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 271.93us 400.53us 6.75ms 97.05%
Req/Sec 20.84k 1.22k 26.85k 80.69%
418670 requests in 10.10s, 20.36MB read
Requests/sec: 41454.11
Transfer/sec: 2.02MB
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's my experience as well, calling run_microtasks
inside Isolate::poll
gives about 10-15% less req/sec.
Ping @ry @piscisaureus do you have any thoughts about this PR? There's no perf gain from this PR and it introduces additional complexity so IMHO it's not really worth landing |
@bartlomieju I'd like to have the libdeno binding available for future experimentation, but left it in kAuto for now. I'd be happy to land that. |
Sure, I'll update the PR |
ef53cf0
to
2fc6aa5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - thanks - I’m sure this will come in handy soon.
No description provided.