Repository navigation
[FIX] PeptideAndProteinQuant: O(1) sample-ID lookup (fixes IsobaricWorkflow "Quantifying peptides" hang) - #9672
Conversation
…rkflow "Quantifying peptides" hang) The "Quantifying peptides" step scaled ~quadratically with experiment size. getSampleIDFromFilenameAndChannel_() linearly scanned the experimental-design MS file section and recomputed File::stemName() (a heap-allocating string op) for every scanned row, and it was called inside the per-peptide x fraction x file x charge x channel aggregation loops (plus a per-(file,charge) x label PSM-count loop). For a large isobaric run (e.g. 600 files x 18 channels = 10,800 MS-file-section rows) this becomes billions of allocating string comparisons on a single thread -> hours of wall time at ~5% CPU (one pegged core on a many-core box). Fix: - Precompute a map<(stemName, label) -> sample> once per readQuantData(); getSampleIDFromFilenameAndChannel_() now does a single map::find. emplace keeps the first occurrence, matching the previous "return first match" semantics. Cache is cleared in updateMembers_(). - Hoist getNumberOfLabels() (itself an O(ms_section) max_element) out of the loop conditions in quantifyPeptides() and annotateQuantificationsToProteins(). Behavior is unchanged: the PeptideAndProteinQuant unit test and all TOPP_ProteinQuantifier, TOPP_IsobaricWorkflow and TOPP_ProteomicsLFQ integration tests pass with identical reference output. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Warning Review limit reached
More reviews will be available in 18 minutes and 25 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 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 |
Self-reviewRead through the final diff line by line. The change is tight and well-scoped (2 files, +61/−26); semantics are preserved and verified by the unit test plus 101 passing TOPP reference-output tests. A few notes for reviewers, none blocking: Verified correct
Nits (non-blocking, intentionally left as-is)
Approach and result look correct to me. Ready for CI / a second pair of eyes. |
Documents four PRs that landed on 2026-06-26 after the last CHANGELOG update (#9667): - #9668: fix platform-dependent float formatting in scientific notation - #9669: feat(PIPECHO) cap SVM training-set size (max_training_points) - #9670: fix SimpleSVM constant-predictor crashes in predict()/setup() - #9672: perf PeptideAndProteinQuant O(1) sample-ID lookup (fixes IsobaricWorkflow hang) GitHub Actions version bump (#9673) carries no CHANGELOG entry per the PR author's own checklist. Claude-Session: https://claude.ai/code/session_01JxivySW6RCM1tKbU8H6bfj Co-authored-by: Claude <[email protected]>
Problem
IsobaricWorkflow(andProteinQuantifier/ProteomicsLFQ) can hang for hours at theQuantifying peptides...step, with CPU usage sitting around ~5% — which looks like a deadlock but is actually one core pegged at 100% on a many-core machine (the code path is single-threaded).Root cause
PeptideAndProteinQuant::getSampleIDFromFilenameAndChannel_()performed a linear scan over the experimental-design MS file section and recomputedFile::stemName(entry.path)(a heap-allocating string operation) for every scanned row:It is called from the bottom of the 5-deep peptide aggregation loops (
peptide × fraction × file × charge × channel) and a separate per-(file,charge)× label PSM-count loop. For a large isobaric experiment — e.g. 600 files × 18 channels → 10,800 MS-file-section rows — the step degenerates to roughlyO(#observations × #channels × #ms_section_rows)with two heap allocations per inner step. That is on the order of 10¹¹ allocating string comparisons, i.e. hours of single-threaded wall time.Additionally, the loop condition re-evaluated
experimental_design_.getNumberOfLabels()every iteration, and that helper itself does anO(ms_section)std::max_element.Fix
std::map<std::pair<std::string, UInt>, size_t>mapping(stemName(path), label) → sample, built once perreadQuantData().getSampleIDFromFilenameAndChannel_()now does a singlemap::find.emplacekeeps the first occurrence of a(stem, label)pair, preserving the old "return first match" semantics. The cache is cleared inupdateMembers_().getNumberOfLabels()into aconstbefore the loops inquantifyPeptides()andannotateQuantificationsToProteins().This takes the lookups from
O(ms_section)-with-allocations down toO(log ms_section), turning the "Quantifying peptides" step from hours → seconds on large isobaric data. The number of lookups is unchanged, so results are bit-for-bit identical.Correctness / behavior
No behavioral change. The mapping is built from the same
getMSFileSection()in the same order, with identical first-match semantics and the identicalException::MissingInformationon a miss. The consensus path already validated(basename, label)uniqueness upstream.Testing
PeptideAndProteinQuant_test✅TOPP_ProteinQuantifier,TOPP_IsobaricWorkflow,TOPP_ProteomicsLFQ— 101/101 pass with identical reference output ✅readQuantDatabefore any consumer) verified across all three TOPP drivers and the unit test.🤖 Generated with Claude Code