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

core: avoid async op future reboxing to bundle PromiseId #10123

Merged
merged 3 commits into from
Apr 11, 2021

Conversation

AaronO
Copy link
Contributor

@AaronO AaronO commented Apr 11, 2021

This is another op-layer optimization, it reduces the baseline overhead of async ops by ~10%.

It removes an extra alloc/free per opcall that happened due to "reboxing" the future to insert the PromiseId. The PromiseId is now passed as a field of OpPayload so the async OpFn wrappers can insert it when mapping the future result.

I have another experiment in progress, but wanted to land this since it's simple and 10% is a respectable gain even if it's not "game changing".

Benches

Before:
test bench_op_async   ... bench:     533,080 ns/iter (+/- 14,308)
test bench_op_nop     ... bench:      71,169 ns/iter (+/- 2,998)
test bench_op_pi_bin  ... bench:      87,043 ns/iter (+/- 3,089)
test bench_op_pi_json ... bench:      85,530 ns/iter (+/- 1,801)

After:
test bench_op_async   ... bench:     474,119 ns/iter (+/- 8,209)
test bench_op_nop     ... bench:      71,417 ns/iter (+/- 3,776)
test bench_op_pi_bin  ... bench:      86,535 ns/iter (+/- 3,084)
test bench_op_pi_json ... bench:      86,308 ns/iter (+/- 1,388)

Copy link
Member

@piscisaureus piscisaureus left a comment

Choose a reason for hiding this comment

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

Awesome!

@piscisaureus piscisaureus merged commit 29eca72 into denoland:main Apr 11, 2021
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

2 participants