Skip to content

search: fragment-ion index for out-of-core searches, on by default — Comet parity on phospho (169 s vs 226 s, +9.6% PSMs) (#76) - #77

Merged
ypriverol merged 11 commits into
perf/mod-handle-no-atomicfrom
feat/fragment-index
Sep 9, 2026
Merged

ypriverol merged 11 commits into
perf/mod-handle-no-atomicfrom
feat/fragment-index

Conversation

@ypriverol

@ypriverol ypriverol commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #74 (base perf/mod-handle-no-atomic). Workstream C for #76: the fragment-ion index, now on by default whenever a search goes out-of-core.

What it does

--fragment-index auto|on|off (default auto): when --candidate-index resolves to mmap (and neither --chimeric, --refine nor --glyco is active), spectra are sorted by precursor mass and scored in slices of ≤ 150 Da / ≤ 20,000 spectra. For each slice the peptidoforms inside its precursor window are enumerated once with a mass-bounded walk, their singly-charged b/y ions are binned at the fragment tolerance, and each spectrum's peaks vote for forms inside its own precursor windows. Forms with ≥ 3 matched ions, at most 100 (--fragment-index-top-k), are materialised and go through the unchanged scoring, feature and PIN path. Searches that fit in RAM are untouched; --fragment-index off reproduces enumeration byte for byte.

Result — PXD007653 phospho, full file, same 32-core node, production defaults, Percolator 3 seeds

engine wall (incl. pre-pass and I/O) PSMs @1% true FDP phospho PSMs MaxQuant scans covered RSS
andes, this PR (K=100) 169 s 37,258–37,280 1.15–1.16% 26,883 82.5% 25 GB
andes, K=50 178 s 37,161–37,191 1.16% 26,801 82.3% 25 GB
Comet 2025.01 226 s 33,888–34,025 1.73–1.78% 23,888 77.9% –
andes enumeration (#74) 5,954 s 36,817–36,922 1.22–1.32% 26,629 82.1% 11 GB

Comet parity on time, +9.6% PSMs and +12.4% phospho PSMs at a third less measured error. Search phase 123 s (~830 spectra/s).

What the measurements on the way taught (each in its commit)

  • The prepared search carries a hardcoded 0.5 Da fragment tolerance; the index takes the scorer's effective tolerance (with 0.5 Da every form matched dozens of peaks by chance).
  • ~88k–120k peptidoforms per Da on this search space: 1,000 high-mass spectra spanned 450 Da = 39.7M forms / 3.3G ion entries, so slices are bounded by mass span; only in-window forms may be indexed (a record reachable through one mod offset carries dozens of forms at other masses); the calibration pre-pass never uses the index (its sample spans all masses).
  • Building Peptide/Candidate objects per form was ~70% of the first index build; walking per-residue masses instead, and pruning the walk by mass bounds (variable mods only add mass), took the search from 1,167 s to 169 s. Mass-ordered form ids turn the per-bin sort into an integer sort.
  • The in-repo fixture is human spectra against E. coli (nine true PSMs): it exercises code paths, not identifications.

Gates

cargo test --workspace 1,111 passed; the four ignored RAM/mmap equivalence gates pass (they run with --fragment-index off, being about the enumeration paths); two in-crate tests pin that the index ranks the true peptide first on exact spectra and that the bounded walk's index selects the same form on build and materialisation.

Not yet

  • Multiplicity copies (PIN Proteins repeats) are not reproduced in index mode.
  • Slice width is fixed at 150 Da (25 GB peak on phospho); making it adaptive to the fix: cap the memory budget by the process's cgroup limit #68 memory budget is the next housekeeping item.
  • The standard sets run in RAM and are untouched; the index's effect if a user forces --candidate-index mmap on them is not measured.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@coderabbitai

coderabbitai Bot commented Sep 8, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

Warning

Review limit reached

Next included review available in 59 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 0d0a34bf-6871-4f7a-90e2-08137f9b2e98

📥 Commits

Reviewing files that changed from the base of the PR and between be6fdda and e59a7b3.

📒 Files selected for processing (14)
  • DOCS.md
  • crates/andes/src/bin/andes/cli.rs
  • crates/andes/src/bin/andes/search.rs
  • crates/andes/tests/mmap_ram_pin_equivalence.rs
  • crates/output/src/glyco_pin.rs
  • crates/output/src/pin.rs
  • crates/output/src/tsv.rs
  • crates/search/src/candidate_gen.rs
  • crates/search/src/fragment_index.rs
  • crates/search/src/lib.rs
  • crates/search/src/mass_calibrator.rs
  • crates/search/src/match_engine.rs
  • crates/search/src/search_params.rs
  • crates/search/tests/mmap_candidate_backing.rs
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/fragment-index

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ypriverol

Copy link
Copy Markdown
Contributor Author

Round 2 on the full file (same protocol):

arm wall PSMs @1% (3 seeds) true FDP phospho PSMs
K=50, min-matched 3 1,148 s 37,206–37,287 1.13–1.16% 26,924
K=100, min-matched 4 1,211 s 37,147–37,212 1.03–1.05% 26,864
K=100, min-matched 5 1,134 s 37,144–37,254 1.04–1.13% 26,810

K and the minimum match barely move identifications or time. The full-run profile explains why: ~70% of the index path was expanding peptidoforms into Peptide/Candidate objects (and freeing them), three passes per 15 Da chunk and again for every overlapping chunk; scoring was 3%. The last commit replaces that with an allocation-free walk over per-residue masses (same recursion, same form order and index) and widens slices to 150 Da so each record is expanded once per slice. Fixture output is unchanged; full-file timing on that build is queued.

@ypriverol

Copy link
Copy Markdown
Contributor Author

Pruned, mass-ordered index (commit e57a21f8), full phospho file, 32 threads, production defaults, Percolator 3 seeds:

arm wall search phase PSMs @1% true FDP phospho PSMs MaxQuant covered RSS
index K=100 169 s 123 s (834 spectra/s) 37,258–37,280 1.15–1.16% 26,883 82.5% 25 GB
index K=50 178 s 134 s 37,161–37,191 1.16% 26,801 82.3% 25 GB
Comet 2025.01 226 s 226 s 33,888–34,025 1.73–1.78% 23,888 77.9% –
enumeration (#74) 5,954 s – 36,817–36,922 1.22–1.32% 26,629 82.1% 11 GB

Comet parity on time is reached (andes is 25% faster wall-to-wall including the 24 s calibration pre-pass) with +9.6% PSMs and +12.4% phospho PSMs at a third less measured error. What did it: the mass-bounded walk visits only in-window forms (the previous build enumerated every form of every reachable record and discarded ~97% afterwards), and mass-ordered form ids turn the per-bin sort into an integer sort and the precursor window into an id range. Profile now: bounded walk 28%, GBDT 12%, scoring closure 9%, record scan 9%, sorts 12%. Remaining memory cost is the 150 Da slice (~1G ion entries); an adaptive slice width against the #68 budget is the next housekeeping item.

@ypriverol ypriverol changed the title search: per-chunk fragment-ion index for PTM-rich out-of-core searches — 5x faster than enumeration, more IDs (#76) search: fragment-ion index for out-of-core searches, on by default — Comet parity on phospho (169 s vs 226 s, +9.6% PSMs) (#76) Sep 9, 2026
@ypriverol

Copy link
Copy Markdown
Contributor Author

Production defaults, no index flags (commit 3a4a24a3): the memory budget picks mmap, auto turns the index on (top-k 100, min matched 3), and the full phospho file finishes in 164 s wall (PHASE TOTAL 162.8 s) with 37,258–37,280 PSMs @1%, FDP 1.15–1.16%, 26,883 phospho PSMs, 82.5% MaxQuant coverage — identical to the explicit K=100 run. Suite 1,111 passed; the four equivalence gates pass with --fragment-index off.

@ypriverol

Copy link
Copy Markdown
Contributor Author

VM head-to-head (8 threads, 31 GB, same mzML, Percolator seed 1), andes at 23530049 with the budget-derived slice width (77 Da here):

engine wall PSMs @1% true FDP phospho PSMs RSS
Comet 2025.01 1,126 s 33,946 1.74% 23,888 –
andes, mzML, production defaults 1,046 s 37,280 1.15% 26,883 15.6 GB
andes, native raw (no conversion) 876 s 37,234 1.12% 26,849 18.4 GB

Same PIN rows as the cluster run (912,747), so identical identifications; the enumeration path on this VM took 45,255 s. The raw→mzML conversion Comet needs costs another 577 s on this machine.

@ypriverol
ypriverol added this pull request to stack #81 September 9, 2026 19:08
…s, flag-gated (#76)

Milestones 1 and 2 of workstream C. With --fragment-index-top-k K the
chunk's peptidoforms are enumerated once, their singly-charged b/y ions
binned at twice the fragment tolerance, and each spectrum's peaks vote for
forms within its precursor windows; forms with at least
--fragment-index-min-matched votes (default 3), at most K, are
materialised and scored by the unchanged path. Off by default and
byte-identical when off. Judged on identifications and entrapment FDP.
A chunk in file order spans the whole precursor mass range, so its
per-chunk index was the whole database (100 GB on phospho). In
fragment-index mode the binary collects the stream, sorts spectra by
precursor mass, and scores mass-ordered chunks; each chunk's index then
covers a narrow mass range.
Its sample spans every precursor mass, so a per-chunk index over it is
the whole database.
…; 64-bit CSR offsets (#76)

A record reachable through one modification offset carries dozens of
forms at other masses; indexing them all put one mass-ordered chunk past
2^32 ion entries and overflowed the 32-bit bin offsets.
… mode, size logging (#76)

The build held every in-window form's ion list before packing, tens of
millions of forms on a phospho chunk. It now counts in one pass and
writes packed entries in a second, logs records/forms/entries per chunk,
and index-mode chunks are 1,000 spectra.
…l as count (#76)

1,000 high-mass phospho spectra spanned 450 Da; that window held 39.7M
peptidoforms and 3.3G ion entries.
… 150 Da index slices (#76)

A full-run profile put ~70% of the index path in expanding peptidoforms
into Peptide/Candidate objects and freeing them, three passes per 15 Da
chunk and again for every overlapping chunk. for_each_form_masses walks
the same recursion as expand_mod_combinations, in the same order with the
same k, but yields per-residue masses without allocating; the index build
computes masses and b/y ions from those. Slices are now 150 Da / 20,000
spectra, so each record is expanded once per slice.
…ent index (#76)

The lean build still walked every form of every reachable record and
discarded those outside the slice window afterwards (28% of the run),
and sorted ~1G ion entries per slice by an indirect mass lookup (22%).
Variable modifications only add mass, so the walk now prunes subtrees by
running sum plus the min/max of the remaining positions; the build and
materialisation share that walk, so the pruned index k selects the same
form on both sides. Form ids are assigned in ascending mass order, so a
bin sorted by id is sorted by mass and the per-bin sort is an integer
sort; the query narrows the precursor window to an id range.
…idate index is out-of-core (#76)

auto (default) turns the fragment-ion index on when --candidate-index
resolves to mmap and neither --chimeric, --refine nor --glyco is active;
searches that fit in RAM are untouched. on warns and falls back to
enumeration when the index is in RAM. The equivalence gates pass
--fragment-index off explicitly: they are about the enumeration paths
agreeing, and the index changes the candidate set by design.
Measured on the phospho space: a 150 Da slice peaks at ~25 GB RSS, about
0.13 GB per Da over a ~5 GB base. The width is now derived from the #68
budget (10-150 Da) so a 31 GB machine gets ~60 Da; --fragment-index-slice-da
overrides it.
- pruned form index widened from u16 to u32: a 50-residue peptide with
  ~30 modifiable sites and four slots exceeds 65,535 forms, and truncation
  would materialise the wrong form
- the per-record expansion cache is not built in index mode (materialise
  never reads it; ~3.5% of the run and up to 4M cached candidates)
- record_span / expand_base_record bounds-check the protein index
- the precursor-mass sort uses total_cmp
- the index test compares modification-aware peptidoforms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant