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

Replace futures-util with async-task #124

Merged
merged 9 commits into from
Apr 27, 2023
Merged

Conversation

notgull
Copy link
Member

@notgull notgull commented Apr 9, 2023

Right now, calloop uses futures-util's FuturesUnordered type to construct its executor. However, futures-util has quite a few dependencies. This PR migrates to another implementation based on the async-task crate, which is dependency free and builds faster. The implementation also uses fewer synchronization primitives, so it should be faster in theory.

I also add slab as a dependency, but since #123 also adds it we should be alright here.

WIP for now

@codecov
Copy link

codecov bot commented Apr 9, 2023

Codecov Report

Patch coverage: 95.94% and project coverage change: +0.63 🎉

Comparison is base (725e16a) 88.23% compared to head (d9f48fa) 88.87%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #124      +/-   ##
==========================================
+ Coverage   88.23%   88.87%   +0.63%     
==========================================
  Files          15       15              
  Lines        1556     1672     +116     
==========================================
+ Hits         1373     1486     +113     
- Misses        183      186       +3     
Flag Coverage Δ
macos-latest 88.58% <95.94%> (+0.73%) ⬆️
ubuntu-latest 88.40% <95.94%> (+0.70%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/sources/futures.rs 93.85% <95.94%> (+6.55%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@notgull notgull marked this pull request as ready for review April 9, 2023 16:41
@elinorbgr
Copy link
Member

Looks like your PR changed some behavior, as a test is no longer passing, and it does not look like a fluke.

I keep forgetting that mpsc::Sender is Send but !Sync. Wrapping it in a
mutex fixes that, at the cost of some overhead. Consider switching to
crossbeam-queue or concurrent-queue in the future.
@notgull
Copy link
Member Author

notgull commented Apr 9, 2023

Looks like your PR changed some behavior, as a test is no longer passing, and it does not look like a fluke.

Yeah, I misread how the channels work and made it so it only drained 1 Runnable instead of a chunk of Runnables, which messed up the dispatching tests. This should be fixed now.

src/sources/futures.rs Outdated Show resolved Hide resolved
src/sources/futures.rs Outdated Show resolved Hide resolved
src/sources/futures.rs Show resolved Hide resolved
src/sources/futures.rs Outdated Show resolved Hide resolved
Comment on lines 232 to 233
// Make sure the runnable is never dropped.
std::mem::forget(e);
Copy link
Member

Choose a reason for hiding this comment

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

Why?

Copy link
Member Author

Choose a reason for hiding this comment

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

I added more documentation explaining this situation. Dropping the Runnable in this case is unsound, so the only option is to leak it.

src/sources/futures.rs Outdated Show resolved Hide resolved
@notgull notgull requested a review from elinorbgr April 18, 2023 22:13
Copy link
Member

@elinorbgr elinorbgr left a comment

Choose a reason for hiding this comment

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

Alright, LGTM, thanks!

@elinorbgr elinorbgr merged commit 0ba3f1e into Smithay:master Apr 27, 2023
@notgull notgull deleted the async-task branch April 27, 2023 15:00
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.

2 participants