Commit 2c8d19f
pre-size the pagoda parallel filter instead of growing via push
A profile with symbols/frame-pointers preserved and LTO disabled
(RUSTFLAGS="-C target-cpu=native -C force-frame-pointers=yes",
CARGO_PROFILE_RELEASE_{STRIP,DEBUG,LTO} overridden for the build - the
committed profile strips symbols and enables thin LTO, both of which
make perf traces hard to trust: stripped binaries collapse everything
into one opaque module frame, and LTO's cross-crate inlining can
misattribute samples to the wrong function) showed finish_grow as a
real, avoidable cost in the two par::parallel(...).filter(...).collect()
calls added for pagoda pruning: each chunk's output Vec grew via
repeated reallocation as matches were found, instead of being sized
once up front - the same category of fix already applied in
board.rs's possible_moves/possible_reverse_moves and keyset.rs's
extraction.
Added par::par_filter, a parallel filter that counts matches per
chunk first (cheap now that pagoda() is O(1)) and allocates each
chunk's buffer at its exact final size. Re-profiled the same way
after the fix: finish_grow no longer appears in the profile at all.
Wall-clock effect (hyperfine, native-cpu build, 50 runs): pagoda
pruning is now genuinely neutral rather than a net loss (mean ratio
1.00 +/- 0.03 vs the pre-pagoda commit) - correctness-preserving and
essentially free, even though it doesn't deliver a net win on this
implementation's current bottleneck (see the previous commit).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>1 parent f4f7fc4 commit 2c8d19f
2 files changed
Lines changed: 25 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
281 | 281 | | |
282 | 282 | | |
283 | 283 | | |
284 | | - | |
285 | | - | |
| 284 | + | |
| 285 | + | |
286 | 286 | | |
287 | 287 | | |
288 | 288 | | |
| |||
347 | 347 | | |
348 | 348 | | |
349 | 349 | | |
350 | | - | |
351 | | - | |
| 350 | + | |
| 351 | + | |
352 | 352 | | |
353 | 353 | | |
354 | 354 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
99 | 120 | | |
100 | 121 | | |
101 | 122 | | |
| |||
0 commit comments