-
Notifications
You must be signed in to change notification settings - Fork 125
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
Implement --deterministic, for chaotic but repeatable color selection #190
Conversation
Codecov Report
@@ Coverage Diff @@
## master #190 +/- ##
==========================================
+ Coverage 90.31% 90.36% +0.05%
==========================================
Files 17 17
Lines 2219 2231 +12
==========================================
+ Hits 2004 2016 +12
Misses 215 215
Continue to review full report at Codecov.
|
Thanks, this looks pretty good! Left some comments inline. I'm not sure why the colors are generally dark, though the second hash trick I mentioned might help. I'd also like to see a new test case for this. |
Co-authored-by: Jon Gjengset <jon@thesquareplanet.com>
Co-authored-by: Jon Gjengset <jon@thesquareplanet.com>
I'd love to add some tests, but... how? The existing test suite doesn't run on its own, it seems like maybe it's missing some files?
|
Ah, yes, it also runs a bunch of tests from the upstream Perl flamegraph repository, which has to be checked out with $ git submodule update --init |
@jonhoo The test I've added passes on my machine, I would really appreciate some assistance here. I don't know why it's not working in the CI or whether this is even the test we want. |
Hmm, looking at the test output, it seems like the test run generates a different color than the committed test file. Even more interestingly, different runs of the test produce different values, which suggest that the generated color is not actually deterministic. Are you sure the test is actually being run on your computer? The failure seems to be consistent across all the different OSes. Separately, you have to use |
@@ -342,7 +342,8 @@ pub(super) fn color( | |||
(name_hash, reverse_name_hash, reverse_name_hash) | |||
} else if deterministic { | |||
use std::hash::Hasher; | |||
let mut hasher = ahash::AHasher::default(); | |||
// Do not use AHasher::default; it is seeded with a compile-time RNG |
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.
Ah, good catch!
Excellent, thank you! |
Released in 0.10.1. |
From the runs I've tried out with this so far it seems like the color selection is a bit biased towards darker shades, which is unfortunate. Not entirely sure what to do about that.