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

Optimize block_on by caching Parker and Waker #149

Merged
merged 4 commits into from
Sep 11, 2023

Conversation

BigWingBeat
Copy link
Contributor

async-io's implementation of block_on currently creates a new parker and waker on every invocation. This PR caches the parker and waker in a thread-local to improve performance. Most of this code is copied from futures-lite's implementation of block_on, as that crate already does exactly this, and the performance difference between these two block_on implementations is why I looked into optimizing async-io in the first place.

futures-lite (Red) vs async-io without this PR (Yellow)

futures-lite vs async-io

futures-lite (Red) vs async-io with this PR (Yellow)

futures-lite vs patched async-io

(Also see bevyengine/bevy#9626 for more context)

Copy link
Member

@notgull notgull left a comment

Choose a reason for hiding this comment

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

Looks good to me!

I'll wait until #142 is merged before I merge this.

src/driver.rs Show resolved Hide resolved
Copy link
Member

@notgull notgull left a comment

Choose a reason for hiding this comment

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

I'll merge this once you rebase on #142

@notgull notgull merged commit 8c3c3bd into smol-rs:master Sep 11, 2023
21 checks passed
@notgull notgull mentioned this pull request Sep 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants