Repository navigation
Commit aa146bf
committed
bench: stop measuring harness overhead in nanosecond benchmarks
One divan bench_refs iteration carries a fixed ~146 instructions of
harness. Where the measured operation costs less than that, the reported
figure tracks the harness rather than the operation, and a small change in
harness cost swings it past CodSpeed's 10% flag threshold with the
measured code untouched. Per-iteration instruction counts (callgrind, the
same instrument class as CodSpeed Simulation) confirm the flagged
benchmarks are exactly the overhead-dominated ones:
true_count_vortex_buffer 1024: 187 Ir (78% harness) <- flagged
2048: 228 Ir (64% harness) <- flagged
16384: 802 Ir (18% harness)
65536: 2770 Ir (5% harness)
The fit is linear at ~0.04 Ir/bit with a ~146 Ir intercept, and no report
ever flagged 16384 or 65536. This also explains why #8861 did not settle
it: dropping 128 (97% harness) just promoted 1024 to worst offender.
- true_count: keep 16384 and 65536, where the popcount dominates.
- slice: BitBuffer::slice only adjusts an offset, a length and a refcount,
so its cost is independent of length -- every size measured exactly 125
Ir, which is why #8749 reported identical values for [1024] and [16384].
Measure one length with enough slices per iteration to dominate, varying
the offset so they cannot be folded together. No black_box is needed:
the slice clones an Arc, and that refcount traffic is a side effect the
optimiser cannot remove.
- binary_search: one search over 65536 elements is ~16 comparisons, and at
~71% harness the two implementations measured 203 vs 206 Ir --
indistinguishable, defeating the comparison the benchmark exists for.
Searching 64 targets per iteration separates them: 15133 Ir for vortex
against 10010 for std.
varbinview_compact was left alone: compact[(4096, 90)] is 1069 Ir, only
14% harness, so its reports belong to the comparison-base problem fixed in
the preceding commit rather than to harness overhead.
Signed-off-by: Claude <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015ypCZPxvLuJK9FgWKF8U4P1 parent 3a7c64b commit aa146bf
2 files changed
Lines changed: 62 additions & 30 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
18 | 23 | | |
19 | 24 | | |
20 | | - | |
| 25 | + | |
21 | 26 | | |
22 | | - | |
23 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
24 | 35 | | |
25 | 36 | | |
26 | 37 | | |
27 | 38 | | |
28 | | - | |
| 39 | + | |
29 | 40 | | |
30 | | - | |
31 | | - | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
32 | 52 | | |
33 | 53 | | |
34 | | - | |
| 54 | + | |
35 | 55 | | |
36 | 56 | | |
37 | 57 | | |
38 | 58 | | |
39 | 59 | | |
40 | | - | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
41 | 63 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
165 | 172 | | |
166 | 173 | | |
167 | 174 | | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
177 | 188 | | |
178 | 189 | | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
183 | 193 | | |
184 | 194 | | |
185 | 195 | | |
| |||
0 commit comments