Repository navigation
Remove unneeded expensive copies (perf, parallel hot paths) - #9686
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (12)
✅ Files skipped from review due to trivial changes (3)
🚧 Files skipped from review as they are similar to previous changes (8)
📝 WalkthroughWalkthroughThis PR replaces several pass-by-value copies with const references and uses ChangesConst-ref and move semantics optimizations
Suggested Reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/openms/source/FORMAT/HANDLERS/MzMLSqliteHandler.cpp`:
- Around line 1111-1113: The raw-buffer compression path in MzMLSqliteHandler is
unsafe for empty vectors because it builds a std::string from
&data_to_encode[0], which is undefined when spectra or chromatogram buffers are
empty. Update the lossless branches in the affected encoding logic (including
the spectrum and chromatogram intensity/mz handling paths) to guard against
empty data before constructing the buffer string, and ensure empty inputs
produce an empty encoded payload without touching the raw pointer.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 1930ccd0-93cf-47c6-b592-7fb3db966e40
📒 Files selected for processing (12)
src/openms/include/OpenMS/ANALYSIS/XLMS/OPXLHelper.hsrc/openms/include/OpenMS/FORMAT/DATAACCESS/SwathFileConsumer.hsrc/openms/source/ANALYSIS/ID/ProSEAlgorithm.cppsrc/openms/source/ANALYSIS/ID/SimpleSearchEngineAlgorithm.cppsrc/openms/source/ANALYSIS/MAPMATCHING/PIPECHO/TransferFDRModel.cppsrc/openms/source/ANALYSIS/NUXL/NuXLAnnotateAndLocate.cppsrc/openms/source/ANALYSIS/NUXL/NuXLFDR.cppsrc/openms/source/ANALYSIS/XLMS/OPXLHelper.cppsrc/openms/source/FEATUREFINDER/MultiplexFilteringProfile.cppsrc/openms/source/FORMAT/HANDLERS/MzMLSqliteHandler.cppsrc/openms/source/FORMAT/HANDLERS/MzXMLHandler.cppsrc/openms/source/KERNEL/ConsensusMap.cpp
Eliminate avoidable heavy copies found by an audit of src/openms, with emphasis on OpenMP parallel regions and hot loops. Each change was verified not to be a deliberate thread-local snapshot: const& conversions only target already-thread-local objects or shared read-only input, and std::move targets are dead thread-local locals. - OPXLHelper: pass FASTA DB to digestDatabase by const& (was whole-DB copy); bind alpha/beta sequences as const& inside the OpenMP candidate loop. - MultiplexFilteringProfile: reference the per-peak satellites multimap instead of copying it inside the OpenMP loop. - MzMLSqliteHandler: std::move the block-local compressed payload strings into the per-index output vectors (8 sites, two OpenMP encoding loops). Also guard the lossless raw-buffer path against empty spectra/chromatograms (avoid UB from &data_to_encode[0] on an empty vector). - SwathFileConsumer: reference getPrecursors() instead of copying the vector per MS2 spectrum. - SimpleSearchEngineAlgorithm / ProSEAlgorithm: const& the reannotated AASequence; std::move PeptideHit/hit vector into setHits. - NuXLAnnotateAndLocate: std::move dead fragment-annotation vectors. - NuXLFDR: append to the mutable getHits() reference instead of copying the hit vector out and back. - MzXMLHandler: std::move spectra into addSpectrum (batch cleared afterwards). - ConsensusMap::appendColumns: std::move mutated loop copies into the unassigned-ID and consensus-feature lists. - TransferFDRModel: iterate acceptors_ by const& to avoid shared_ptr refcount churn. Builds clean; all unit/class tests for the affected classes pass. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
301e910 to
fa0f865
Compare
… (#9694) Four recently merged PRs landed on develop without changelog coverage: the QPXConverter removal was documented but missing its PR reference, and the QPXFile metavalue-iteration perf fix, the cross-codebase expensive-copy cleanup, and the EmgFitter1D robustness fix had no entry at all. Claude-Session: https://claude.ai/code/session_013oNRGEvcP3d7LMVv2hqAE4 Co-authored-by: Claude <[email protected]>
Summary
Removes avoidable heavy copies across
src/openms, found by an audit focused on OpenMP parallel regions and hot loops. All changes areconst&conversions orstd::moves of dead values — no behavior change.Each edit was specifically vetted to ensure it is not a deliberate thread-local snapshot for parallelization safety:
const&conversions only target objects that are already thread-local (constructed per-iteration) or shared read-only input (never mutated in the region).std::movetargets are dead thread-local locals written to distinct per-thread indices.Intentional copies (e.g.
std::setconst-iterator copies, sort-sink params, copies that mutate while the source must stay intact) were identified and left untouched.Changes
OPXLHelperdigestDatabasetakes FASTA DB byconst&(was a whole-DB copy); alpha/beta sequences bound asconst&inside the OpenMP candidate loopMultiplexFilteringProfileMzMLSqliteHandlerstd::moveblock-local compressed payload strings into output vectors (8 sites, two OpenMP encoding loops)SwathFileConsumergetPrecursors()instead of copying the vector per MS2 spectrumSimpleSearchEngineAlgorithm/ProSEAlgorithmconst&the reannotatedAASequence;std::movePeptideHit/hit-vector intosetHitsNuXLAnnotateAndLocatestd::movedead fragment-annotation vectorsNuXLFDRgetHits()reference instead of copying the hit vector out and backMzXMLHandlerstd::movespectra intoaddSpectrum(batch cleared afterwards)ConsensusMap::appendColumnsstd::movemutated loop copies into the unassigned-ID and consensus-feature listsTransferFDRModelacceptors_byconst&to avoidshared_ptrrefcount churnTesting
OpenMSlibrary + all targets build clean (0 errors).ctestfull suite: all class/unit tests covering the modified classes pass —OPXLHelper_test(relinked against the new signature),ConsensusMap_test,MzMLSqliteHandler_test,MultiplexFilteringProfile_test,OpenPepXLAlgorithm_test, allProSE_*/OpenNuXL_*/SimpleSearchEngine_1/2/FalseDiscoveryRate_*.CometAdapter/DatabaseSuitability; a develop-side-Search:decoys autoCLI drift from [ProSE] Default tolerances + auto decoy mode (prefix/suffix), reconciled with FDR decoupling #9644; a GLPK solver assertion inMRMFeatureSelector_test). None touch files changed here.🤖 Generated with Claude Code
Summary by CodeRabbit
Refactor
Performance