Repository navigation
dia: diaPASEF 27 -> 21 min at 48 CPUs (50 -> 47 at 16), byte-identical; parallel search merge, PIN parsing, RT refit, line search - #581
Merged
Conversation
|
ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing |
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 9 minutes. View limit details
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. |
…ities The chunk cache of fragment-intensity predictions built its key with peptide.to_string() on every lookup (about 115 M lookups on a diaPASEF run) and turned the cached raw values into intensities (one exp per ion) on every hit. It now hashes the peptidoform in place, compares it with Peptide equality (residues, residue masses, modifications, flanks: a superset of the text the key used) and stores the intensities, shared by Arc. The peptidoform is cloned only on a miss.
After the charge searches of a chargeless chunk, each spectrum's merged queue is trimmed and its strong scores recalibrated leave-one-out over the spectrum's pool, O(kept x pool) per spectrum. The loop ran on one thread for 20,000 spectra per chunk; it now runs per spectrum on the thread pool (each spectrum's result depends only on its own queue and pool).
The keep-10-per-scan step sorted 75 M PIN rows by (scan group, re-rank score) with a stable sort on one thread, and looked the scan groups up in a SipHash map. The sort is now par_sort_unstable_by with the row index as the last key (the order the stable sort gives, ties included) and the group map uses FxHash (group ids still number the groups in first-appearance order).
Nomination walked the 75 M pool rows on one thread to keep, per (peptidoform, charge, run), the first row of the highest pool LLR. The rows are now ranked by a parallel sort on (key, LLR descending, row index) and the first row of each key is kept: the same rows. With a NaN LLR (where the walk's result depends on the order) the walk stays.
…pose The co-elution columns built two maps over the kept 9.5 M PIN rows and the re-rank looked up each of 75 M rows' run name in SipHash maps on one thread; they use FxHash now (only lookups and in-order pushes, no iteration order leaks out). The co-elution feature columns are transposed one column per task.
The RT refit trained its three cross-fitted regression GBDTs one after the other and predicted the 9.5 M PIN rows on one thread. The folds now train on the thread pool together, each row is predicted by its fold's model in parallel, and the median sort runs in parallel (an f64 sort by total_cmp gives the same sequence stable or not).
The precursor PIN reads the 9.5 M pass-1 rows into a map of the best row per (FileName, Peptide, charge); the map is only looked up and updated in row order, so FxHash replaces SipHash without changing the result.
On a chargeless DIA chunk each spectrum is searched at every charge in separate charge searches; their units' PSMs were moved into the spectra's merged queues on one thread, 14 % of a chunk's time at 46 threads (1.65 s of 12 s per chunk). When the units of a charge search belong to distinct spectra (the usual case: one spectrum's charges have precursor masses further apart than a chunk spans) each spectrum is now filled on the thread pool, in the same order as before; otherwise the units are merged one by one as before.
Every DIA pass that reads the 75 M-row PIN (predict, pool scores, co-elution, RT refit, precursor q) looked up each row's peptide in SipHash maps on one thread; at 48 threads the predict step ran 80 s on about 3 cores before its RT predictions and 33 s on one core before its MS2 predictions. The rows' known/new peptide test and their form ids are now looked up on the thread pool, and only the new peptides are walked in order (form ids keep their first-appearance numbering). The MS2 (peptidoform, charge) pairs are found the same way (eligibility in parallel, numbering in row order), the row-to-pair map is parallel, and the maps (spectrum bases, forms, pairs, anchors, folds) use FxHash; none is iterated in an order that reaches the output.
…rallel The kept-feature completion copies each batch's peptides (2,048 spectra, about 90 k peptides) out of the candidate store under its lock on one thread, 3 % of a chunk's time at 46 threads. The copy now runs on the thread pool while the lock is held; nothing else takes that lock while a chunk completes its kept features (the chunk's scoring has finished and chunks are scored one at a time), so the parallel copy cannot wait on it.
The class-wise FDR and the cutoffs classify every rescored PSM (5 M targets and their decoys on a diaPASEF run) by its proteins' entry kinds on one thread, several times after rescoring. The classification now runs in parallel over the rows in the map's iteration order (rows keep their indices), and the pooled decoy scores sort in parallel (an f64 sort by total_cmp gives the same sequence).
Reading the pass-1 PIN for the precursor PIN allocated each row's (FileName, Peptide, charge) key and looked up its SpecId in a SipHash map on one thread (18 s on about 3 cores at 48 threads). The keys are now built in the parallel parse and the nominee map uses FxHash; the best row per key is still chosen in row order.
The block reader of the DIA passes validated each 64 MB block as UTF-8 and split it into lines on the consumer thread, then handed the lines to the parallel parse. The 75 M-row pass-1 PIN is about 60 GB of text and is read by several passes (predict, pool scores, nomination, re-rank, co-elution), so this serial step cost tens of seconds per run. A block is now cut after newlines into 64 pieces that are checked and split on the thread pool and concatenated in order: the same lines.
In each SVM fit the line search walked the training rows on one thread to sum the two slopes and collect the breakpoints; at 48 threads it was a third of the fit time on the diaPASEF pass-1 PIN (39 of 119 s summed over the fits; gram 43 s, screened passes 27 s). The rows' slope terms and breakpoints are now computed per chunk of rows in parallel, then added and concatenated in row order: the same sums (same additions in the same order) and the same breakpoint list before the stable sort.
The AVX2 tree walk evaluates rows in steps of 32 (four 8-lane groups), padding a batch's row count up to a multiple of 32 with copies of its last row. The rich-ion and fragment-intensity models are evaluated per PSM on tens of ion rows, so the padding was a large share of the walk. The rows are now padded to a multiple of 8: full 32-row steps as before, then single 8-lane groups for the rest. Each row's value is still the sum of its leaves over the trees in tree order, so the outputs are the same.
A tree node's histograms are built in tasks of 4 features. The DIA learned score trains on about 45 features in 3 folds at once, so a node gave about 11 tasks per fold and the 48-thread runs used about 20 cores for its rounds. A task now takes fewer features (down to 1) when the blocks of 4 would not give every thread one. Each bin still adds its rows in row order, so the histograms are the same.
Protein inference turned each rescored PSM (5 M targets, and the decoys) into its peptide's protein families on one thread, then ran the target and decoy parsimony one after the other. The families are now found per PSM on the thread pool and merged per peptide in a map (the best score and the union of families do not depend on the merge order), the rows sort in parallel (their peptides are distinct), and the target and decoy sides run together.
The learned score of the precursor PIN (three cross-fitted GBDT rounds) was started with pass-1 rescoring and its later rounds outlasted pass 1, so it set the end of rescoring. It depends only on the pass-2 table and the seed, so it now starts on its own thread right after pass 2, beside the per-scan cut and the co-elution columns, and rescoring joins it after pass 1 (the table moves into the thread and back). Same score; the memory it holds (about 5 GB) now overlaps those steps, which hold less than the search did.
ypriverol
force-pushed
the
perf/diapasef-fast2
branch
from
November 25, 2026 19:32
f153004 to
9b0d056
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A second round of diaPASEF speed-ups, after #571. Steps that ran on one core now run in parallel. Outputs are byte-identical.
On PXD062685 Condition A Sample Alpha 01, with native rescoring, each A/B pair ran on disjoint halves of the same node:
a78fefbc…at 14, 16 and 46 threads, on main and on this branch. The PB-Astral slice digest (63e679ec…) is unchanged at 8 and 14 threads.Changes
to_string(), and caches the final intensities.Tried and dropped
rayon::join) was slower at 16 and 48 CPUs.At 16 CPUs the run is now CPU-bound: index voting, the fragment GBDT, the MS2 predictor and the learned-score GBDT.