Repository navigation
[PERF] MetaInfoRegistry: share the lock between lookups - #10594
Merged
Merged
Conversation
Every access to a meta value by name (MetaInfoInterface::setMetaValue, getMetaValue, metaValueExists, ...) looks the name up in the global MetaInfoRegistry, and every registry method ran inside one OpenMP critical section. Threads that only read the registry therefore excluded each other. Use a std::shared_mutex instead: lookups (including registerName() for a name that is registered already, the common case) take it shared, and only registering a new name or changing a description/unit takes it exclusively. Exceptions for unregistered names and indices are now thrown with the lock released by its guard instead of from inside a critical section. Measured with OpenDIA on an Orbitrap Astral DIA run (600k precursors, 32 threads, no chromatogram output): 30% of the thread samples in the extraction/scoring stage were waiting for this critical section, mostly below MRMFeatureFinderScoring::addScoreMetaValues_. With the shared lock the CPU time of that stage drops from 82 min to 39 min and its wall time from 3:52 min to 3:11 min; results are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Sr8hFGChVGwX29y7mDXezS
cbielow
reviewed
Oct 16, 2026
cbielow
left a comment
Contributor
There was a problem hiding this comment.
in general, a good thing. Just wondering if
- is there a performance increase in real world scenarios?
- do we pay with compile time?
MetaInfoRegistry.h is included by nearly every OpenMS file (through MetaInfo.h), so do not make it include <shared_mutex> or change the class layout: the reader-writer lock is now a file-local object in MetaInfoRegistry.cpp that guards all registries, as the named OpenMP critical section did before. Only MetaInfo's global registry is used in practice, so lookups are as concurrent as with a per-registry lock, and assignment needs only one lock. The lock is created on first use and never destroyed, so registries stay usable while objects with static storage duration are destroyed. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Sr8hFGChVGwX29y7mDXezS
cbielow
reviewed
Oct 16, 2026
Contributor
|
nice speedup! |
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Sr8hFGChVGwX29y7mDXezS
Contributor
Author
|
thanks for the review will merge once ci passes |
timosachsenberg
pushed a commit
that referenced
this pull request
Oct 16, 2026
#10595, which this branch was stacked on, was squash-merged into develop, so the files both changed conflicted. develop has exactly #10595's final content plus #10594 (MetaInfoRegistry); the resolution keeps this branch's versions and adds #10594's CHANGELOG entry. The diff against develop is the one commit of this PR. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012GBvJZN8neGpv9RoUshwFL
timosachsenberg
pushed a commit
that referenced
this pull request
Oct 16, 2026
CHANGELOG conflict with #10594: both entries are kept, with this branch's wording of the Percolator PEP fix (ProSE's -rescore flag is removed here). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012GBvJZN8neGpv9RoUshwFL
timosachsenberg
pushed a commit
that referenced
this pull request
Oct 16, 2026
Only CHANGELOG conflicted; both sides are kept. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01B51nRFoHvZuVXD7cT8XZav
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.
Description
Every access to a meta value by name (
MetaInfoInterface::setMetaValue,getMetaValue,metaValueExists, ...) looks the name up in the globalMetaInfoRegistry. Every registry method ran inside one OpenMP critical section, so threads that only read the registry excluded each other.This PR replaces the critical section with a
std::shared_mutex:registerName()for a name that is already registered, which is the common case.registerName()checks under the shared lock first, then takes the exclusive lock and checks again before inserting, because another thread may have registered the name in between.MetaInfoRegistry.cppthat guards all registries, as the named critical section did.MetaInfoRegistry.his unchanged, so the files that include it do not get<shared_mutex>, and the class layout stays the same. The lock is created on first use and never destroyed, so registries stay usable while objects with static storage duration are destroyed.The public API is unchanged, and the pyOpenMS bindings need no update.
Measured with OpenDIA on an Orbitrap Astral DIA run (600k precursors, 32 threads, no chromatogram output). 30% of the thread samples in extraction and scoring were waiting for this critical section, mostly under
MRMFeatureFinderScoring::addScoreMetaValues_. With the shared lock:This change is also part of #10559, the OpenDIA runtime and memory PR, with the same
MetaInfoRegistrycode. It is proposed separately here because it affects every multithreaded tool that sets or reads meta values by name, not only OpenDIA. A follow-up in #10559 that made lookups lock-free with thread-local copies of the name table has been reverted there: it saved about 5 s per run but added considerable complexity to this central class. Both PRs add the same CHANGELOG entry at the same place, so whichever merges second needs a trivial CHANGELOG conflict resolution.Checklist
🤖 Generated with Claude Code
https://claude.ai/code/session_01Sr8hFGChVGwX29y7mDXezS
Summary by CodeRabbit