Repository navigation
perf: expand each out-of-core mass window once per chunk (~1.9x) - #67
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Team Run ID: 📥 CommitsReviewing files that changed from the base of the PR and between 1254cb7 and c46c116cec35ddfc3e10e89a4275df8fe01da113. 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe Mmap candidate path now matches RAM candidate multiplicity and ordering. It caches expanded nominal-mass windows per chunk. New ignored integration tests compare PIN output for default, fixed, and variable modifications. ChangesCandidate equivalence
Estimated code review effort: 4 (Complex) | ~45 minutes Merge Risk: ⚪ Minimal · up to Out-of-core candidate expansion is reused per nominal mass window within each chunk, reducing search time while retaining the existing direct-expansion fallback and equivalent candidate output behavior. Sequence Diagram(s)sequenceDiagram
participant run_chunk_inner
participant MmapWindowCache
participant expand_mmap_window_candidates
participant PIN_output
run_chunk_inner->>MmapWindowCache: lookup nominal-mass window
MmapWindowCache-->>run_chunk_inner: return cached candidates
run_chunk_inner->>expand_mmap_window_candidates: expand cache miss
expand_mmap_window_candidates-->>run_chunk_inner: return ordered candidates
run_chunk_inner->>PIN_output: write search results
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…r spectrum
The out-of-core candidate path was 3-15x slower than in-RAM, and the whole gap sat
inside the search loop: on the ecoli fixture `[PHASE stream_search]` was 30.9s
out-of-core against 8.0s in-RAM, with index load negligible.
The in-RAM path enumerates candidates ONCE for the run and each spectrum reads a
bucket range. The out-of-core path re-did the base-record fetch, mod expansion,
multiplicity replication, decoy relabel and sort for EVERY (spectrum, charge) unit.
Measured on that fixture: 49,066 search units cover only 1,657 distinct nominal
windows, a 29.6x mean reuse, and every unit shares its window with another. So ~97%
of that work was repeated.
Each chunk now collects the distinct windows of its units, expands each exactly once
(in parallel), and the scoring loop reads the prepared slice. The hot path takes no
lock and memory is bounded to one chunk's distinct windows, with a cap beyond which
expansion falls back to the direct path.
The window key is the nominal bounds only: the calibration shift is
`params.precursor_mass_shift_ppm`, a run-level constant, so it cannot vary between
units of a chunk and does not belong in the key.
stream_search, 3 runs each, same host/command:
no cache 30.58 / 30.12 / 32.03 s mean 30.9
cached 13.82 / 16.63 / 18.31 s mean 16.3 -> ~1.9x, ranges disjoint
in-RAM reference 8.0
Pure caching: the out-of-core PIN stays byte-identical to the in-RAM PIN in all three
modification configurations (default 77,097 rows; fixed-only 75,739; one variable mod
77,129), which is the equivalence PR #66 established.
c46c116 to
646436d
Compare
Rebased onto
mainnow that #66 has merged; this branch is a single commit on top of it.The out-of-core candidate path was 3–15× slower than in-RAM and the entire gap sat inside the search loop:
[PHASE stream_search]30.9 s out-of-core against 8.0 s in-RAM on the ecoli fixture, index load negligible.Cause, measured rather than assumed: the in-RAM path enumerates candidates once for the whole run and each spectrum reads a bucket range, while the out-of-core path re-did the base-record fetch, modification expansion, multiplicity replication, decoy relabel and sort for every (spectrum, charge) unit. On that fixture 49,066 search units cover only 1,657 distinct nominal windows — 29.6× mean reuse, every unit sharing its window with another — so about 97% of the work was repeated.
Each chunk now expands its distinct windows once, in parallel, and the scoring loop reads the prepared slice. The hot path takes no lock, memory is bounded to one chunk's distinct windows, and there is a cap beyond which expansion falls back to the direct path.
stream_search, 3 runsAbout 1.9×, ranges disjoint. I would quote it as "about" — the cached runs vary more than I would like.
Byte-identical output: the out-of-core PIN matches the in-RAM PIN in all three modification configurations (default 77,097 rows, fixed-only 75,739, one variable mod 77,129). Full suite 1,084 passed, clippy clean at
-D warnings, rustfmt clean.One assumption checked rather than trusted: the calibration shift is
params.precursor_mass_shift_ppm, a run-level constant, so it cannot vary between units of a chunk and correctly does not belong in the cache key.I also dropped an earlier branch of mine that memoised the multiplicity lookup: it was byte-identical but measured flat (30.0 s vs 30.2 s), because the redundancy was in repeating the whole expansion, not in the lookup inside it.
Summary by CodeRabbit
Bug Fixes
Tests