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

refactor(core/shared_queue): overflow_response overwrite bugfix & improved shared queue overflow performance #9433

Merged
merged 5 commits into from
Feb 23, 2021

Conversation

inteon
Copy link
Contributor

@inteon inteon commented Feb 7, 2021

I reviewed the shared queue message passing code (js <-> rs).

  • The have_unpolled_ops variable in runtime.rs was changed to not be encapsulated by a Cell<>, as this is not needed.
  • In runtime.rs the overflow_response logic was changed, now ALL async responces are always polled in poll_pending_ops and returned in an Vec, this also fixes a bug where the value in overflow_response could be overwritten by the second loop. Also both the request to check the shared_queue and the overflow data are send in one v8 function call now.

No performance degradation is observed in the benchmarks. In case the workload overflows the queue a lot, this implementation will probably be more performant as all async responses can be transfered from rs to js in 1 function call (maybe a test-case is needed here if for you this does not make sense).

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.

I reviewed the shared queue message passing code (js <-> rs).

  • The core.js and shared_queue.rs files only include aesthetic changes for better readability and also more similar code between both files.

While I appreciate the work, these changes are highly subjective and are only adding to diff lines; I'd prefer to discuss them after fixing actual bugs.

  • The have_unpolled_ops variable in runtime.rs was changed to not be encapsulated by a Cell<>, as this is not needed.

👍

  • In runtime.rs the overflow_response logic was changed, now ALL async responces are always polled in poll_pending_ops and returned in an Vec, this also fixes a bug where the value in overflow_response could be overwritten by the second loop. Also both the request to check the shared_queue and the overflow data are send in one v8 function call now.

These changes are in the hot code path and I'm a bit worried about creating a lot of vectors, but let's verify on the benchmarks.

Some changes might be a bit opinionated, I'm open for any adaptations that are still needed.
No performance degradation is observed in the benchmarks. In case the workload overflows the queue a lot, this implementation will probably be more performant as all async responses can be transfered from rs to js in 1 function call (maybe a test-case is needed here if for you this does not make sense).

Yes, a bench case would be perfect as there's no benchmark for overflown responses; take a look at cli/bench/main.rs for example benchmarks.

core/runtime.rs Outdated Show resolved Hide resolved
core/runtime.rs Show resolved Hide resolved
@inteon
Copy link
Contributor Author

inteon commented Feb 9, 2021

Ok, I reverted some of the changes and added an extra benchmark. I propose that if the changes can be merged I create a new pull request that includes the changes done to core.js and shared_queue.rs, so these can be further discussed like you mentioned.

@inteon inteon changed the title refactor(core/shared_queue): shared queue code simplification & improved shared queue overflow performance refactor(core/shared_queue): overflow_response overwrite bugfix & improved shared queue overflow performance Feb 9, 2021
…eue overflow performance

have_unpolled_ops: remove unneeded cell + set to false once

structure field reordering (grouped by functional use) & branching readability improvement

allow for multiple messages in overflow, also combining overflow call with shared buffer call

format fix

revert aesthetic changes

add overflow benchmark

format + add lint exception + add copyright

removed unnecessary loop in test

added bug unittest

Merge branch 'master' of https://github.com/denoland/deno into code_review
Base automatically changed from master to main February 19, 2021 14:59
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, thanks @inteon. As stated previously this change is in the hot path, so I'll be watching benchmarks after landing this PR and might have to revert if performance deteriorates.

@bartlomieju bartlomieju merged commit dccf5e0 into denoland:main Feb 23, 2021
@inteon inteon deleted the code_review branch March 4, 2022 10:45
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