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

Implements the waker changes for task API stabilization. #1445

Merged
merged 8 commits into from
Feb 19, 2019

Conversation

Matthias247
Copy link
Contributor

This removes LocalWaker, and adds ArcWake to the library.

@Matthias247
Copy link
Contributor Author

That's my current development snapshot. Requires rust-lang/rust#57992 to get merged.
It doesn't build for me locally due to some issue with the rand crate. Not sure whether that is futures related, or whether I have a bad commit of the nightly rustc version.

There's a ton of churn in this change, but most things are renaming. The important parts will be moving the Waker-related things over, e.g. inside LocalPool and the Compat adapter.

@Nemo157
Copy link
Member

Nemo157 commented Jan 30, 2019

@Matthias247 try running cargo update -p rand -p rand_core (and then again with all the actual versions of rand_core detected, or just do a full cargo update), rand used a semver trick to do a non-breaking breaking change which causes issues with cargo's normal minimal update on build.

@Matthias247
Copy link
Contributor Author

Thanks @Nemo157. cargo update helped and I could compile things now. I fixed all compilation issues and the normal unit tests are running. doctests are not running, likely because my locally compiled rustc doesn't have rustdoc included.

If you want to review it, the main focus should be on components which involved Waker: LocalPool, futures-unordered, ArcWake, waker_ref and the few test wakers.

@ebkalderon
Copy link
Contributor

@Matthias247 Any updates on this? Several other pending PRs can't pass CI and are blocked until this one gets merged.

@Matthias247
Copy link
Contributor Author

@ebkalderon From mv POV that's implemented. The checks were failing because it was never built by CI against the changes in std.
So that needs to happen. And a review.

Copy link
Member

@Nemo157 Nemo157 left a comment

Choose a reason for hiding this comment

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

Mostly looks good to me (the Task code reductions look great).

futures-test/src/task/mod.rs Outdated Show resolved Hide resolved
// For simplicity reasons wrap the Waker into an Arc.
// We can optmize this again later on and reintroduce WakerLt<'a> which
// derefs to Waker, and where cloning it through RawWakerVTable returns
// an Arc version
Copy link
Member

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

Choose a reason for hiding this comment

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

I think you meant "optimize" here and not "optmize?"

Copy link
Contributor

Choose a reason for hiding this comment

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

This is now cloning the current task twice on every single poll.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, we'll want to follow up with this optimization pretty quickly since this will cause an allocation every time as_waker is called :(

futures-util/src/task/arc_wake.rs Show resolved Hide resolved
futures-util/src/task/arc_wake.rs Show resolved Hide resolved
futures-util/src/task/waker_ref.rs Show resolved Hide resolved
@Nemo157
Copy link
Member

Nemo157 commented Feb 15, 2019

The CI failures seem to be related to the conflicting files after merging this with master.

@Matthias247
Copy link
Contributor Author

@Nemo157 I tried to resolve the conflicts in the web UI. If that won't work, I will only get to it tonight (PST). If you want to look into it before in order to unblock the library, feel free to merge and resolve it. Shouldn't be large issues.

@Matthias247
Copy link
Contributor Author

@cramertj , @Nemo157 Everything builds now. The remaining failing test is due to CI testing against an older version of rustc which obviously doesn't have the required changes.

@taiki-e
Copy link
Member

taiki-e commented Feb 16, 2019

@Matthias247 Could you change the minimum required version on .travis.yml and README.md from nightly-2019-01-11 to nightly-2019-02-15?

@Matthias247
Copy link
Contributor Author

@taiki-e Thanks! That helped

@Nemo157
Copy link
Member

Nemo157 commented Feb 16, 2019

(Just a note, there are some minor no_std issues with the current changes here, but I have a branch fixing them as I work through updating embrio as well, if this is merged before I finish that update I'll open a separate PR, otherwise I can open a PR to this PR to get those in as well).

EDIT: In order to make sure it's tested properly I'll do the fixes in a separate PR that also fixes #1396.

@@ -27,20 +27,20 @@ fn unbounded_1_tx(b: &mut Bencher) {
for i in 0..1000 {

// Poll, not ready, park
assert_eq!(Poll::Pending, rx.poll_next_unpin(lw));
assert_eq!(Poll::Pending, rx.poll_next_unpin(waker));
Copy link
Member

Choose a reason for hiding this comment

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

nit: here and elsewhere, I think it'd be fine to abbreviate waker as e.g. wk since it's used so often. I can open this as a separate followup change, though, since it seems potentially controversial.

@cramertj
Copy link
Member

I've gone ahead and rebased this and will merge when tests pass, and plan to follow up with some changes to cleanup a few issues that were brought up here before releasing.

@Nemo157 Nemo157 mentioned this pull request Feb 19, 2019
@cramertj cramertj merged commit 1339c87 into rust-lang:master Feb 19, 2019
@Matthias247 Matthias247 deleted the waker_changes3 branch February 20, 2019 02:55
@cramertj cramertj mentioned this pull request Feb 20, 2019
/// This macro bakes in propagation of `Err` signals by returning early.
/// This macro bakes in propagation of `Pending` and `Err` signals by returning early.
#[macro_export]
macro_rules! try_poll {
Copy link

Choose a reason for hiding this comment

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

@Matthias247 Why was this macro removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jsancio I am not aware having actively removed this in my change. Maybe it was part of @cramertj's cleanup effort, or a rebase/merge artifact. @cramertj Do you know? Otherwise it might have been a mistake.

Copy link
Contributor

Choose a reason for hiding this comment

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

In 1339c87#diff-01958fc79efbf83fe4d83d5f9cb5b5ec, @cramertj replaced uses of try_poll! with ?

Copy link

Choose a reason for hiding this comment

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

Great. Thanks for the response.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, try_poll is kinda useless now that ? works on Poll.

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.

8 participants