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

rt: initial implementation of new threaded runtime #5823

Merged
merged 33 commits into from Jul 21, 2023

Conversation

carllerche
Copy link
Member

This patch includes an initial implementation of a new multi-threaded runtime. The new runtime aims to increase the scheduler throughput by speeding up how it dispatches work to peer worker threads. This implementation improves most benchmarks by about ~10% when the number of threads is below 16. As threads increase, mutex contention deteriorates performance.

Because the new scheduler is not yet ready to replace the old one, the patch introduces it as an unstable runtime flavor, warning it isn't production ready. Work to improve the scalability of the runtime will most likely require more intrusive changes across Tokio, so I am opting to merge with master to avoid more significant conflicts. I don't intend ever to stabilize a new runtime flavor. Instead, once the new scheduler is ready, it will replace the current one.

As an example of benchmarks, here is Hyper hello world: https://gist.github.com/carllerche/7ac6924ad3ab1bb8e1a289fd96043636

I'm not sure if duplicating tests, including loom tests, is the best strategy here.

This patch includes an initial implementation of a new multi-threaded
runtime. The new runtime aims to increase the scheduler throughput by
speeding up how it dispatches work to peer worker threads. This
implementation improves most benchmarks by about ~10% when the number of
threads is below 16. As threads increase, mutex contention deteriorates
performance.

Because the new scheduler is not yet ready to replace the old one, the
patch introduces it as an unstable runtime flavor with a warning that it
isn't production ready. Work to improve the scalability of the runtime
will most likely require more intrusive changes across Tokio, so I am
opting to merge with master to avoid larger conflicts.
@carllerche carllerche added A-tokio Area: The main tokio crate M-runtime Module: tokio/runtime T-performance Topic: performance and benchmarks labels Jun 26, 2023
@github-actions github-actions bot added the R-loom Run loom tests on this PR label Jun 26, 2023
@carllerche carllerche marked this pull request as draft June 26, 2023 22:07
@hawkw hawkw self-requested a review June 26, 2023 22:08
Cargo.toml Outdated Show resolved Hide resolved
@carllerche carllerche marked this pull request as ready for review June 27, 2023 20:56
@inevity
Copy link
Contributor

inevity commented Jun 29, 2023

Can you detail the "speeding up how it dispatches work to peer worker threads. " compared with original impl of threaded runtime?

@carllerche
Copy link
Member Author

@inevity I plan to write about it in detail later. However, I don't expect the implementation currently in the PR to stay as is.

@carllerche carllerche added R-loom-multi-thread Run loom multi-thread tests on this PR R-loom-multi-thread-alt Run loom multi-thread alt tests on this PR labels Jun 29, 2023
tokio/Cargo.toml Outdated Show resolved Hide resolved
@carllerche
Copy link
Member Author

Finally green!

@carllerche carllerche merged commit 4165601 into master Jul 21, 2023
82 checks passed
@carllerche carllerche deleted the rt-multi-thread-alt branch July 21, 2023 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate M-runtime Module: tokio/runtime R-loom Run loom tests on this PR R-loom-multi-thread Run loom multi-thread tests on this PR R-loom-multi-thread-alt Run loom multi-thread alt tests on this PR T-performance Topic: performance and benchmarks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants