-
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
--- | ||
header: | ||
profile-version: 1 | ||
binary-name: 'reader-yaml.test.tmp.exe' | ||
binary-build-id: '<unknown>' | ||
profile-flags: [ lbr ] | ||
profile-origin: branch profile reader | ||
profile-events: '' | ||
dfs-order: false | ||
functions: | ||
- name: SolveCubic | ||
fid: 6 | ||
hash: 0xC6E9098E973BBE19 | ||
exec: 151 | ||
nblocks: 18 | ||
blocks: | ||
- bid: 0 | ||
insns: 43 | ||
hash: 0xed4db287e71c0000 | ||
exec: 151 | ||
succ: [ { bid: 1, cnt: 151, mis: 2 }, { bid: 7, cnt: 0 } ] | ||
- bid: 1 | ||
insns: 7 | ||
hash: 0x39330000e4560088 | ||
succ: [ { bid: 13, cnt: 151 }, { bid: 2, cnt: 0 } ] | ||
- bid: 13 | ||
insns: 26 | ||
hash: 0xa9700000fe202a7 | ||
succ: [ { bid: 3, cnt: 89 }, { bid: 2, cnt: 10 } ] | ||
- bid: 3 | ||
insns: 9 | ||
hash: 0x62391dad18a700a0 | ||
succ: [ { bid: 5, cnt: 151 } ] | ||
- bid: 5 | ||
insns: 9 | ||
hash: 0x4d906d19ecec0111 | ||
- name: usqrt | ||
fid: 7 | ||
hash: 0x8B62B1F9AD81EA35 | ||
exec: 20 | ||
nblocks: 6 | ||
blocks: | ||
- bid: 0 | ||
insns: 4 | ||
hash: 0x1111111111111111 | ||
exec: 20 | ||
succ: [ { bid: 1, cnt: 0 } ] | ||
- bid: 1 | ||
insns: 9 | ||
hash: 0x27e43a5e10cd0010 | ||
succ: [ { bid: 3, cnt: 320, mis: 171 }, { bid: 2, cnt: 0 } ] | ||
- bid: 3 | ||
insns: 2 | ||
hash: 0x4db935b6471e0039 | ||
succ: [ { bid: 1, cnt: 300, mis: 33 }, { bid: 4, cnt: 20 } ] | ||
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# This script checks that YamlProfileReader in llvm-bolt is reading data | ||
# correctly and stale data is corrected by profile inference. | ||
|
||
RUN: yaml2obj %p/Inputs/blarge.yaml &> %t.exe | ||
RUN: llvm-bolt %t.exe -o %t.null -b %p/Inputs/blarge_profile_stale.std-hash.yaml \ | ||
RUN: --print-cfg --print-only=usqrt,SolveCubic --infer-stale-profile=1 -v=1 \ | ||
RUN: 2>&1 | FileCheck %s | ||
|
||
# Verify that yaml reader works as expected. | ||
CHECK: pre-processing profile using YAML profile reader | ||
CHECK: BOLT-INFO: YAML profile with hash: std::hash | ||
|
||
# Function "SolveCubic" has stale profile, since there is one jump in the | ||
# profile (from bid=13 to bid=2) which is not in the CFG in the binary. The test | ||
# verifies that the inference is able to match two blocks (bid=1 and bid=13) | ||
# using "loose" hashes and then correctly propagate the counts. | ||
|
||
CHECK: Binary Function "SolveCubic" after building cfg { | ||
CHECK: State : CFG constructed | ||
CHECK: Address : 0x400e00 | ||
CHECK: Size : 0x368 | ||
CHECK: Section : .text | ||
CHECK: IsSimple : 1 | ||
CHECK: BB Count : 18 | ||
CHECK: Exec Count : 151 | ||
CHECK: Branch Count: 552 | ||
CHECK: } | ||
# Verify block counts. | ||
CHECK: .LBB00 (43 instructions, align : 1) | ||
CHECK: Successors: .Ltmp[[#BB07:]] (mispreds: 0, count: 0), .LFT[[#BB01:]] (mispreds: 0, count: 151) | ||
CHECK: .LFT[[#BB01:]] (5 instructions, align : 1) | ||
CHECK: Successors: .Ltmp[[#BB013:]] (mispreds: 0, count: 151), .LFT[[#BB02:]] (mispreds: 0, count: 0) | ||
CHECK: .Ltmp[[#BB03:]] (26 instructions, align : 1) | ||
CHECK: Successors: .Ltmp[[#BB05:]] (mispreds: 0, count: 151), .LFT[[#BB04:]] (mispreds: 0, count: 0) | ||
CHECK: .Ltmp[[#BB05:]] (9 instructions, align : 1) | ||
CHECK: .Ltmp[[#BB013:]] (12 instructions, align : 1) | ||
CHECK: Successors: .Ltmp[[#BB03:]] (mispreds: 0, count: 151) | ||
CHECK: End of Function "SolveCubic" | ||
|
||
# Function "usqrt" has stale profile, since the number of blocks in the profile | ||
# (nblocks=6) does not match the size of the CFG in the binary. The entry | ||
# block (bid=0) has an incorrect (missing) count, which should be inferred by | ||
# the algorithm. | ||
|
||
CHECK: Binary Function "usqrt" after building cfg { | ||
CHECK: State : CFG constructed | ||
CHECK: Address : 0x401170 | ||
CHECK: Size : 0x43 | ||
CHECK: Section : .text | ||
CHECK: IsSimple : 1 | ||
CHECK: BB Count : 5 | ||
CHECK: Exec Count : 20 | ||
CHECK: Branch Count: 640 | ||
CHECK: } | ||
# Verify block counts. | ||
CHECK: .LBB01 (4 instructions, align : 1) | ||
CHECK: Successors: .Ltmp[[#BB113:]] (mispreds: 0, count: 20) | ||
CHECK: .Ltmp[[#BB113:]] (9 instructions, align : 1) | ||
CHECK: Successors: .Ltmp[[#BB112:]] (mispreds: 0, count: 320), .LFT[[#BB10:]] (mispreds: 0, count: 0) | ||
CHECK: .LFT[[#BB10:]] (2 instructions, align : 1) | ||
CHECK: Successors: .Ltmp[[#BB112:]] (mispreds: 0, count: 0) | ||
CHECK: .Ltmp[[#BB112:]] (2 instructions, align : 1) | ||
CHECK: Successors: .Ltmp[[#BB113:]] (mispreds: 0, count: 300), .LFT[[#BB11:]] (mispreds: 0, count: 20) | ||
CHECK: .LFT[[#BB11:]] (2 instructions, align : 1) | ||
CHECK: End of Function "usqrt" | ||
# Check the overall inference stats. | ||
CHECK: 2 out of 7 functions in the binary (28.6%) have non-empty execution profile | ||
CHECK: inferred profile for 2 (100.00% of profiled, 100.00% of stale) functions responsible for {{.*}} samples ({{.*}} out of {{.*}}) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.