Repository navigation
perf(FragmentIndex): shrink bucket size to 4096 for tighter candidate lists - #9203
Conversation
… lists The previous sqrt(N) heuristic produces very coarse buckets on large immunopeptidomics indices (e.g. bucket_size 22k for a 490M-fragment non-specific human index). Each query peak then scans thousands of fragments far outside its tolerance window. Hard-coding bucket_size to 4096 approximates MSFragger's fixed ~0.02 Da fragment-bin density in the dense 500-1500 Da region, so a bucket now covers roughly one fragment-tolerance window instead of a wide sqrt(N) span. Benchmark on DN17_Liver_classI_techRep2 (SNES, 45M mothers, unspecific cleavage, 7 ppm / 20 ppm, 8 threads): - wall: 91 min -> 80.6 min (-11%) - CPU: 603 min -> 523 min (-13%) - PSMs: 28235 -> 28235 (identical) - peak RSS unchanged Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
📝 WalkthroughWalkthroughThe fragment bucket size calculation in Changes
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/openms/source/ANALYSIS/ID/FragmentIndex.cpp (1)
1260-1265: Consider extracting the bucket size as a named constant.The value
4096is used both here and implicitly assumed by all downstream bucket-walking code paths (query,querySpectrumSNES_, and the test helperfragmentsSorted()). Promoting it to a namedconstexpr(e.g.static constexpr size_t DEFAULT_BUCKET_SIZE = 4096;in the header, alongside the rationale comment) would make the tuning knob discoverable and grep-able, and let the test file reference the same symbol instead of re-deriving expectations from the raw literal.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/openms/source/ANALYSIS/ID/FragmentIndex.cpp` around lines 1260 - 1265, Extract the magic literal 4096 into a named constexpr (e.g. static constexpr size_t DEFAULT_BUCKET_SIZE = 4096) declared in the class header near the other member declarations and the rationale comment, then replace the literal use in FragmentIndex.cpp (assignment to bucketsize_) with that symbol (bucketsize_ = DEFAULT_BUCKET_SIZE) and update all downstream uses/tests that assume 4096 (functions query, querySpectrumSNES_ and the test helper fragmentsSorted()) to reference the same constexpr so the tuning value is discoverable and consistent across production and tests.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/openms/source/ANALYSIS/ID/FragmentIndex.cpp`:
- Around line 1260-1265: Extract the magic literal 4096 into a named constexpr
(e.g. static constexpr size_t DEFAULT_BUCKET_SIZE = 4096) declared in the class
header near the other member declarations and the rationale comment, then
replace the literal use in FragmentIndex.cpp (assignment to bucketsize_) with
that symbol (bucketsize_ = DEFAULT_BUCKET_SIZE) and update all downstream
uses/tests that assume 4096 (functions query, querySpectrumSNES_ and the test
helper fragmentsSorted()) to reference the same constexpr so the tuning value is
discoverable and consistent across production and tests.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 117b7b60-5c90-443f-a5e2-bf90b11a8b48
📒 Files selected for processing (1)
src/openms/source/ANALYSIS/ID/FragmentIndex.cpp
Restore ProSE/FragmentIndex/File entries dropped by the FeatureFinderCentroided reorganization commit (#9159) and add new entries for commits merged after the last sync: - #9188: ProSE BREAKING: default isotope error range changed to [0,+2] - #9191: ProSE SNES mother-peptide indexing for non-specific searches - #9195: ProSE fix: defer PSM FDR when Percolator enabled; valid .pin output - #9203: FragmentIndex: fixed bucket_size 4096 for tighter candidate lists - #9204: ProSE: resolve PercolatorAdapter via findSiblingTOPPExecutable - #9205: ProSE: per-file output isolation + dangling decoy ref crash fix - #9207: File::rename: cross-device fallback (copy+remove on EXDEV) Co-authored-by: GitHub Copilot <[email protected]> Co-authored-by: Copilot <[email protected]>
Summary
bucketsize_ = sqrt(fi_fragments_.size())with a fixedbucketsize_ = 4096inFragmentIndex::build().bucket_size 22232for a 490M-fragment human SNES index — so each query peak scans thousands of fragments far outside its tolerance window.Benchmark
DN17_Liver_classI_techRep2.mzML, SNES enabled, unspecific cleavage, human SwissProt, 7 ppm precursor / 20 ppm fragment, 8 threads, 45,089,468 SNES mothers:Matched-spectra count is bit-identical to the prior run — bucketing only affects how candidates are traversed, not which ones match.
Notes
bucket_min_mz_memory shrinks slightly (N/4096 floats ≈ 1 MB at N=1B, vs. sqrt(N) ≈ 4 MB).fi_fragments_.size() < 4096) the build loop produces a single bucket spanning the whole index; correctness is preserved (the bucket-walk loop degrades to a plain linear scan).bucket_min_mz_vector with a fixed-width m/z bin-offset table would remove the remaininglower_boundgate and tighten candidate lists further — out of scope for this PR.Test plan
FragmentIndex_testand ProSE tests🤖 Generated with Claude Code
Summary by CodeRabbit