diff options
author | Ellis Hoag <ellis.sparky.hoag@gmail.com> | 2025-08-08 10:21:29 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-08-08 10:21:29 -0700 |
commit | 3b884db6ef458148ddc71e8133b334f8e1794ff9 (patch) | |
tree | 42d521b0a074dd659aba670dee445868ffd31026 /llvm/test | |
parent | 688551f05cf5f6c90e0f5edc890ee13bb563fa95 (diff) | |
download | llvm-3b884db6ef458148ddc71e8133b334f8e1794ff9.zip llvm-3b884db6ef458148ddc71e8133b334f8e1794ff9.tar.gz llvm-3b884db6ef458148ddc71e8133b334f8e1794ff9.tar.bz2 |
[InstrProf] Fix trace reservoir sampling (#152563)
`InstrProfWriter::addTemporalProfileTraces()` did not correctly account
for when the sources traces are sampled, but the reservoir size is
larger than what it was before, meaning there is room for more traces.
Also, if the reservoir size decreased, meaning traces should be
truncated.
Depends on https://github.com/llvm/llvm-project/pull/152550 for the test
refactor
Diffstat (limited to 'llvm/test')
-rw-r--r-- | llvm/test/tools/llvm-profdata/merge-traces.proftext | 9 | ||||
-rw-r--r-- | llvm/test/tools/llvm-profdata/trace-limit.proftext | 2 |
2 files changed, 10 insertions, 1 deletions
diff --git a/llvm/test/tools/llvm-profdata/merge-traces.proftext b/llvm/test/tools/llvm-profdata/merge-traces.proftext index 57ea16c..3512f33 100644 --- a/llvm/test/tools/llvm-profdata/merge-traces.proftext +++ b/llvm/test/tools/llvm-profdata/merge-traces.proftext @@ -12,15 +12,24 @@ # RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size=2 %t-2.profdata %s %s --text | FileCheck %s --check-prefixes=CHECK,SEEN4,SAMPLE2 # RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size=2 %t-2.profdata %t-2.profdata --text | FileCheck %s --check-prefixes=CHECK,SEEN4,SAMPLE2 +# Test that we can increase the reservoir size, even if inputs are sampled +# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size=2 %s %s %s %s -o %t-4.profdata +# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size=4 %t-4.profdata %t-4.profdata --text | FileCheck %s --check-prefixes=CHECK,SEEN8,SAMPLE4 + +# Test that decreasing the reservoir size truncates traces +# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size=1 %t-4.profdata --text | FileCheck %s --check-prefixes=CHECK,SEEN4,SAMPLE1 + # CHECK: :temporal_prof_traces # CHECK: # Num Temporal Profile Traces: # SAMPLE1: 1 # SAMPLE2: 2 +# SAMPLE4: 4 # CHECK: # Temporal Profile Trace Stream Size: # SEEN1: 1 # SEEN2: 2 # SEEN3: 3 # SEEN4: 4 +# SEEN8: 8 # CHECK: a,b,c, # Header diff --git a/llvm/test/tools/llvm-profdata/trace-limit.proftext b/llvm/test/tools/llvm-profdata/trace-limit.proftext index e246ee8..6b4f974 100644 --- a/llvm/test/tools/llvm-profdata/trace-limit.proftext +++ b/llvm/test/tools/llvm-profdata/trace-limit.proftext @@ -11,7 +11,7 @@ # RUN: llvm-profdata merge --temporal-profile-max-trace-length=1000 %s -o %t.profdata # RUN: llvm-profdata show --temporal-profile-traces %t.profdata | FileCheck %s --check-prefixes=CHECK,ALL -# NONE: Temporal Profile Traces (samples=0 +# NONE: Temporal Profile Traces (samples=0 seen=0): # CHECK: Temporal Profile Traces (samples=1 seen=1): # SOME: Trace 0 (weight=1 count=2): # ALL: Trace 0 (weight=1 count=3): |