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

Win10: Use GetSystemTimePreciseAsFileTime directly #121633

Merged
merged 2 commits into from
Mar 11, 2024

Conversation

ChrisDenton
Copy link
Member

On Windows 10 we can use GetSystemTimePreciseAsFileTime directly instead of lazy loading it (with a fallback).

@rustbot
Copy link
Collaborator

rustbot commented Feb 26, 2024

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added 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 Feb 26, 2024
@rust-log-analyzer

This comment has been minimized.

@rustbot
Copy link
Collaborator

rustbot commented Feb 26, 2024

The Miri subtree was changed

cc @rust-lang/miri

@ChrisDenton
Copy link
Member Author

ChrisDenton commented Feb 26, 2024

This adds GetSystemTimePreciseAsFileTime to miri, which is identical to GetSystemTimeAsFileTime except that it promises to use the highest precision clock available. Since miri didn't artificially lower the precision in the first place, there is no difference between the two functions.

@RalfJung
Copy link
Member

RalfJung commented Feb 26, 2024 via email

@ChrisDenton
Copy link
Member Author

Should Miri be limiting the precision of the other one, if that's what the official implementation does?

🤷 Technically it's left unspecified in the Microsoft docs so it could just be the same clock and it's free to change between versions.

In practice it has similar limitations to GetTickCount as mentioned in Windows Time

GetTickCount and GetTickCount64 are limited to the resolution of the system timer, which is approximately 10 milliseconds to 16 milliseconds

This can also be adjusted with timeBeginPeriod. But as far as I can tell miri doesn't currently emulate system "ticks" (which are used for all sorts of timers and scheduling) and it would perhaps be odd to implement it only for one function.

@RalfJung
Copy link
Member

r=me on the Miri part

This is exactly the same as GetSystemTimeAsFileTime except that it promises maximum precision.
@ChrisDenton
Copy link
Member Author

Squished commits.

Copy link
Member

@Noratrieb Noratrieb 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 (Chris begged asked me to review it)

@@ -345,6 +345,10 @@ extern "system" {
pub fn GetSystemTimeAsFileTime(lpsystemtimeasfiletime: *mut FILETIME) -> ();
}
#[link(name = "kernel32")]
extern "system" {
Copy link
Member

Choose a reason for hiding this comment

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

why are these individual extern blocks?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because that's what are binding generator generates. The README has a few details about how this file is made.

Copy link
Member Author

Choose a reason for hiding this comment

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

Basically it's all made by the windows-bindgen crate.

Copy link
Member

Choose a reason for hiding this comment

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

ah

@Noratrieb
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Mar 7, 2024

📌 Commit eb40adb has been approved by Nilstrieb

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 7, 2024
jhpratt added a commit to jhpratt/rust that referenced this pull request Mar 11, 2024
Win10: Use `GetSystemTimePreciseAsFileTime` directly

On Windows 10 we can use `GetSystemTimePreciseAsFileTime` directly instead of lazy loading it (with a fallback).
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 11, 2024
Rollup of 8 pull requests

Successful merges:

 - rust-lang#121148 (Add slice::try_range)
 - rust-lang#121573 (unix_sigpipe: Add test for SIGPIPE disposition in child processes)
 - rust-lang#121633 (Win10: Use `GetSystemTimePreciseAsFileTime` directly)
 - rust-lang#121840 (Expose the Freeze trait again (unstably) and forbid implementing it manually)
 - rust-lang#121907 (skip sanity check for non-host targets in `check` builds)
 - rust-lang#122002 (std::threads: revisit stack address calculation on netbsd.)
 - rust-lang#122108 (Add `target.*.runner` configuration for targets)
 - rust-lang#122298 (RawVec::into_box: avoid unnecessary intermediate reference)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 11, 2024
Rollup of 9 pull requests

Successful merges:

 - rust-lang#121148 (Add slice::try_range)
 - rust-lang#121633 (Win10: Use `GetSystemTimePreciseAsFileTime` directly)
 - rust-lang#121840 (Expose the Freeze trait again (unstably) and forbid implementing it manually)
 - rust-lang#121907 (skip sanity check for non-host targets in `check` builds)
 - rust-lang#122002 (std::threads: revisit stack address calculation on netbsd.)
 - rust-lang#122108 (Add `target.*.runner` configuration for targets)
 - rust-lang#122298 (RawVec::into_box: avoid unnecessary intermediate reference)
 - rust-lang#122315 (Allow multiple `impl Into<{D,Subd}iagMessage>` parameters in a function.)
 - rust-lang#122326 (Optimize `process_heap_alloc`)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 1a989e0 into rust-lang:master Mar 11, 2024
11 checks passed
@rustbot rustbot added this to the 1.78.0 milestone Mar 11, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Mar 11, 2024
Rollup merge of rust-lang#121633 - ChrisDenton:precise, r=Nilstrieb

Win10: Use `GetSystemTimePreciseAsFileTime` directly

On Windows 10 we can use `GetSystemTimePreciseAsFileTime` directly instead of lazy loading it (with a fallback).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-windows Operating system: Windows S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

7 participants