Skip to content

Optimize MS2 spectrum peak shrinking hot path - #780

Merged
YukiMatsuzawa merged 1 commit into
masterfrom
copilot/yukimatsuzawa-optimize-high-impact-hot-path
Sep 2, 2026
Merged

Optimize MS2 spectrum peak shrinking hot path#780
YukiMatsuzawa merged 1 commit into
masterfrom
copilot/yukimatsuzawa-optimize-high-impact-hot-path

Conversation

@YukiMatsuzawa

Copy link
Copy Markdown
Contributor

Summary

  • replace result.Any() with constant-time result.Count > 0 in Ms2ScanMatching.ShrinkPeaks
  • preserve peak merging behavior while avoiding repeated LINQ enumeration in the MS2 matching hot path

Ten performance improvement candidates

  1. Optimize Ms2ScanMatching.ShrinkPeaks empty-result check — high impact/trivial effort; implemented here.
  2. Cache SpectrumViewer mass/intensity ranges — medium-high impact/low effort; avoid repeated Min/Max traversals.
  3. Use a HashSet for SpectrumViewer duplicate-drop checks — medium impact/low effort.
  4. Avoid sorting every MolecularNetworking edge before degree filtering — high impact for large networks/low-medium effort.
  5. Index chemical ontology membership checks — medium-high impact/medium effort.
  6. Reduce intermediate allocations in spectrum normalization — medium impact/low effort.
  7. Improve MsScanMatching candidate availability indexing — high impact for large peak sets/medium effort.
  8. Reuse isotope-profile ordering — medium impact/medium effort.
  9. Replace repeated enumerable Count calls — low-medium impact/low effort.
  10. Batch SpectrumViewer axis recalculation notifications — medium UI impact/medium effort.

Validation

  • dotnet restore tests\Common\CommonStandardTests\CommonStandardTests.csproj
  • dotnet test tests\Common\CommonStandardTests\CommonStandardTests.csproj --no-restore --verbosity minimal

Replace repeated LINQ enumeration with a constant-time count check in the MS2 matching hot path.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@YukiMatsuzawa
YukiMatsuzawa merged commit 45a531c into master Sep 2, 2026
9 checks passed
@YukiMatsuzawa
YukiMatsuzawa deleted the copilot/yukimatsuzawa-optimize-high-impact-hot-path branch September 2, 2026 04:01
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.

1 participant