-
Notifications
You must be signed in to change notification settings - Fork 66
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
MacOS reports it has nano-second precision, but it most often doesn't --> Bad nano benchmark results #313
Comments
Confirmed it's a bug on erlang at least with the reported resolution. |
Alrighty. After all of this time I'm here, I'm actually looking at it. Also, sorry for the time but well.. life and stuff. Fuck 2020. Anyhow. Investigating this is worse than I anticipated. I initially managed to reproduce but now seemingly can't... I only switched a couple of things around (different formatter) but now... it seems to be working fine? Not sure if it's the mood of the os or whatever. I changed the bottom of the original script like this: bench_fun = fn -> View.render("iodata-long", %{character: character}) end
Benchee.run(
%{
"iodata" => bench_fun,
},
formatters: [
{Benchee.Formatters.Console, extended_statistics: true}
]
)
alias Benchee.Benchmark.Collect.NativeTime
fun = fn _i -> {time, _} = NativeTime.collect(bench_fun); time end
1..1000
|> Enum.map(fun)
|> Enum.take(-50)
|> IO.inspect()
1..1000
|> Enum.map(fun)
|> Enum.take(-50)
|> IO.inspect() and the output I get is quite fine and looks okay:
Albeit earlier I got this: Not sure what gives. |
which now... makes me think that maybe after all it is the function call overhead measurements that are messing with things. |
Hello, I'm just running into this issue today on a 2018 15" Macbook Pro. I am running Benchee
I am getting graphs like the ones posted here, with many 0us or 1000ns results. It looks like the Erlang issue is resolved in my version of Erlang. Monotonic time results are consistent for me across 5 iex sessions in a row, it looks like I have a lower resolution than the OP:
Here are my results for strings_bench using your edits to the script: Click to expand
Please let me know if I can assist with this further, I'm glad to help out. |
This was FINALLY solved in #339 |
Finally got around to verifying this once I got a hand on a Mac, I'll add more details from my own computer later but the gist is this:
Problem
In whatever circumstance that I don't understand
:erlang.monotonic_time()
only answers in microsecond precision while acting like nanosecond. The impact is that we get measurements that aren't precise enough and as a result are reporting weird measurements/medians of 0ns or what not.Here you can see the
monotonic_time()
behaviour changing, between answering in thousands (microseconds) and precise (nanoseconds)and yes, the native time unit claims to be
:nanosecond
(no change when converting native to nanosecond):as a result our measurements can look like this and produce very odd results:
Background
See this twitter thread, basically I noticed odd looking benchmarking results in this blog post (a median of 0ns). The benchmark can be found here
Further Debugging
After looking into the Erlang Time Correction docs I hoped that the os_monotonic information might be different but apart from the bad time values it seems to be the same between Mac and my linux machine:
I also investigated time_warp_mode but results on the mac didn't change.
Opened an issue at Erlang/OTP: https://bugs.erlang.org/browse/ERL-1067
Possible Solutions
Workarounds possible now
Environment
Values obtained from a MBP from ~2014/2015 running 10.14.2 Mojave on an i5 processor
Is this a benchee bug?
Yes and No. Yes the results reported in the end aren't accurate, however I'd say that this time reporting with another precision than reported is a bug in the BEAM or maybe MacOS or I dunno what.
We still need to fix it/make it better as lots of people out there are doing benchmarks on MacOS.
Can I help?
If you have a mac you can run the benchmark and post your results: https://github.com/oestrich/strings_bench
If you could run an
iex
shell and run:erlang.monotonic_time()
a couple of times, kill the session and run it again seeing if the precision changes as seen above, that'd be nice. I'd like to see if this happens all the time/for everything or just specific configurations.The text was updated successfully, but these errors were encountered: