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

Experiment: replace thread locals with custom waker vtable #105

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

HyeonuPark
Copy link

This is a post to share experiment, not actual pull request. But its result is too impressive I couldn't resist sharing them. On my not-so-strict linux env, it shows clear ~40% perf improvement.

pdf

I don't have proper benchmark env setup ATM, but you can test it on your own env too.

But there's few subtle issues to note before shipping this idea:

  1. It uses waker_getter nightly feature. This feature seems pretty trivial and I expect it to be stable soon-ish, but even if it happens it will take a quite while for this feature to follow up the MSRV policy.
  2. It wraps/replaces the waker passed. A different waker is passed to downstack, deactivates Waker::will_wake() based optimizations.
  3. Again this change replaces the waker, other libs that detects its own vtable like embassy would be affected as it's not their own vtable anymore. To workaround this issue the stream! / try_stream! macros can unpack the inner waker before polling its inner async block. But this implementation would not be trivial.

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.

1 participant