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

[BOLT] Use deterministic xxh3 for computing BF/BB hashes #72542

Merged
merged 2 commits into from
Nov 27, 2023

Conversation

spupyrev
Copy link
Contributor

@spupyrev spupyrev commented Nov 16, 2023

std::hash and ADT/Hashing::hash_value are non-deterministic functions whose
results might vary across implementation/process/execution. Using xxh3 instead
for computing hashes of BinaryFunctions and BinaryBasicBlock for stale profile
matching.
(A possible alternative is to use ADT/StableHashing.h based on FNV hashing but
xxh3 seems to be more popular in LLVM)

This is to address #65241.

@spupyrev spupyrev marked this pull request as ready for review November 16, 2023 18:01
@spupyrev
Copy link
Contributor Author

The changes is a "completed" version of #65437 with tests -- I didn't know how to commandeer the change so had to create a new PR

Copy link
Contributor

@aaupov aaupov left a comment

Choose a reason for hiding this comment

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

Thanks for fixing the tests and cleaning up the code. Please address one comment in test, otherwise looks good.

@@ -5,19 +5,28 @@ RUN: yaml2obj %p/Inputs/blarge.yaml &> %t.exe
# Testing "usqrt"
RUN: llvm-bolt %t.exe -o /dev/null --b %p/Inputs/blarge_profile_stale.yaml \
RUN: --print-cfg --print-only=usqrt --infer-stale-profile=1 \
RUN: --profile-ignore-hash=1 --profile-use-dfs=0 2>&1 | FileCheck %s -check-prefix=CHECK1
RUN: --profile-ignore-hash=1 --profile-use-dfs=0 --debug-only=bolt-prof 2>&1 | FileCheck %s -check-prefix=CHECK1
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add REQUIRES: asserts for debug logging checks

@spupyrev spupyrev merged commit e7dd596 into llvm:main Nov 27, 2023
2 of 3 checks passed
@spupyrev spupyrev deleted the bolt-deterministic-hashing branch January 19, 2024 23:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bolt] issue about using std::hash in YamlProfileReader and its test case
2 participants