Repository navigation
ProSE: no thread lending on OpenMP runtimes with a process-global thread count (MSVC vcomp) - #10815
Conversation
…/iterations/tron_epsilon/warm_start/single_cneg Conflict resolution (newton and cvalgo both extend the Percolator training options): - ProSEAlgorithm: cvalgo's PercolatorTraining struct carries the solver as well (new member `solver`, from 'rescore_solver'); rescoreWithPercolator_ takes the struct only (newton's separate `solver` argument and the rescore_solver_ member are folded into it). Parameters unchanged: rescore_solver (newton) and rescoring:* (cvalgo). - Percolator::train/rescore: setSolver and setTrainingOptions both called. - CrossValidation::trainCpCnPair: the start weights are the pair's previous weights for Newton/LDA (newton) or for TRON with warm_start and no nested CV (cvalgo); 0 otherwise (default TRON: unchanged). With both options set, tron_epsilon is the tolerance of the last step (Newton's earlier steps keep 1e-4), as pOptions.epsilon is shared. - UPSTREAM.md: both descriptions; patches 13-16, 19 regenerated in application order; chain check passes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…o int12: -Search:rescore_method reset Conflict resolution: - Percolator parameters/members: newton's 'solver' and RESET's 'algorithm'/'reset:*' both kept. - ProSEAlgorithm: rescoreWithPercolator_ takes both the training options (PercolatorTraining, incl. the solver) and RESET's extra Percolator parameters (Param); parameters rescore_solver, rescoring:*, rescore_method, reset:* all kept; the run's search parameters record Percolator:solver (non-default) and the RESET values. - RESET on nopin's dense rows: Percolator::rescoreReset_ moves RescoreInput::feature_matrix into the new PercolatorReset::Input::feature_matrix (no per-row copy: the reset branch read the int10 per-row vectors, which buildPSMRescoreInput no longer fills); PercolatorReset::run reads every row through Input::row() (rowCount()/row() as RescoreInput), the row-vector layout still works (tests, library callers); malformed dense input is rejected. New test: dense and row layouts give identical RESET output (SVM and MLP) and the dense checks. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…|joint|static|own (default per_file) Conflict resolution (reuse was written against int10's stamping rescorePSMs): - Percolator: nopin's const buildPSMRescoreInput (dense feature matrix, no stamping) and rescorePSMs are kept; reuse's stamping implementation (PinMetaValueCleanup, buildRowsOfStampedHits, non-const buildPSMRescoreInput) is not taken. reuse's scorer API is added on top: rescorePSMs(..., score_type, const PSMScorer& scorer, bool best_hit_only = false); the conv/nopin signature rescorePSMs(..., score_type, best_hit_only) calls it with an empty scorer. A scorer replaces rescore() (and RESET); its row count is checked against ri.rowCount() (taken before RESET moves the matrix). Percolator::score() keeps reuse's no-terminate shift and parallel region (auto-merged). - ProSE rescore_reuse code reads nopin's dense rows: training rows appended to dense RescoreInput matrices, calibration decoys and the shift sample copied per row, the shift check and the cross-fitted scores read ri.row(r) (reuseRawScore takes a row pointer). - ProSE parameters: reuse's rescoringPercolatorParameters() now also applies the training options (rescoring:*, rescore_solver) and the RESET parameters; rescoreWithPercolator_ takes (training, extra, reuse). The reused models are Percolator models trained with the training options; with rescore_method 'reset' a reuse mode other than per_file is ignored with a warning (every file is rescored by RESET). Best-hit-only write-back (conv) also with a reuse scorer. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…record The merge of the RESET and rescore_reuse records in rescoreWithPercolator_ lost the brace that closes the RESET block (6a31f0b did not compile). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rom the whole run The training draw of rescore_reuse (a seeded hash-uniform value per spectrum) is ProSEAlgorithm::reuseTrainingDraw() (same expression as before, so the same spectra). New test: at several sampling fractions and two seeds the drawn spectra are spread over the whole run (each tenth of it about its share, the sample reaches its end), seeded and reproducible, other seeds/files draw other spectra, calibration spectra are never drawn (user rule on capped training, REPL_BRIEF.md). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…m from all rows New PercolatorSampler_test (links OpenMS_Percolator): sampleTrainingRowIndices (Percolator subset_max_train, ProSE rescoring:subset_max_train) keeps about max_train rows spread over the whole input (each tenth of the rows about a tenth of the sample, up to its end: not a prefix), the PSMs of a spectrum together, seeded and reproducible; no cap keeps all rows. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
… (review round 1, Codex MAJOR) The newton merge left trainSvm() zeroing the weights before every TRON solve, so the start weights that cvalgo's warm_start puts into trainCpCnPair were discarded (warm and cold runs identical). Now only the Newton/LDA fallback to TRON starts from 0; with the TRON solver the weights are used as given (0 unless warm_start: the default training is unchanged). Patches 16 and 19 regenerated (the fix belongs to the solver dispatch of patch 16); chain check OK. New Percolator_test section (failing before the fix: warm == cold at a loose tolerance): warm starts change the result at tron_epsilon 0.3, repeat runs are identical, the default is cold. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ration and training draws disjoint - Percolator: the scorer entry point is rescorePSMsWithScorer() (Codex r1 MINOR: as an overload of rescorePSMs(), a function pointer passed as scorer converted to the bool best_hit_only of the other overload and was ignored). - ProSE rescore_reuse: the calibration draw is ProSEAlgorithm::reuseCalibrationDraw() (same expression as before); the spread test now checks that calibration and training draws are disjoint at every fraction, cover every spectrum at fractions 1, and that the calibration spectra (~5 %) are spread over the run (coordinator request). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…out (review round 2, Kimi MINOR 1) Comment and docstring only (no code change; bundle int12-c2 stays representative). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…_fold) With subset_max_train capping the training set, the in-sample mode (upstream --subset-max-train, still the default of the Percolator class) runs the cross-validation on the sample and scores every row with the average of the three fold models, so a sampled row is scored by two models that trained on it. subset_mode out_of_fold: every spectrum (spectrum file, scan: Percolator's own fold key) is assigned to one of the three folds first and a seeded random sample of whole spectra (at most subset_max_train rows) is drawn from the entire input (InProcessSampler: drawOutOfFoldSample, a hash of seed and spectrum: independent of row order and threads). The cross-validation keeps these folds (patch 20-cv-fixed-folds: CrossValidation::setFixedFolds -> Scores::createXvalSetsBySpectrum), so each fold's model trains only on the sampled spectra of the other folds (positive selection, Cpos/Cneg choice and initial direction inside that training set). Every row, sampled or not, is scored by its own fold's model only, and the folds are merged as the cross-validation merges its test folds (per-fold q-values and rescaling), then TDC, q-values and PEPs as before. The cap is global (one sample, as upstream). A sample without targets or decoys in some fold falls back to training on all rows. Without a cap, or in_sample, nothing changes. getSvmWeights() returns the three fold models after such a rescore; getCappedTrainingInfo() records folds, sample and the training rows of each fold model. Tests: no row scored by a model that trained on it (and every row by its fold's model), whole-spectrum sample spread over the whole input, determinism by seed and thread count, fallback, in_sample unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
With rescoring:subset_max_train > 0, Percolator trains out-of-fold on the capped sample by default (every PSM scored by the fold model that never saw its spectrum); in_sample keeps the percolator executable's scheme. Recorded as Percolator:subset_mode in the search parameters only when a cap is set, so the default output (no cap) is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
-out_pin passed the enzyme's name (e.g. Trypsin/P, or the default Trypsin) to PercolatorInfile::store(), which knows only lower-case Percolator names and treats any other name as "every site is enzymatic". Every row therefore had enzN = enzC = 1 and enzInt = peptide length - 1. It now passes the name Percolator knows, as the rescoring does: the helper that maps the names (an anonymous function next to ProSEAlgorithm::rescoreWithPercolator()) is now the public static ProSEAlgorithm::pinEnzymeName(), used by both. The new TOPP test fails without the fix (enzInt 13/27/22 instead of 0/1/1). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…odel (review round 1); mode out_of_fold_avg Review round 1 (Codex capfix-r1 BLOCKER/MAJOR, Kimi capfix-r1 MAJOR/MINOR): - Sanity check: Percolator's validateDirection counts the targets of all test folds (the held-out folds) and resets all models at once. Out-of-fold, each fold's model is checked against its default direction on its own training set and replaced alone (RecordingSanityCheck::validateFolds_). - The fold models are taken as checked, before CrossValidation's merge rescales them by their test sets (held-out labels). - Cneg candidates: each fold's from its own training set's target/decoy ratio (the sample's ratio counts the held-out labels); mergeCpCnPairs' nested path looks them up per fold (patch 20). - Nested cross-validation: each fold draws its nested sets from a generator state of its own per step; the shared stream let other folds' draws (whose training sets hold this fold's PSMs) change a fold's nested sets (patch 20). - The scorers are merged at train_fdr (the CV's selection FDR), as the CV merges its test folds; the scoring loop honours num_threads. - Warning without scan numbers (every row its own spectrum); sampler documented as a random-priority prefix within a row budget. - ProSE records Percolator:subset_mode only for the out-of-fold modes, so in_sample with a cap stays byte-identical to before. New subset_mode out_of_fold_avg (coordinator): sampled rows by their fold's model only; rows of unsampled spectra, which no model has seen, by the average of the fold models (as in_sample scores them). Every row is scored out-of-sample, and the targets and decoys of a spectrum share their scorer (a spectrum is sampled or not as a whole). The four scorers are merged as the folds (rescaled per scorer). Tests: relabelling targets of fold-0 spectra as decoys leaves fold 0's model unchanged (sampled spectra; the other models change) and every model unchanged (unsampled spectra), with default, nested_xval_bins 3, warm starts, Newton and LDA (failed before the Cneg and nested-seed fixes); out_of_fold_avg scorers per row, per spectrum, unseen by their scorer, scores affine in their scorer; fallback with a two-spectrum sample. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…minus is an enzymatic site) The PIN columns enzN/enzC compare the flanking residues of the first evidence with the enzyme's rule. OpenMS marks a protein terminus as '[' / ']'; Percolator writes '-' and counts it as an enzymatic site, but the mapping to '-' happened after the features: a peptide at a protein N-terminus got enzN = 0, one at a C-terminus not after a cleavage residue enzC = 0 (stamping, the in-process feature matrix and .pin files alike). The fix of 97dd260f48 (claude/percolatorinfile-terminus-enzyme-b-5edf-20261022), ported to pinHitColumns_ and kept behind a switch because it changes the default output: an enzyme name with the suffix "+termini" (e.g. "trypsinp+termini") maps the terminus marks first. Without the suffix the features are unchanged. Test (failing first: all six checks of the new section fail with the modifier ignored, oracle/build/failfirst.out): SAMPLE at both termini, at the N- or C-terminus only, and at neither, stamped and in the feature matrix, with and without the modifier. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… spectrum as positive candidate With train_best_positive (ProSE's rescoring, PercolatorAdapter -train_best_positive), Percolator's Scores::generatePositiveTrainingSet sorts the training set by spectrum and label with an unstable sort and keeps the first PSM of each group: not the best-scoring one in general. With 10 hits per spectrum most kept targets are weaker hits above the training FDR, and most positives are missing in the first iterations (Velos file of the 20-file benchmark, fold positives in iteration 1: percolator executable 296/373/438, this tree 130/153/162, best-scoring PSMs 642/734/867; exec/perf/oracle.md). New Percolator parameter best_positive: 'first' (default, Percolator's choice, unchanged results) or 'score' (CrossValidation::setBestPositiveByScore: stable sorts by score and then by spectrum and label; generateTrainingSetsOfSortedSet keeps the first PSM of each group of a set sorted by score). Vendored change as patches/20-best-positive-by-score.patch (UPSTREAM.md); chain check OK. Test PercolatorBestPositive_test (failing first with the option ignored: line 122, both paths): 40 spectra x 10 target hits, both the fallback and the sorted-set path keep one positive per spectrum, the best-scoring one with 'score'. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…yme_termini (default off) Search:rescoring:best_positive first|score (Percolator best_positive), rescoring:use_pi0 true|false (Percolator use_pi0; the percolator executable with -Y uses pi0 = 1) and rescoring:fixed_enzyme_termini false|true (enzyme name with PercolatorInfile's "+termini", for the rescoring and -out_pin). Defaults keep the output byte-identical. Effect on the 20-file benchmark (5 Percolator seeds, driver on ProSE's own feature matrix, exec/perf/oracle.md): best_positive score +1.22 % PSMs, doubled-DB FDP 1.099 -> 1.039 %; with use_pi0 false +1.03 %, 1.015 %. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…after a per-fold reset, small remainder, no-OpenMP build) - Codex r2 MAJOR: when the per-fold sanity check replaces a fold's model, its test set is scored with the replacement before the CV merge, which rescales each model by its test set before getAvgWeights averages them (the average scorer of out_of_fold_avg). The saved fold models do not depend on it. - Codex r2 MINOR: out_of_fold_avg uses the average scorer only if the unsampled rows hold at least 100 targets and 100 decoys (its rescaling at train_fdr), else they stay with their folds' models. - No-OpenMP gate (clang -fopenmp-simd parses num_threads()): score_threads is declared without OpenMP too. - Docs: sampler inclusion probability (Codex NIT), per-fold sanity comment (Kimi NIT-2); test: relabelling unsampled spectra changes none of the four out_of_fold_avg models (Kimi NIT-4). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ning_curve) User request: choose the training size by a learning curve. Spectra get their folds as in out_of_fold; validation spectra (the end of the random order, at most subset_curve_validation = 250,000 rows and 20 % of the rows) are set aside and never trained on. Nested whole-spectrum samples of subset_curve_start (100,000), twice, four times ... as many rows, up to subset_max_train (if > 0, else subset_curve_max = 4,000,000; or all rows but the validation spectra), are each trained out-of-fold (all isolation fixes). Fold k's measure: targets at q <= train_fdr ((decoys + 1) / targets) among the validation spectra of the OTHER folds under fold k's model, so no fold-k label decides fold k's size or model. Fold k stops at the first doubling that adds less than subset_curve_min_gain (0.2 %) and keeps that model. Every row is scored by its fold's chosen model, merged as out_of_fold. ProSE: rescoring:subset_mode learning_curve, rescoring:curve_start, rescoring:curve_min_gain; the curve is recorded as Percolator:subset_curve. Default output unchanged. Refactor: rescore()'s training block is a local function (train_rows), called once as before or once per curve size. Tests: stop rule (first size below the threshold; later sizes not evaluated for a stopped fold; a threshold of 10 stops all folds at the second size), determinism by seed and threads, relabelling targets of fold-0 spectra anywhere (samples, validation) leaves fold 0's curve, size and model unchanged while the other folds' curves change; sampler: validation spectra fixed across caps, disjoint from and nested samples, whole spectra. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ess (Linux) When a process ends, the kernel releases its address space before the waiting parent is told: for a search that leaves 0.5-1 GB of (mostly free malloc) memory this is 40-80 ms after the last output, on one core (astral_B1 t16: 67 ms of 2.38 s; hfx_B1 t64: 50 ms of 1.13 s). After the tool has returned its exit code, main() starts a helper process that shares the address space (CLONE_VM, no SIGCHLD to this process, untraced) and blocks on a pipe whose write end only this process holds. The process then ends exactly as before (destructors, stdio flush, exit code); since the kernel drops the address space of an ending process before closing its files, the helper sees the end of the pipe when this process no longer uses the memory, ends, and the memory is released with it, after the parent of ProSE has seen the exit. The helper uses raw system calls only (it shares the memory but not the thread state, e.g. errno), blocks all signals and closes every inherited file (close_range, or close in a loop) so that no reader of the output waits for it. Not used: other systems and architectures than Linux x86_64/aarch64, sanitizer builds, Valgrind (LD_PRELOAD vgpreload; it does not run such processes); if pipe() or clone() fail, the process ends as before. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…view findings The helper process of 5a5274c131 is a change of behaviour that the user decides on: it now runs only with the environment variable OPENMS_FAST_EXIT=1 (default off), documented in the tool page with the reasons (a sandbox that forbids creating processes, an init process that does not reap adopted children, a job system that waits for all processes of a job). Codex review round 1: - 9: both pipes are created with O_CLOEXEC, so no program started later holds the write end; - 10: all signals are blocked by the parent around clone() (restored afterwards), so the helper never runs a signal handler of the tool; the raw rt_sigprocmask (and its x32 size issue) is gone, x32 (__ILP32__) is excluded; - 8: the helper closes its copy of the write end explicitly and ends at once (leaving the memory to the tool, as before) if close_range is not available, instead of a bounded close loop; - 11: the tool waits (at most 0.1 s) until the helper holds no file of the tool but the pipe (end of file on a second pipe), so a reader of the output sees its end with the tool's; - 13: not used under a debugger or tracer (TracerPid), nor in Clang sanitizer builds (__has_feature). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…patch 21) The initial direction of every fold sorts the PSMs by each of the 30 features and counts the positives in both directions. Each count took a new snapshot of the n sorted keys, a new vector of n (score, label) pairs and a q-value vector that grew by doubling (about 7 blocks of up to 8n bytes per count). On HeLa 25pc_50_25 (2.3 M PSMs, 64 threads) these were ~16 GB of fresh blocks in 2.2 s, 2.1 M page faults (mcount/gdb, exec/perf/memalloc.md). The counts now take their buffers from lists of the call and put them back when done (released at the end of the call), and countPositivesOfPairs reserves the q-values at once. The counts and so the direction are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…writable at once) glibc grows the heap of a thread's arena by the pages an allocation lacks, one mprotect() at a time, and each mprotect() holds the address-space lock for writing, which stalls the page faults of all other threads. The preprocessing of the spectra keeps several GB of peak lists allocated in small blocks by all threads: on HeLa 25pc_50_25 at 64 threads 1.2 million mprotect() calls, 76 % system time, the phase slower at 64 than at 16 threads. With M_TOP_PAD = 64 MiB a new heap is made writable in one call when glibc creates it (new_heap adds the pad). Indicative (ibminode05, = ibminode06 hardware; the same setting as GLIBC_TUNABLES=glibc.malloc.top_pad=67108864): HeLa 25pc_50_25 t64 preprocessing 2.65 -> 0.69 s, whole run 29.56 -> 27.84 s, peak RSS 15.43 -> 15.17 GiB; astral_B1 t64 1.43 -> 1.36 s, hfx_B1 t16 1.23 -> 1.15 s. Not applied if GLIBC_TUNABLES sets glibc.malloc.* or with OPENMS_MALLOC_DEFAULTS=0. Output unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…arge ones The BT4 matrices of the TRON solves (X and the two active-row buffers of a workspace) take hundreds of MB on a large data set (HeLa 25pc_50_25: 1.5 M training rows x 32 columns per fold), are zero-filled when a workspace grows, written once per solve and read in every iteration. On HeLa at 64 threads the CV training took 3.0 M page faults; with glibc.malloc.hugetlb=1 (huge pages for all large blocks) 0.49 M and the training 10.44 -> 9.32 s (ibminode05, indicative). AlignedDoubles now allocates without writing, advises MADV_HUGEPAGE for the 2 MiB pages inside the block (Linux; a hint, followed in the kernel's "always" and "madvise" THP modes), then zero-fills as before. Values unchanged; Percolator_test and PercolatorTron_test pass. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ion buffers adviseHugePages (ssl.h, from the TRON workspace commit) is now shared. The dense feature matrix of the rescoring (PercolatorInfile::buildFeatureMatrix: rows x features doubles, 0.56 GB on HeLa 25pc_50_25) is reserved, advised and then zero-filled; in Scores::getInitDirection (patch 21, regenerated) the feature columns, the key snapshots and the pair buffers are advised. With THP in "madvise" mode these get huge pages: fewer page faults when they are filled and fewer TLB misses when they are read. Values unchanged; Percolator_test, PercolatorTron_test and PercolatorInfile_test pass; patch chain check OK. Patch 21 notes the duplicate 20s of parallel branches. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…n parallel, median and MAD by selection summarizeTopHits() merged a std::set<std::string> of sequences and one of accessions per thread range on one thread and freed them afterwards (0.4 s for the 250,000 top hits of a timsTOF run). The ranges now note their sequence strings in one buffer and their accessions by pointer, in buckets by hash; the buckets are counted (sort + unique) one per thread and the buffers freed in parallel. The error lists are reserved once. Median and MAD of the error lists by std::nth_element: the same order statistics as the sort of Math::median() (which is used for lists with a NaN or a negative zero, where the result could depend on the algorithm). HeLa 25pc_50_25 (kim, indicative): run statistics 618 -> 112 ms at 64 threads, 576 -> 111 ms at 16. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…er comparison MSExperiment::sortSpectra() read the retention times of two spectra (752 bytes apart) per comparison of its index sort; it now reads them into an array first and compares those, with the same comparisons as SpectrumType::RTLess (so the same order, NaN included). ProSE skips sortSpectra(false) after a chunked read if the spectra are already in retention time order (no NaN; equal times keep their order in the sort as well). HeLa 25pc_50_25 (kim, indicative; its spectra are not in retention time order): 164-219 -> 107 ms. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…a in parallel; ProSE reader joins with the waiting threads The ranges of the spectra themselves (a pass over every peak) are updated in parallel for 4,096 spectra or more outside a parallel region, then added to the range managers in spectrum order as before. If the update of a spectrum throws, the state is that of the serial loop: the spectra before it added, the ranges of the later ones restored, the exception rethrown. In ProSE the reader thread of a chunked mzML read runs it with the threads of the thread that waits for the spectra as well (ChunkHelp::joinThreads(): that thread does nothing else until it has them). HeLa 25pc_50_25 (kim, indicative; 107 M peaks): join 429 -> 41 ms at 64 threads, 348 -> 51 ms at 16. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…d in parallel keepPeptidesInPrecursorWindows_() made the windows of all spectra and sorted them on one thread (0.12 s for the 250,000 spectra of a timsTOF run). Each thread now makes those of a contiguous range of the spectra (the first NaN bound or error in spectrum order decides as before), joined in spectrum order, sorted by boost block_indirect_sort (pairs of floats without NaN: equal ones differ at most in the sign of a zero, which none of the comparisons after tells apart). HeLa 25pc_50_25 (kim, indicative): 125 -> 36 ms at 64 threads. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Walking the hits of every identification is bound by the memory latency (0.13-0.19 s for the 250,000 identifications of a timsTOF run before each idXML store). Ranges of the identifications are walked in parallel and the definitions of each run joined (a union of sets: the same whatever the ranges); the set of a run is looked up once per identification and only for a definition. HeLa 25pc_50_25 (kim, indicative): 188 -> 4 ms at 64 threads. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ion; Da-mode windows) into claude/prose-mz-recalibration-20261103 Co-Authored-By: Claude Opus 5.5 <[email protected]> # Conflicts: # src/openms/include/OpenMS/ANALYSIS/ID/ProSEAlgorithm.h # src/openms/source/ANALYSIS/ID/ProSEAlgorithm.cpp # src/tests/class_tests/openms/source/ProSEAlgorithm_test.cpp # src/topp/ProSE.cpp
…ion; Da-mode windows) into claude/prose-speed-rounds-20261103 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-mz-recalibration-20261103 #10804 was squash-merged, so this branch's history and develop carried the same change twice and every file both touched conflicted. Resolution: this branch's version of ProSEAlgorithm.h/.cpp and ProSEAlgorithm_test.cpp (develop changed them only through the squash); develop's version of src/tests/topp/CMakeLists.txt and ProSE.cpp (changed by other merges as well) with this PR's own diff applied on top. The diff against develop is the PR's diff as before, hunk headers aside. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…e squash of #10804) into claude/prose-speed-rounds-20261103 No conflicts; the diff against #10805's branch is this PR's diff as before. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…uash of #10804) into claude/prose-omp-global-count-20261104 No conflicts; the diff against #10806's branch is this PR's diff as before. Co-Authored-By: Claude Fable 5.1 <[email protected]>
timosachsenberg
left a comment
There was a problem hiding this comment.
AI-generated initial review
This is an automated, AI-generated first review. It looks only for high- and medium-priority issues (no nits) and checks whether the PR has tests and measurements. Please double-check anything before acting on it; a maintainer will follow up. I reviewed 2a457010 against its base, the head of #10806 (1819b502).
What I ran:
- Code reading: the diff, plus the thread lending code around it:
BackgroundSpectra,BackgroundConsumer, the hit and spectra release helpers,XMLFile'sOpenMPThreadReservation_, and the consumer inProSE.cpp. - Probe check: I compiled a standalone copy of
ompThreadCountIsGlobal()with GCC 13.3 / libgomp (_OPENMP201511). It reportsfalseand leaves the caller's number as it was. - CI: green on all six build-and-test jobs on this head, including
windows-2025, cl.exe. Windows CI builds with MSVC/openmp:experimental(cmake/multithreading.cmake:70), which is vcomp. So the new probe test checks the global behaviour on the affected runtime. - Not run: I have no Windows/vcomp machine. Linux is unaffected by construction. A full OpenMS build on this 4-core runner would take hours and would only exercise the per-thread path, so I did not repeat any measurements.
Verdict:
- High priority: none.
- Medium priority: three issues:
- the QPX PSM table build in the consumer still sizes its team with
omp_get_max_threads(); - no test covers the bug itself;
- the probe sits in
ProSEAlgorithm, soXMLFile's reservation cannot use it and still races on vcomp.
- the QPX PSM table build in the consumer still sizes its team with
- Linux/macOS output and threading: unchanged. Every new branch is guarded by the probe, and on a helper the new override equals the per-thread number that is set right after it.
Medium priority
1. The QPX PSM table build in the consumer ignores the consumer's share on vcomp
- Where:
buildQPXRunFiles_()(ProSE.cpp:756) callsQPXFile::exportPSMsToQPXArrow(). That function sizes its team itself:threads = omp_get_max_threads(),W = min(threads, PSMs / 2048)(QPXFile.cpp:1592). - On vcomp: on the consumer helper,
omp_get_max_threads()is the process's number. After the lend that isthreads - 2, e.g. 10 at-threads 12. With-out_qpxand several inputs on Windows, the PSM table of each file is then built with up to 10 threads next to the search's 10. On Linux it is built with the helper's 2. - Description: it says the QPX export sizes its team by the new number. In fact only the
threadspassed toqpxScanFormat(),concatenateAndWriteToParquet()and the stream append use it. - Mitigation: read
SysInfo::ompThreadsOfThisThread()atQPXFile.cpp:1592, which keeps today's value on per-thread runtimes, or passthreadsthrough. One-out_qpxrun on the Windows box would confirm it; the measurements cover idXML output only.
2. No test catches the original bug
- What the new tests cover: the probe,
SysInfo's per-thread number, andIdXMLFile::store()with 2 threads. - What they miss: nothing checks the actual regression, which is that a multi-file search leaves the caller's OpenMP number shrunk. Windows CI runs on vcomp, so such a test would guard the fix where it matters.
- Suggestion: extend the existing
setFileResultConsumersection (ProSEAlgorithm_test.cpp:6357), e.g.:ScopedOpenMPThreads scoped(4); const int before = omp_get_max_threads(); std::atomic<int> consumer_threads{0}; // in the consumer: consumer_threads = SysInfo::ompThreadsOfThisThread(); auto mfres = algo.searchWithModificationAnalysis(files, database_file); TEST_EQUAL(omp_get_max_threads(), before) // stock code on vcomp: the reader's quarter stays TEST_TRUE(consumer_threads >= 1 && consumer_threads <= before)
- Caveat: I expect the first check to fail on the stock code under vcomp, but I could not run it on Windows.
3. The probe lives in ProSEAlgorithm, and XMLFile's reservation still races on vcomp
- The remaining setter:
OpenMPThreadReservation_(XMLFile.cpp:193-212) still callsomp_set_num_threads()and restores the value it read. The description lists it under "Not changed". However, it is held for the whole parse of a streamed file (XMLFile.cpp:574), not only for a moment. - The race on vcomp: on the reader helper, the reservation reads and restores the process's number. Its save and restore can interleave with the main thread's consumer lend and restore (
ProSEAlgorithm.cpp:8397,:8420). Example with-threads 24on 24 logical CPUs:- The reservation saves 24 and sets 23.
- The main thread lends to the consumer: it reads 23 and sets 21.
- The read ends and the reservation restores 24, so the lend is undone while the consumer still runs.
- The consumer finishes and the main thread restores 23. The rest of the run uses 23 of 24 threads.
- Scope: this is an edge case (
-threads≥ logical CPUs, streamed input on the non-chunked path) with a small effect. It is the same kind of bug as the one fixed here. - Mitigation: move the probe to
SysInfo, next toompThreadsOfThisThread()(e.g.SysInfo::ompThreadCountIsGlobal()), and make the reservation a no-op where it returns true. That also avoids a publicProSEAlgorithmstatic for what is a property of the runtime.
Checked and found sound
- Per-thread runtimes (libgomp, libomp):
readBorrowsThreads(), the reader body and the helpers keep their old calls.- On the consumer helper,
setOmpThreadsOfThisThread(helper_threads)equals theomp_set_num_threads(helper_threads)that follows it, soIdXMLFile::store()and the QPX share are unchanged. - On the main thread, the override falls back to
omp_get_max_threads().
- Probe:
- The function-local static makes initialisation thread-safe.
- In practice the first call happens on the main thread, in
readBorrowsThreads()fromBackgroundSpectra::start()andBackgroundConsumer::start(), before any helper is started.
- Other helpers that set the number: the release helpers for dropped hits and spectra (
ProSEAlgorithm.cpp:7499,:9411) also callomp_set_num_threads()on helper threads. Both are compiled out on Windows (release_laterisconstexpr false;#if !defined(OPENMS_WINDOWSPLATFORM)), so vcomp never reaches them. - Consumer on vcomp: only the main thread changes the process's number (it lowers it while the helper runs and restores it in
finish()). The helper never writes it. - ID writers:
IdXMLFileis the only one with OpenMP regions, so switching it to the override is enough for the idXML consumer.
Tests
- Good:
- The probe test asserts what the runtime actually does, and Windows CI runs it on vcomp.
- The
SysInfotests cover the per-thread override and its reset. - The
IdXMLFiletest checks that the output is byte-identical with 2 threads.
- Gap: no end-to-end check of the regression (issue 2).
Measurements
- Good: real data (HeLa, 3 files, 520,267 MS2 spectra) on Windows/vcomp against Linux/libgomp at 8, 12 and 16 threads, with wall and CPU time.
- Output is identical to stock and across thread counts (487,461 top hits, 89,547 PSMs at 1 % FDR).
- The single-region
num_threads(12)diagnostic supports the root cause.
- Caveat:
- The description itself notes that the stock and first-commit runs at 8 and 12 threads had a foreign load of 16–51 %, so the second commit's gain there is partly that load. The clean 16-thread pair (60 s → 51 s) is the reliable figure.
- Missing: a
-out_qpxmulti-file run on Windows (issue 1).
Generated by Claude Code
…e observed m/z Review follow-ups of #10805: - Fragment annotations: with calibration:recalibrate, postProcessHits_() and annotateFragmentPeaks_() read the peaks that applyRecalibration_() corrected in place. They now undo the fragment model (MzRecalibration_::uncorrect(), exact for offset, to 1e-13 Da for a line), so a PSM's precursor m/z and its annotations are both as observed, and the run summary's tolerance estimate has observed errors on both sides (the residuals stay in the calibration:*_residual_* records). The model is passed in explicitly, because the multi-file path keeps one calibration result per file. - Co-isolated precursors of a chimeric search come from the same survey scans as the selected one: applyRecalibration_() now corrects their m/z (CoIsolationDetector::META_MZ) by the precursor model too and keeps the observed ones (observed_coisolated_mz), which their PSMs report. Their precursor-error feature is then a residual like that of chimeric_rank 1. - Tool page: drop the leftover sentence that called recalibrate "off"; state the linear and none modes, the 5 ppm / 0.01 Da floor with the correction, and that the reported errors are of the observed m/z. - search(PeakMap&) docs: the spectra come back with corrected m/z. - Tests: uncorrect() round trips; annotations match the observed peaks and the PSM m/z equals the observed one (exact checks, where TEST_REAL_SIMILAR's 1e-5 ratio would pass a 5-7 ppm shift); applyRecalibration_() on co-isolated precursors; TOPP_ProSE_4_recalibrate runs the tool's default end to end. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0149aXmbmJRoyZgSEgVjDKbn
…onditionally The fixture yields a PSM for each of its 12 spectra, enough for the tolerance estimate (10): assert at least 10 PSMs and both estimates, instead of skipping the median checks without them (CodeRabbit nitpick on #10805). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0149aXmbmJRoyZgSEgVjDKbn
The fixture yields fewer than the 10 PSMs the run summary's tolerance estimate needs (cd470f2 failed there on Linux arm). Collect the statistics of the PSMs repeated ten times instead: the medians are the same, and the check of the observed errors on both sides no longer depends on the fixture's yield. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0149aXmbmJRoyZgSEgVjDKbn
…rsors) into the speed rounds Conflicts in MzRecalibration_ and applyRecalibration_(): kept both sides, uncorrect() next to AtRT/at(), and the co-isolated precursor keys next to the per-spectrum AtRT model for the fragment peaks. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0149aXmY7heshmULGihPVydG
… rounds Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0149aXmY7heshmULGihPVydG
|
[Edit: retracted. The earlier review (5 Nov, on 2a45701) raised three medium-priority points that are still open on this head, and I had missed them.]
I'm working on fixes for these on this branch and will post an updated verdict when they are in and CI is green. Benefit, for reference: on Windows, ProSE at Generated by Claude Code |
ProSEAlgorithm.{h,cpp} on develop equal #10805's branch head, which this
branch already contains, so the conflicts resolve to this branch's version.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0149aXmY7heshmULGihPVydG
…n, QPX team size, regression test) - SysInfo::ompThreadCountIsGlobal() replaces ProSEAlgorithm's: it is a property of the OpenMP runtime, and XMLFile needs it too. Its test moves to SysInfo_test. - XMLFile's OpenMPThreadReservation_ is a no-op where the number is global: held for a whole streamed parse on the reader helper, its save/restore could undo the main thread's consumer lend on vcomp. - QPXFile::exportPSMsToQPXArrow() sizes its team by SysInfo::ompThreadsOfThisThread(), so the consumer helper's share holds on vcomp too (same value as before on per-thread runtimes). - ProSEAlgorithm_test: the multi-file search with a file result consumer checks that the caller's OpenMP number is unchanged afterwards and that the consumer saw at most that many threads (the regression itself; Windows CI runs vcomp). Review of 5 Nov on #10815. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0149aXmY7heshmULGihPVydG
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0149aXmY7heshmULGihPVydG
|
I pushed ee6a1fb, which addresses the three medium-priority points of the 5 Nov review. Points are numbered as in the review. No verdict yet:
Generated by Claude Code |
|
Verdict: ready to merge, after #10806.
Generated by Claude Code |
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0149aXmY7heshmULGihPVydG
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0149aXmY7heshmULGihPVydG
Targets develop. It was stacked on #10806, which is now merged, and develop is merged in as c8b4de3, so the diff shows only this change.
What
On MSVC's OpenMP runtime (vcomp, OpenMP 2.0)
omp_set_num_threads()by any thread sets the number of threads for the whole process; libgomp, LLVM's libomp and MSVC's/openmp:llvmkeep one number per thread. ProSE's background reader set its quarter of the threads from its helper thread, nothing set the number back on the branch the usual runs take, and every later thread decision read the shrunken number. On Windows a search of three HeLa files (520,267 MS2 spectra) with-threads 12on a 12-core box ran on 3 threads: 128 s instead of about 45 s. Linux and macOS were not affected.SysInfo::ompThreadCountIsGlobal(): probed once, on the main thread (a thread sets another number, the caller checks its own and sets it back); used by ProSE andXMLFile.omp_set_num_threads()(the regions of the read take their threads from their clauses, the rest of the read runs with the process's number), and the reader body's set-and-restore is skipped.SysInfo::setOmpThreadsOfThisThread(), a thread-local override ofomp_get_max_threads(), whichIdXMLFile::store()and the QPX export (includingQPXFile::exportPSMsToQPXArrow()) size their teams by. On the first commit alone the consumer ran on the main thread on vcomp, where the search of the next file waited 3 s per file for the write (measured in the phase comparison at 12 threads: 0.3 s per file on Linux, 3.3 s on Windows).-debug 1.XMLFile's thread reservation (the non-chunked read path) is skipped where the number is process-global, so it can no longer undo the consumer's lend on vcomp.SysInfo_test);SysInfo's number is per thread and resets;IdXMLFile::store()writes the same file with 2 threads set; a multi-file search with result consumers underScopedOpenMPThreads(4)leaves the caller'somp_get_max_threads()unchanged and gives each consumer between 1 and 4 threads (ProSEAlgorithm_test). All pass in CI on the six jobs, Windows (vcomp) included.Measured
Flash workstation (Ryzen 9 7900X, 12 cores / 24 logical CPUs, Windows 11, MSVC 14.44 + vcomp, vcpkg static deps), HeLa 3 files (520,267 MS2 spectra), the 28 Oct protocol, affinity to the physical cores for 8 and 12 threads; the stock numbers are the best of four runs, the first commit's the best of two on a box carrying another user's load of 16–51 % before the 8- and 12-thread runs and 1–3 % before the 16-thread ones, both commits' the best of two on an idle box (0–11 % before each run). Linux for comparison: ibminode06 (EPYC 7763, libgomp), pinned to physical cores; note that Flash has 12 cores, so its 16 threads use four SMT siblings while the EPYC's 16 are physical cores.
With the first commit the search phase runs at Linux's per-thread speed (16 threads: 6.0 / 5.9 / 5.6 s per file against 6.3 / 5.9 / 5.8 s on the EPYC; the search phase of the three files took 36 / 25 / 17.6 s at 8 / 12 / 16 threads, the stock build 72 s at 12), and the whole run was 1.65× behind Linux at 16 threads. The second commit takes the idXML write off the main thread again (the helper writes with 2 threads while the next file is searched): 9 s less per run on the clean 16-thread pair (60 → 51 s), which is the 3 s per file the phase comparison had measured for the inline write; the 8- and 12-thread pairs gained 16 and 13 s, part of which is the earlier runs' foreign load. CPU time fell by about 70 s at 16 threads (676 → 603 s): the inline write had run a 16-thread team at 8 cores busy for 3 s per file, with 480 k page faults per file. At 8 and 12 threads, where both machines run on physical cores, Windows is now within 5 % of Linux's wall time; at 16 threads it stays 1.4× behind (SMT siblings on the 12-core box, Percolator's OpenMP-2.0 path on MSVC, 1.75× behind libomp, #10772, and the page faults of the Windows heap). The idXML outputs are identical to the stock build's (487,461 top hits with identical scores, 89,547 PSMs at 1 % FDR) and between thread counts. The diagnostic that found the cause,
num_threads(12)on the scoring region alone, had taken the search phase from 72 s to 24 s. The analysis with the thread-state samples and the runtime probe:output/scaling-2026-11-04/windows-options-2026-11-04.mdof the ProSE project (not in the repository).Not changed
XMLFile's thread reservation (non-chunked read path) still sets the number when the given threads reach the logical CPUs, as before.CI
While stacked, the build-and-test workflow was dispatched by hand. First commit b517ce9: https://github.com/OpenMS/OpenMS/actions/runs/41858554522 (green on all six jobs). Second commit a7e9f3a: https://github.com/OpenMS/OpenMS/actions/runs/41910568142 (green on all six jobs). After the develop merge of #10806's branch (5 Nov), 2a45701: https://github.com/OpenMS/OpenMS/actions/runs/41994546768, green on all six jobs. Review fixes (6 Nov: the probe moved to
SysInfo, theXMLFilereservation, the QPX PSM table, the regression test) ee6a1fb: https://github.com/OpenMS/OpenMS/actions/runs/42210789066, green on all six jobs. The develop merge c8b4de3 leaves the tree unchanged; the PR's own CI runs on it.🤖 Generated with Claude Code