-
Notifications
You must be signed in to change notification settings - Fork 30k
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
benchmark: benchmarking impacts of async hooks on promises #31188
benchmark: benchmarking impacts of async hooks on promises #31188
Conversation
benchmark/async_hooks/promises.js
Outdated
run(n).then(() => { | ||
bench.end(n); | ||
}); | ||
break; |
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 could fall through here after the hook.enable()
call, if you like.
benchmark/async_hooks/promises.js
Outdated
await new Promise((resolve) => resolve()) | ||
.then(() => { throw new Error('foobar'); }) | ||
.catch((e) => e); |
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.
Nit:
await Promise.resolve()
.then(() => { throw new Error('foobar'); })
.catch((e) => e);
benchmark/async_hooks/promises.js
Outdated
|
||
const bench = common.createBenchmark(main, { | ||
n: [1e6], | ||
method: [ |
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.
Nit: These aren't methods. They're descriptive strings, right? I don't have a better idea than method
though, so maybe it's fine and if someone comes up with something better in the future, they can PR that in.
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.
What about:
tracking: [
'enabled',
'disabled'
]
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.
(If we do make this change, which I like, we'll need to add tracking
to test-benchmark-async-hooks.js
.)
Confirmed on the command line that |
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.
Optional nit or something for someone to do in a subsequent PR: It might be a good idea to have a default value for method
(like we do for cipher
in benchmark/crypto/aes-gcm-throughput.js
) and then specify an empty string for method
in test/benchmark/test-benchmark-async-hooks.js
. Then subsequent benchmarks that want to use method
don't have to use trackingDisabled
or whatever if that's not appropriate for that benchmark.
Benchmark tests CI: https://ci.nodejs.org/job/node-test-commit-custom-suites-freestyle/11413/ |
Landed in b3b0ae5 |
PR-URL: #31188 Refs: nodejs/diagnostics#124 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
PR-URL: #31188 Refs: nodejs/diagnostics#124 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
PR-URL: #31188 Refs: nodejs/diagnostics#124 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Is there an issue for continuation of this work (I mean further optimization)? I did a simple experiment recently. I have removed emit resolve call from |
@puzpuzpuz Yeah, your result is quite similar in my local reproduction. I'm trying to find out improvements. But, alas, if you have any idea you can go ahead 😄. |
I was thinking of optimizations for |
Refs: nodejs/diagnostics#124
FWIW, following is the result of the benchmark:
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes