Skip to content

Fix TOPPView performance when right clicking in large mzML - #8997

Merged
timosachsenberg merged 3 commits into
OpenMS:developfrom
cbielow:fix_tv_click
Mar 25, 2026
Merged

timosachsenberg merged 3 commits into
OpenMS:developfrom
cbielow:fix_tv_click

Conversation

@cbielow

@cbielow cbielow commented Mar 25, 2026 •

Copy link
Copy Markdown
Contributor

Description

fix performance bug introduced in #7974

also: limit number of fragment scans in context menu list

Checklist

  • Make sure that you are listed in the AUTHORS file
  • Add relevant changes and new features to the CHANGELOG file
  • I have commented my code, particularly in hard-to-understand areas
  • New and existing unit tests pass locally with my changes
  • Updated or added python bindings for changed or new classes (Tick if no updates were necessary.)

How can I get additional information on failed tests during CI

Click to expand If your PR is failing you can check out

Advanced commands (admins / reviewer only)

Click to expand
  • /reformat (experimental) applies the clang-format style changes as additional commit. Note: your branch must have a different name (e.g., yourrepo:feature/XYZ) than the receiving branch (e.g., OpenMS:develop). Otherwise, reformat fails to push.
  • setting the label "NoJenkins" will skip tests for this PR on jenkins (saves resources e.g., on edits that do not affect tests)
  • commenting with rebuild jenkins will retrigger Jenkins-based CI builds

⚠️ Note: Once you opened a PR try to minimize the number of pushes to it as every push will trigger CI (automated builds and test) and is rather heavy on our infrastructure (e.g., if several pushes per day are performed).

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Improved fragment scan collection logic in the 2D visualization canvas with more precise handling of scan positioning and reduced memory overhead during spectrum visualization operations.

cbielow added 2 commits March 25, 2026 15:39
…rge mzML tages ages, due to copying of the whole map multiple times)
@coderabbitai

coderabbitai Bot commented Mar 25, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The collectFragmentScansInArea_ protected method in Plot2DCanvas was refactored to accept an explicit center_rt parameter and an optional max_count limit for MS2 scans. The implementation changed from linear RT range iteration to bidirectional expansion around the center RT position, with filtering by precursor presence, MS level, and m/z containment.

Changes

Cohort / File(s) Summary
Plot2DCanvas Method Signature
src/openms_gui/include/OpenMS/VISUAL/Plot2DCanvas.h
Protected slot collectFragmentScansInArea_ signature expanded with center_rt (double) and max_count (int, default 10) parameters; documentation updated to clarify RT expansion semantics and parameter meanings.
Plot2DCanvas Implementation
src/openms_gui/source/VISUAL/Plot2DCanvas.cpp
Fragment scan collection refactored to compute center_rt from range and perform bidirectional expansion from center position; lambda captures tightened to capture only relevant indices; logic now filters by precursor, MS level, and m/z; results sorted by RT/index and limited by max_count (0 = unlimited).

Possibly related PRs

Suggested reviewers

  • timosachsenberg

Poem

🐰 Behold! The scans now bloom and spread,
From center point, both left and right they thread,
No linear march, but bidirectional grace—
A rabbit's refactor sets the perfect pace! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main fix: improving TOPPView performance when right-clicking in large mzML files, which is the core issue addressed by the optimization and max_count limiting changes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/openms_gui/source/VISUAL/Plot2DCanvas.cpp (1)

1554-1563: Use OpenMS count/index types consistently in the new bookkeeping.

indices.size() is a size_t, while max_count and index are raw ints here. That mixes signed/unsigned arithmetic in the loop guards and menu indices.

As per coding guidelines, "Use OpenMS primitive types from OpenMS/CONCEPT/Types.h instead of standard C++ types."

Also applies to: 1567-1576

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms_gui/source/VISUAL/Plot2DCanvas.cpp` around lines 1554 - 1563, The
new bookkeeping mixes std types and raw ints—change the container and counters
to OpenMS primitives: replace std::vector<size_t> indices with std::vector<Size>
(from OpenMS/CONCEPT/Types.h), make max_count use Size, and compute the scan
index in the addMS2ScanIfValid lambda using an OpenMS Size (e.g. cast the
pointer/distance result to Size) instead of raw int; where APIs require signed
ints (e.g. menu insertion calls), perform a single explicit cast at the call
site. Ensure all comparisons and loop guards use the same OpenMS Size/Int types
(indices, max_count, index) to avoid signed/unsigned mixing.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/openms_gui/source/VISUAL/Plot2DCanvas.cpp`:
- Around line 1543-1586: The outward walk can continue past the RT window
because each side only tests one boundary per iteration; change the loop so each
direction stops permanently once that side's iterator leaves the RT window: when
checking it_left, if it_left->getRT() < range.getMinRT() set it_left =
peak_data.end() (or otherwise mark left finished) and do not decrement further;
when checking it_right, if it_right->getRT() > range.getMaxRT() set it_right =
peak_data.end() (or mark right finished) and do not increment further; also
ensure the initial center_it may be outside range and treat that side as already
finished if center_it->getRT() is out of bounds. Apply these checks around the
existing addMS2ScanIfValid/RT tests (symbols: center_it, it_left, it_right,
peak_data, range, addMS2ScanIfValid, max_count) so we stop walking a side once
its RT crosses the window.

---

Nitpick comments:
In `@src/openms_gui/source/VISUAL/Plot2DCanvas.cpp`:
- Around line 1554-1563: The new bookkeeping mixes std types and raw ints—change
the container and counters to OpenMS primitives: replace std::vector<size_t>
indices with std::vector<Size> (from OpenMS/CONCEPT/Types.h), make max_count use
Size, and compute the scan index in the addMS2ScanIfValid lambda using an OpenMS
Size (e.g. cast the pointer/distance result to Size) instead of raw int; where
APIs require signed ints (e.g. menu insertion calls), perform a single explicit
cast at the call site. Ensure all comparisons and loop guards use the same
OpenMS Size/Int types (indices, max_count, index) to avoid signed/unsigned
mixing.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9d0919b7-df66-4f7f-afde-25ba985afc89

📥 Commits

Reviewing files that changed from the base of the PR and between 573199f and 7d067bb.

📒 Files selected for processing (2)
  • src/openms_gui/include/OpenMS/VISUAL/Plot2DCanvas.h
  • src/openms_gui/source/VISUAL/Plot2DCanvas.cpp

@timosachsenberg
timosachsenberg merged commit d4d039c into OpenMS:develop Mar 25, 2026
36 of 38 checks passed
github-actions Bot pushed a commit that referenced this pull request Mar 26, 2026
Add missing entries for:
- #8991: Arrow/Parquet made required dependency; WITH_PARQUET CMake option removed
- #8993: BREAKING IMFormat enum rename (CONCATENATED→IM_PEAK, MULTIPLE_SPECTRA→IM_SPECTRUM)
- #8997: Fix TOPPView performance regression when right-clicking in large mzML
- #8999: BrukerTimsFile tiered scan→1/K0 calibration with RationalScan2ImConverter

Co-authored-by: Copilot <[email protected]>
timosachsenberg pushed a commit that referenced this pull request Mar 26, 2026
Add missing entries for:
- #8991: Arrow/Parquet made required dependency; WITH_PARQUET CMake option removed
- #8993: BREAKING IMFormat enum rename (CONCATENATED→IM_PEAK, MULTIPLE_SPECTRA→IM_SPECTRUM)
- #8997: Fix TOPPView performance regression when right-clicking in large mzML
- #8999: BrukerTimsFile tiered scan→1/K0 calibration with RationalScan2ImConverter

Co-authored-by: GitHub Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
@timosachsenberg timosachsenberg mentioned this pull request Jun 8, 2026
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.

2 participants