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

Specialize sleep_until implementation #118480

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

dvdsk
Copy link
Contributor

@dvdsk dvdsk commented Nov 30, 2023

Draft (I need the CI tests, which will probably fail)
related tracking issue: #113752

Replaces the generic catch all implementation with target_os specific ones for: linux/netbsd/freebsd/android/solaris/illumos, wasi, macos/ios/tvos/watchos and windows.

Points of attention:

  • Adds extern "C" calls to mach_wait_until and mach_timebase_info for macos etc. We could also import them from the mach2 crate, but then we depend on mach2 and we need to modify mach2 to work as an std dep (adding a feature rustc-dep-of-std).
  • The implementations need access to the target_os specific details of the Instant type. For that I added an into_inner and made some fields public. Is there a neater way?
  • All untested, I only have access to an linux install. I hope the CI catches any issues.

@rustbot
Copy link
Collaborator

rustbot commented Nov 30, 2023

r? @cuviper

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added O-hermit Operating System: Hermit O-itron Operating System: ITRON O-SGX Target: SGX O-unix Operating system: Unix-like O-wasi Operating system: Wasi, Webassembly System Interface O-windows Operating system: Windows S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Nov 30, 2023
@dvdsk
Copy link
Contributor Author

dvdsk commented Nov 30, 2023

Not ready for review, however I need CI to run.

@dvdsk dvdsk marked this pull request as ready for review November 30, 2023 16:03
@cuviper
Copy link
Member

cuviper commented Nov 30, 2023

We don't have a configured way to try full CI, but you can copy specific jobs from auto to pr here:

Then ./x.py run src/tools/expand-yaml-anchors to update the real config, and push that as a temporary commit.

Copy link
Contributor

@joboet joboet left a comment

Choose a reason for hiding this comment

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

I tested this on my local macOS machine. While the implementation works, the test currently fails because its success margin is too small.

library/std/tests/thread.rs Outdated Show resolved Hide resolved
library/std/src/thread/mod.rs Show resolved Hide resolved
@bors
Copy link
Contributor

bors commented Dec 7, 2023

☔ The latest upstream changes (presumably #116565) made this pull request unmergeable. Please resolve the merge conflicts.

@dvdsk dvdsk force-pushed the sleep_until_os_specific_impl branch 2 times, most recently from 7ace020 to 1e36e08 Compare December 24, 2023 14:44
@rustbot rustbot added A-testsuite Area: The testsuite used to check the correctness of rustc T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue. labels Dec 24, 2023
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@dvdsk dvdsk force-pushed the sleep_until_os_specific_impl branch from 5470a7c to a0f50b6 Compare December 24, 2023 16:44
@dvdsk dvdsk marked this pull request as draft December 24, 2023 16:47
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Jan 13, 2024

☔ The latest upstream changes (presumably #117285) made this pull request unmergeable. Please resolve the merge conflicts.

@cuviper
Copy link
Member

cuviper commented Jan 25, 2024

I'm clearing this from my queue while it's in draft, but you can use ready when you are.

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 25, 2024
@Dylan-DPC
Copy link
Member

@dvdsk any updates on this pr? thanks

@dvdsk
Copy link
Contributor Author

dvdsk commented Aug 2, 2024

There are merge commits (commits with multiple parents) in your changes. We have a no merge policy so these commits will need to be removed for this pull request to be merged.

You can start a rebase with the following commands:

$ # rebase
$ git pull --rebase https://github.com/rust-lang/rust.git master
$ git push --force-with-lease

The following commits are merge commits:

* [fa89b9b](https://github.com/rust-lang/rust/commit/fa89b9b354b832315fe8662090d4a2ecbe2136cd)

* [30870b8](https://github.com/rust-lang/rust/commit/30870b8aaf04b9a721aee8d2eca14c19a6f28493)

* [030b112](https://github.com/rust-lang/rust/commit/030b112252926f66f1c0d2787fb2093e737a2d08)

* [dac9893](https://github.com/rust-lang/rust/commit/dac9893c9ba5bbfa70e25dfe293f9625b86df698)

mostly some misery I had with the submodules causing the merges to not become fast forwards. The commit history is a bit ugly anyway. Ill see if I can clean that up later, maybe just squash it all done to one or two commits.

let info = info.assume_init();
let ticks = nanos * (info.denom as u64) / (info.numer as u64);

let ret = mach_wait_until(ticks);
Copy link
Contributor

Choose a reason for hiding this comment

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

mach_wait_until can be interrupted by signals just like clock_nanosleep, so this should check if ret is KERN_ABORTED (14) and retry in that case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks for finding that out 👍 And nice to read (the stack overflow link) I am not the only one that struggled to find any details on mach_wait_until

@dvdsk dvdsk force-pushed the sleep_until_os_specific_impl branch from d59d09d to bf0ebb9 Compare August 3, 2024 11:31
@rustbot rustbot removed the has-merge-commits PR has merge commits, merge with caution. label Aug 3, 2024
@dvdsk dvdsk force-pushed the sleep_until_os_specific_impl branch from bf0ebb9 to 61439b2 Compare August 3, 2024 11:35
@rust-log-analyzer

This comment has been minimized.

dvdsk and others added 7 commits August 3, 2024 13:53
It is not working and I can not figure out why. Since I am not familiar
with developing on windows I might not be the best person to work on
this.

The work removed in this commit might be a useful jumping off point for
anyone else however.
more unix platforms

target_vendor's done by:
Co-authored-by: Jonas Böttiger <jonasboettiger@icloud.com>
@dvdsk dvdsk force-pushed the sleep_until_os_specific_impl branch from 61439b2 to bbb93cb Compare August 3, 2024 11:56
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@dvdsk dvdsk force-pushed the sleep_until_os_specific_impl branch from a88ec6d to 00f5d5b Compare August 5, 2024 13:15
@dvdsk
Copy link
Contributor Author

dvdsk commented Aug 5, 2024

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 5, 2024
@jieyouxu jieyouxu added the F-sleep_until `#![feature(sleep_until)]` label Aug 8, 2024
@bors
Copy link
Contributor

bors commented Aug 31, 2024

☔ The latest upstream changes (presumably #129809) made this pull request unmergeable. Please resolve the merge conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc F-sleep_until `#![feature(sleep_until)]` O-hermit Operating System: Hermit O-itron Operating System: ITRON O-SGX Target: SGX O-unix Operating system: Unix-like O-wasi Operating system: Wasi, Webassembly System Interface O-windows Operating system: Windows S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants