-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[BOLT] Provide backwards compatibility for YAML profile with std::hash #74253
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
Conversation
|
268cc19
to
c7c5bf9
Compare
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.
How about we write a new field to YAML with a hash function name/ID? In the reader, we default to std::hash
for backwards compatibility as you already do. If we are not planning on using std::hash
in the future (for writing), perhaps the option is not needed at all? We can likely have a couple of binary/YAML test cases that verify backwards compatibility.
Suggestion for the title: "Provide backwards compatibility for YAML profile with std::hash".
Added a YAML test checking backwards compatibility. It reuses the test |
Renamed Xxh3 to XXH3. |
Summary: xxh3 hash is the default for newly produced profile (sets `hash-func: xxh3`), whereas the profile that doesn't specify `hash-func` will be treated as `hash-func: std-hash`, preserving old behavior.
bolt/test/X86/reader-stale-yaml-std.test introduced by this patch might rely on determinism of My Hashing.h change #96282 might cause bolt/test/X86/reader-stale-yaml-std.test to fail: #96282 (comment) |
BlendedHashes[I].InstrHash = (uint16_t)InstrHash; | ||
if (HashFunction == HashFunction::StdHash) { | ||
uint64_t InstrHash = std::hash<std::string>{}(InstrHashStr); | ||
BlendedHashes[I].InstrHash = (uint16_t)hash_value(InstrHash); |
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.
std::hash<std::string>
results are quite good and do not need another bit mixer.
llvm::hash_value
is non-deterministic (#96282).
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.
Yes, we realized that but couldn't make the change at the time (breaks profile matching). But now that the default has switched to xxh3 we can drop hash_value and adjust tests.
This test from llvm#74253 relies on particular hash values from Hashing.h. The test fails in LLVM_ENABLE_ABI_BREAKING_CHECKS=on modes (llvm#96282) or whenever Hashing.h implementation changes.
This test from llvm#74253 relies on particular hash values from Hashing.h. The test fails in LLVM_ENABLE_ABI_BREAKING_CHECKS=on modes (llvm#96282) or whenever Hashing.h implementation changes.
Provide backwards compatibility for YAML profile that uses
std::hash
:xxh3 hash is the default for newly produced profile (sets
std-hash: false
),whereas the profile that doesn't specify
std-hash
will be treated asstd-hash: true
, preserving old behavior.Same as
profile-use-dfs
in https://reviews.llvm.org/D156176.