-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
time: small implementation cleanups #6517
Conversation
`StateCell::mark_pending` already uses a loop to retry the compare exchange operation if it fails. The logic within the loop would handle a spurious failure like any other failure, so `compare_exchange_weak` makes the implementation more efficient for some platforms.
This replaces a manual implementation of `Instant::saturating_duration_since` with the actual one. Clippy already catches this for primitive integer types via the `manual_saturating_arithmetic` lint, as demonstrated by the following example: ```rs fn saturating_sub(val: usize, n: usize) -> usize { val.checked_sub(n).unwrap_or(0) } ```
As explained by the comment removed by this commit earlier Rust versions didn't have an ergonomic way of building arrays of any size of non-Copy types. Rust 1.63 stabilized `array::from_fn`, fixing the above issue and by making it easy to construct arrays from a constructor.
This replaces `Wheel::levels`, currently represented as a `Vec` of 6 elements, into an array. This should help eliminate some bounds checks from accesses to `levels`. This changes the size of `Wheel` from 48 bytes to 32 bytes on x86_64. The initial implementation didn't Box the array, resulting into `Wheel` having a size of 6264 bytes and loom tests overflowing their stack.
Replaces the manual implementation of a waker list with `WakeList`.
cc @wathenjiang |
All LGTM! However, it should be pointed out that in the current implementation, the behavior of I think we should ensure that the order of this FIFO remains unchanged. |
Good catch! I've opened a separate PR to fix it #6521 |
Order of wakers is generally not something we guarantee, but I think having |
There was a problem hiding this 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.
Motivation
While reading how the timer driver works, I found several things that could be cleaned up.
Solution
I've included those fixes in this PR.