Repository navigation
search: cache out-of-core expansions per base record instead of per window (#72) - #73
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: Advanced Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe search candidate pipeline now separates base-record retrieval from peptidoform expansion. Mmap searches cache expansions by base-record identity, preserve record multiplicity, and filter expanded candidates against exact nominal windows. ChangesCandidate expansion
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~25 minutes Merge Risk: ⚪ Minimal · up to The caching refactor preserves candidate output while improving runtime, with no actionable merge-blocking risk identified. Sequence Diagram(s)sequenceDiagram
participant Spectrum
participant MmapCandidateIndex
participant MmapRecordCache
participant expand_base_record
Spectrum->>MmapCandidateIndex: request base records for nominal windows
MmapCandidateIndex-->>Spectrum: return records and multiplicities
Spectrum->>MmapRecordCache: look up BaseRecordKey
MmapRecordCache-->>Spectrum: return cached expansion or miss
Spectrum->>expand_base_record: expand uncached base record
expand_base_record-->>Spectrum: return peptidoforms
Spectrum->>Spectrum: filter, replicate, sort, and relabel candidates
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 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 |
|
Full 5,000-spectrum chunk of the phospho search (16 threads,
About 17x on a whole chunk; the larger cache budget buys nothing here, so the default stays. Whole-file projection ≈ 2.3 h at 16 threads instead of ~40 h. |
… MaxQuant reference table (#75) * benchmarks: phospho tier — dataset, mods, MaxQuant reader, reference table First PTM-enriched benchmark. PXD007653 (Krahmer/Mann mouse liver EasyPhos, Q Exactive, single-shot TiO2, label-free), one file: 20151014_QEp6_NaKr_SA_totalliver_control2_phospho.raw, 3.72 GB. Verified against the shipped model store's source ledger — it is NOT training data, unlike the obvious pick PXD014525, which trained hcd_qexactive_tryp_phosphorylation. make_truth.py gains a maxquant reader over msms.txt: decoys dropped (Reverse), PEP <= 0.01, one row per (run, scan), filtered to the run actually searched. It keeps MaxQuant's modified sequence in a seventh column so localisation can be compared later; emit() widens the header only when a reader supplies it, so the glyco tables keep their six columns byte-for-byte. The committed table holds 23,563 spectra, 17,072 of them phospho-bearing. The depositors searched UP000000589, the same mouse proteome the 1:1 shuffled entrapment database is built from, so the comparison is like-for-like apart from isoforms. Numbers follow once the run lands; nothing is claimed here. * benchmarks: mods file takes one residue per line; NumMods=4 The Phospho line specified STY as a single residue spec, which the parser rejects (it takes one residue or `*`), so both arms failed at startup. Split into three lines. NumMods raised 3 -> 4 because 0.2% of the reference peptides carry four variable mods and none carry more than four that we need; at 3 those would be unreachable by construction. * benchmarks: commit the MaxQuant phospho reference table (PXD007653, one file) * benchmarks: first PTM-enriched benchmark — PXD007653 phospho, one file, both arms Default model 36,817–36,922 PSMs @1% (true FDP 1.22–1.32%), --protocol phospho 36,780–36,884 (1.10–1.14%), ~26.7k phospho-bearing PSMs; 82.1% of the MaxQuant reference scans covered with 98.3% bare-peptide agreement. Binary d606d962 (main + #71 + #73 + #74), provenance and recipe recorded. Site localisation is not scored and is listed as the open gap.
…72) On a PTM-rich search the out-of-core path spent ~95% of CPU generating peptidoforms: every spectrum re-expanded the base peptides of its windows, and consecutive windows overlap heavily. The per-chunk cache is now keyed by base record: the distinct records of every window in the chunk are fetched once (index scans), expanded once in parallel under the same candidate budget, and each spectrum assembles its list from them. The assembly reproduces the in-RAM multiset and order: records are deduplicated at the record level (a record's copies share one mass, so a window holds all or none of them), the RAM nominal-bucket predicate is applied per peptidoform against the union of the spectrum's windows, the multiplicity comes from the copy count in the index scan instead of a per-candidate index query, and the pass-tagged stable sort is unchanged. lazy_candidates_for_nominal_window is now a composition of the two new functions and keeps its contract.
cea86dd to
bfb76fe
Compare
Stacked on #71 (base branch
fix/precursor-cal-honours-mmap); addresses #72.Problem
On a PTM-rich out-of-core search (PXD007653 phospho: Phospho S/T/Y + Ox-M + Acetyl, NumMods=4, mouse 1:1 entrapment DB) a native profile showed ~95% of CPU in peptidoform generation:
expand_recursive56%, the per-window expansion wrapper 23%, malloc/free 14%; scoring below 1.5%. Every spectrum re-expanded the base peptides of its windows, and consecutive windows overlap heavily, so the same base peptide was rebuilt for almost every spectrum that reached it. The per-chunk window cache from #67 could not help: it caches whole windows, and its 4M-candidate budget covers only ~80 phospho windows per 5,000-spectrum chunk.Change
The per-chunk cache is keyed by base record instead of by window:
base_records_for_nominal_windowfetches a window's base records (index range scans, cheap) with each record's copy count — the RAM enumeration multiplicity — taken from the scan instead of a per-candidate index query.expand_base_recordexpands one record into all its peptidoforms, no window filter.lazy_candidates_for_nominal_windowis now a composition of the two new functions and keeps its contract; the in-crate tests that pin it to the RAM enumeration still pass.Evidence
expand_recursive+ 3% terminal variants; the scoring closure is now 25%cargo test --workspaceFull 5,000-spectrum chunk timing at the default and a 16M budget is running on the cluster against the 7,100 s baseline; I will post it here.
What remains after this is the expansion itself (recursive clone per form); that is the next lever in #72.
Summary by CodeRabbit