-
Notifications
You must be signed in to change notification settings - Fork 33
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
On macOS arm64, quanta::Instant::elapsed
method tends to return a shorter duration than std::time::Instant::elapsed
does
#96
Comments
Thanks for filing this issue and providing an MCVE. 🙇🏻 What version of macOS are you testing this on? When I run this locally on an older macOS platform (Intel-based MBP, macOS Ventura 13.4), I don't observe a difference between the two variants... so it seems like either the difference is coming from the macOS version, or potentially from the hardware architecture. |
Ah, sorry, I forgot to mention. It is macOS Sonoma 14.2.1. (Mac mini M1) |
Alright, good to know. I'm not ready to update locally to Sonoma yet (😅) but I think we can continue to do some debugging here. Firstly, here's a slightly updated version of your MVCE which uses Secondly, I created a branch -- This change is based a hunch that the way we measure time on macOS currently -- |
Thanks for working on this so quickly!
I believe it is working! Here are the results. Quanta v0.12.1 $ cargo tree -i quanta
quanta v0.12.1
└── quanta-stdlib-deviation v0.1.0 (...)
$ cargo run --release
running test for std...
.................... done!
std statistics:
min: 1000300544ns
p50: 1004347391ns
p99: 1005293567ns
max: 1005293567ns
range: 4993023ns (100.03005% to 100.52936% of target)
running test for quanta...
.................... done!
quanta statistics:
min: 984543232ns
p50: 988971007ns
p99: 988979199ns
max: 988979199ns
range: 4435967ns (98.45432% to 98.89792% of target) Quanta $ cargo tree -i quanta
quanta v0.12.1 (https://github.com/metrics-rs/quanta?branch=tobz/debug-macos-measurement-error#55d077b1)
└── quanta-stdlib-deviation v0.1.0 (...)
$ cargo run --release
running test for std...
.................... done!
std statistics:
min: 1000251392ns
p50: 1005043711ns
p99: 1005060095ns
max: 1005060095ns
range: 4808703ns (100.02514% to 100.50601% of target)
running test for quanta...
.................... done!
quanta statistics:
min: 1000505344ns
p50: 1003974655ns
p99: 1005060095ns
max: 1005060095ns
range: 4554751ns (100.05053% to 100.50601% of target) Environment
$ sw_vers
ProductName: macOS
ProductVersion: 14.2.1
BuildVersion: 23C71
$ rustc -Vv
rustc 1.75.0 (82e1608df 2023-12-21)
binary: rustc
commit-hash: 82e1608dfa6e0b5569232559e3d385fea5a93112
commit-date: 2023-12-21
host: aarch64-apple-darwin
release: 1.75.0
LLVM version: 17.0.6 |
Awesome! I'll get the change merged in shortly. 👍🏻 |
Released the fix as Thanks again for the report and providing the MVCE. 🙇🏻 |
On macOS arm64,
quanta::Instant::elapsed
method tends to return a shorter duration thanstd::time::Instant::elapsed
does.Steps to reproduce
Run the following program. It measures the duration of 1 send thread sleep using
std::time::Instant
andquanta::Instant
.Expected result
Both
std::time::Instant
andquanta::Instant
should return durations slightly longer than 1 second, the sleep duration.Actual results
Rust 1.75.0.
quanta::Instant::elapsed
method returned durations slightly shorter then 1 second.quanta::Instant::elapsed
method returned durations slightly longer then 1 second.std::time::Instant
quanta::Instant
v0.12.1quanta::Instant
v0.11.1aarch64-apple-darwin
aarch64-unknown-linux-gnu
x86_64-unknown-linux-gnu
The text was updated successfully, but these errors were encountered: