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] Provide backwards compatibility for YAML profile with std::hash #74253

Merged
merged 1 commit into from
Dec 11, 2023

Conversation

aaupov
Copy link
Contributor

@aaupov aaupov commented Dec 3, 2023

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 as
std-hash: true, preserving old behavior.

Same as profile-use-dfs in https://reviews.llvm.org/D156176.

@aaupov aaupov added the BOLT label Dec 3, 2023
Copy link

github-actions bot commented Dec 3, 2023

:white_check_mark: With the latest revision this PR passed the C/C++ code formatter.

@aaupov aaupov force-pushed the revert-xxh branch 2 times, most recently from 268cc19 to c7c5bf9 Compare December 3, 2023 21:46
Copy link
Contributor

@maksfb maksfb left a 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".

bolt/lib/Profile/YAMLProfileReader.cpp Outdated Show resolved Hide resolved
bolt/lib/Passes/IdenticalCodeFolding.cpp Outdated Show resolved Hide resolved
@aaupov aaupov changed the title [BOLT] Introduce profile-use-std-hash [BOLT] Provide backwards compatibility for YAML profile with std::hash Dec 6, 2023
@aaupov
Copy link
Contributor Author

aaupov commented Dec 7, 2023

We can likely have a couple of binary/YAML test cases that verify backwards compatibility

Added a YAML test checking backwards compatibility. It reuses the test bolt/test/X86/reader-stale-yaml.test and its input (bolt/test/X86/Inputs/blarge_profile_stale.yaml) from before xxh diff.

bolt/include/bolt/Core/BinaryFunction.h Outdated Show resolved Hide resolved
@aaupov
Copy link
Contributor Author

aaupov commented Dec 11, 2023

Renamed Xxh3 to XXH3.
Added the Default enum value aliased to XXH3 to avoid confusion which hash to use.

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.
@aaupov aaupov merged commit b039ccc into llvm:main Dec 11, 2023
4 checks passed
@aaupov aaupov deleted the revert-xxh branch December 11, 2023 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants