Skip to content

[TEST] Speed up slow class tests by removing redundant work (#4854) - #9696

Merged
timosachsenberg merged 2 commits into
developfrom
speedup-slow-tests-4854
Jul 1, 2026
Merged

timosachsenberg merged 2 commits into
developfrom
speedup-slow-tests-4854

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Jul 1, 2026 •

Copy link
Copy Markdown
Contributor

Closes #4854.

Context

The 2020 issue lists Windows-Debug runtimes. Much has already improved on develop: several named offenders were removed (CompNovo, PeakPickerCWT) or renamed, and the diagnosed std::endl-flush cause is already handled (the ClassTest framework and mzML writer use '\n'/buffered writes and only print on failure).

Measuring current standalone runtimes, one test dominates every other pure-OpenMS class test by two orders of magnitude. These changes remove redundant, deterministic recomputation from the heaviest tests. No assertion or expected value changes — each distinct configuration is still exercised exactly as before.

Changes

Test Before After Note
FLASHDeconvAlgorithm_test 213 s ~60 s 20 → 8 full run()s
OPXLHelper_test (Windows: 75 s) — O(n²) enumerate 3× → 1×
IsobaricChannelExtractor_test (Windows: 26 s) — _6.mzML parsed 6× → 1×
MultiplexClustering_test — — dead cluster() removed
  • FLASHDeconvAlgorithm_test: the "Phase 1" sections (added in [WIP] Update FLASHDeconv #8257, a [WIP] PR) re-ran the full deconvolution 20× on the same input, each only reading a different trivial property of the identical result. The TOPDOWN module has no randomness (so run() is deterministic, which the test's own consistency sections already assert), so this hoists one shared default run and one shared FDR run and repoints the read-only sections at them. All distinct configs (RNA averagine, gaussian merging, FDR) and the cross-run determinism guards are kept. 213 s → ~60 s (Release).
  • OPXLHelper_test: the O(n²) enumerateCrossLinksAndMasses ran 3× with byte-identical inputs → enumerate once and reuse (copies where filterPrecursorsByTags mutates in place).
  • IsobaricChannelExtractor_test: IsobaricChannelExtractor_6.mzML was parsed from disk 6× into fresh PeakMaps → parse once into a shared const map, aliased read-only in each section (extractChannels takes const PeakMap&).
  • MultiplexClustering_test: drop a full cluster() call in the constructor-only section whose result was never asserted.

Notes

On Linux Release the three secondary tests are already ~0.2 s (small test data); their payoff is Windows-Debug-specific, where per-op cost is 100–300× and they map onto the issue's own 75 s / 26 s entries. FLASHDeconv is the decisive, cross-platform win. All four tests were rebuilt and pass with identical outputs. The remaining suite hotspots are external-tool adapters (Comet/Sage/Percolator/Luciphor), which aren't OpenMS-code-optimizable.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Improved efficiency and reliability by reusing shared, deterministic inputs across multiple scenarios.
    • Reduced repeated expensive computations for deconvolution validation, isobaric extraction, clustering, and precursor/cross-link candidate handling.
    • Strengthened assertions for output consistency (vector sizing, scan metadata), parameter handling in merging behavior, and FDR/decoy-related regressions.
    • Refactored tests to avoid redundant mzML loading and to run core clustering logic only in the appropriate test section.

These tests re-ran expensive, deterministic computations many times over
the same input while only reading different trivial properties of the
identical result. Compute each distinct configuration once and reuse it;
no assertion or expected value changes.

- FLASHDeconvAlgorithm_test: ran the full (deterministic) deconvolution 20x
  on the same input across the "Phase 1" sections. The TOPDOWN module has no
  randomness, so hoist one shared default run and one shared FDR run and
  repoint the read-only sections at them (20 -> 8 runs). All distinct
  configurations (RNA, gaussian merging, FDR) and the cross-run determinism
  guards are preserved. ~213s -> ~60s (Release).

- OPXLHelper_test: the O(n^2) enumerateCrossLinksAndMasses was run 3x with
  byte-identical inputs; enumerate once at file scope and reuse (copies where
  filterPrecursorsByTags mutates in place).

- IsobaricChannelExtractor_test: IsobaricChannelExtractor_6.mzML was parsed
  from disk 6x into fresh PeakMaps; parse once into a shared const map and
  alias it (read-only) in each section.

- MultiplexClustering_test: drop a full cluster() call in the constructor
  section whose result was never asserted (the cluster() section below
  already exercises and checks it).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@timosachsenberg timosachsenberg mentioned this pull request Jul 1, 2026
@coderabbitai

coderabbitai Bot commented Jul 1, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 25560a48-4554-45c7-8f9d-d9de9526e989

📥 Commits

Reviewing files that changed from the base of the PR and between 389ad6d and bf2c02c.

📒 Files selected for processing (2)
  • src/tests/class_tests/openms/source/FLASHDeconvAlgorithm_test.cpp
  • src/tests/class_tests/openms/source/OPXLHelper_test.cpp
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/tests/class_tests/openms/source/OPXLHelper_test.cpp
  • src/tests/class_tests/openms/source/FLASHDeconvAlgorithm_test.cpp

📝 Walkthrough

Walkthrough

Four unit test files were refactored to reuse shared inputs and precomputed results instead of repeating expensive setup and execution. The changes affect FLASHDeconvAlgorithm, IsobaricChannelExtractor, MultiplexClustering, and OPXLHelper tests.

Changes

FLASHDeconvAlgorithm test refactor

Layer / File(s) Summary
Shared baseline/FDR setup and averagine validation
src/tests/class_tests/openms/source/FLASHDeconvAlgorithm_test.cpp
Computes shared default and FDR deconvolution outputs once, then reuses them for averagine initialization and mass-range checks.
Spectrum merging validation
src/tests/class_tests/openms/source/FLASHDeconvAlgorithm_test.cpp
Validates multiple merging method settings and runs a dedicated Gaussian-merging case that checks non-empty output.
FDR and decoy averagine assertions
src/tests/class_tests/openms/source/FLASHDeconvAlgorithm_test.cpp
Reuses shared default and FDR runs to check decoy averagine initialization, noise decoy weight bounds, decoy container non-emptiness, and a repeated FDR regression case.
Output validation reuse
src/tests/class_tests/openms/source/FLASHDeconvAlgorithm_test.cpp
Reuses shared default spectra and features for metadata, feature property, peak-group presence, repeated-size consistency, and scan-number checks.

IsobaricChannelExtractor shared PeakMap refactor

Layer / File(s) Summary
Shared PeakMap fixture and section reuse
src/tests/class_tests/openms/source/IsobaricChannelExtractor_test.cpp
Creates a file-scope shared PeakMap and rebinds several exp and exp_purity references to it instead of reloading the mzML file.

MultiplexClustering constructor test simplification

Layer / File(s) Summary
Constructor test skips cluster()
src/tests/class_tests/openms/source/MultiplexClustering_test.cpp
Removes the expensive cluster() call from the constructor test section and leaves clustering checks to the later section.

OPXLHelper precursor enumeration reuse

Layer / File(s) Summary
One-time enumeration and reuse in downstream tests
src/tests/class_tests/openms/source/OPXLHelper_test.cpp
Moves cross-link precursor enumeration to file scope, uses a local sorted copy in buildCandidates, and filters local copies in filterPrecursorsByTags.

Suggested reviewers: cbielow

Poem

A rabbit hopped through tests once slow,
Cached the bits so they’d not re-glow. 🐇
One mzML load, one deconv run,
Less looping now, more time for fun.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: speeding up slow class tests by removing redundant work.
Linked Issues check ✅ Passed The changes address issue #4854 by eliminating repeated deterministic work in the slow tests highlighted by the issue.
Out of Scope Changes check ✅ Passed All modifications stay within the test-speedup scope and do not introduce unrelated code changes.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch speedup-slow-tests-4854

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.

@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: 3

🤖 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/tests/class_tests/openms/source/FLASHDeconvAlgorithm_test.cpp`:
- Around line 313-336: Replace the boolean assertions in
FLASHDeconvAlgorithm_test with the preferred TEST_TRUE/TEST_FALSE helpers,
especially in the Output validation sections. Update the checks on
spec.getScanNumber() and feature.avg_mass to use TEST_TRUE, and remove the
tautological default_features.size() >= 0 assertion since it can never fail; if
you need to verify feature presence, assert a meaningful condition against
default_features or its contents instead.

In `@src/tests/class_tests/openms/source/IsobaricChannelExtractor_test.cpp`:
- Around line 77-80: The shared load of IsobaricChannelExtractor_6.mzML should
not happen before the first section because it bypasses the per-section
START_SECTION try/catch handling. Move the PeakMap ic6_shared initialization and
the MzMLFile().load call into a dedicated START_SECTION setup block or a small
helper invoked from within a section so any parse/file failure only fails that
subtest. Keep the shared variable available to the later sections that reuse it.

In `@src/tests/class_tests/openms/source/OPXLHelper_test.cpp`:
- Around line 89-93: The shared precursors vector is being reordered by
OPXLDataStructs::XLPrecursorComparator, but
spectrum_precursor_correction_positions is left in the original order, so the
pair loses alignment. In the OPXLHelper_test setup where
enumerateCrossLinksAndMasses is reused, either sort a local copy of precursors
or apply the same ordering to spectrum_precursor_correction_positions before the
later filterPrecursorsByTags section so each precursor stays matched with its
correction position.
🪄 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: 56647df9-0ca5-4e90-a817-0c3d5fb01f8b

📥 Commits

Reviewing files that changed from the base of the PR and between e11ac28 and 389ad6d.

📒 Files selected for processing (4)
  • src/tests/class_tests/openms/source/FLASHDeconvAlgorithm_test.cpp
  • src/tests/class_tests/openms/source/IsobaricChannelExtractor_test.cpp
  • src/tests/class_tests/openms/source/MultiplexClustering_test.cpp
  • src/tests/class_tests/openms/source/OPXLHelper_test.cpp

…aligned

FLASHDeconvAlgorithm_test:
- Use TEST_TRUE/TEST_FALSE for boolean assertions in the Output Validation
  sections (spec.getScanNumber(), feature.avg_mass, pg.getMonoMass(),
  found_peak_groups) instead of TEST_EQUAL(<bool>, true).
- Replace the tautological TEST_EQUAL(default_features.size() >= 0, true)
  (size() is unsigned, so it can never fail) with the meaningful
  TEST_FALSE(default_features.empty()); the default run finds features on
  this input (as the void run() section already asserts).

OPXLHelper_test:
- The shared 'precursors' was sorted in place while
  'spectrum_precursor_correction_positions' was left unsorted, so the
  filterPrecursorsByTags section reused a misaligned pair. Sort a local copy
  inside the buildCandidates section (the only consumer needing sorted
  precursors) so the shared vectors stay index-aligned for the filter test.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@timosachsenberg
timosachsenberg merged commit 02545db into develop Jul 1, 2026
13 checks passed
@timosachsenberg
timosachsenberg deleted the speedup-slow-tests-4854 branch July 1, 2026 09:55
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.

Speed up tests

1 participant