perf(fast): full-scale round — index sets, changed-only registry, in-place apply, shared word deltas#57
Merged
Merged
Conversation
…red word deltas Profiled on the entire wikitext-2 train split (23.8k docs, 500 merges). Five kept changes, each digest-verified in isolation: - Inverted-index values Vec<u32> -> FxHashSet<u32>: removal was a linear scan of up to ~23k doc ids per affected doc per step. - The per-step registry scan emits only words that actually merge; staying in the registry is the known-unchanged signal (kills a serial ~74k-entry map rebuild per step). - apply_premerge rewrite: changed-only map, scan-first without cloning untouched docs, in-place slot writes via Arc::make_mut (SuperBPE replay 4.65s -> 1.58s). - try_apply_incremental writes (position, replacement) in place instead of rebuilding each affected doc's children Vec (~2.4M Arc clones/step early). - Each changed word's candidate delta list is computed once per step and docs combine the pre-built lists weighted by occurrence count (delta emission 17.1s -> 8.3s thread-summed). Full scale, cold, best of 3: Boundless 10.90s -> 5.64s (1.9x), SuperBPE 8.36s -> 5.05s (1.7x), BPE/BNE flat (bottlenecks untouched). Digests unchanged at full scale and at the 2000-row default config. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The full-scale profiling round (entire wikitext-2 train split: 23.8k docs / 10.9M chars, 500 merges), extracted from the on-hold #55 branch so it can merge independently — all five changes target machinery that's already on main (#54's registry/premerge/incremental paths). Cherry-picks cleanly; verified from scratch on this base.
Changes (each was digest-verified in isolation on the profiling branch)
Vec<u32>→FxHashSet<u32>— removal wasiter().position(), a linear scan of up to ~23k doc ids, paid per affected doc per step.apply_premergerewrite — changed-only map, scan-first without cloning untouched docs, in-place slot writes viaArc::make_mut(SuperBPE's 50-merge phase-1 replay 4.65s → 1.58s on the profiling branch).try_apply_incrementalcollects (position, replacement) and writes in place instead of rebuilding each affected doc's children Vec (~2.4M Arc clones/step early on), with boundary deltas read through a small position→replacement overlay.(candidate, ±1)list is computed once per step; docs combine the pre-built lists weighted by occurrence count. This was the sleeper: thread-summed profiling showed delta emission at 17.1s vs 4.5s for the scans everyone suspected.Results on this base (main + this PR; cold subprocess per case, 500 merges, full split)
2af4c7edca✓967201e51c✓10318b5e1c✓2a6baff51d✓(On top of #55's batch ingestion the same changes measure 1.9×/1.7× — the two PRs compound.) Default 2000-row benchmark digests all match the reference (
20d930a435/6598b73bb3/9999e69912×2). 141 tests + 2 skipped; clippy unchanged.Cumulative full-scale history: Boundless 179s → 7.7s on main (23×), → 5.6s with #55 (32×); SuperBPE 216s → 9.3s / 5.1s (23× / 43×).
Note: full-scale digest methodology is cold-process-per-case because of #56 (training mutates the global cluster cache — pre-existing, fix coming separately).
Tried and reverted this round: serial map build for changed-words (no measurable change vs rayon reduce).
🤖 Generated with Claude Code