Skip to content

Optimize imaging spectrum bin accumulation - #792

Merged
YukiMatsuzawa merged 1 commit into
masterfrom
copilot/yukimatsuzawa-performance-hotspot-fix-e2b
Sep 7, 2026
Merged

Optimize imaging spectrum bin accumulation#792
YukiMatsuzawa merged 1 commit into
masterfrom
copilot/yukimatsuzawa-performance-hotspot-fix-e2b

Conversation

@YukiMatsuzawa

Copy link
Copy Markdown
Contributor

Summary

  • replace repeated ContainsKey/indexer lookups with a single TryGetValue in the imaging spectrum binning hot path
  • preserve existing binning and maximum-intensity behavior

Performance rationale

Each incoming peak previously performed a dictionary membership lookup and then additional indexer lookups. The new code performs one lookup and reuses the retrieved bin, reducing hash-table work and indexer overhead for every accumulated peak.

Performance improvement candidates identified

  1. Imaging spectrum bin accumulation — implemented; highest impact/lowest effort.
  2. Spectrum viewer drag-drop membership — use a keyed set for repeated DisplayScans.Contains checks.
  3. MSDIAL5 peak conversion — avoid sorting all MS2 spectra when acquisition mode only needs a bounded window.
  4. Normalized MS2 filtering — combine max-intensity calculation and filtering into one pass where semantics permit.
  5. Deisotoping output ordering — avoid a second sort when isotope estimation already provides ordered peak IDs.
  6. Chromatogram peak feature materialization — remove unnecessary ToList before consumers that accept enumerables.
  7. Raw spectrum export — stream transformed results instead of eagerly materializing arrays.
  8. Library peptide ordering — cache sorted peptide results for repeated access.
  9. Spot annotation grouping — build lookup dictionaries once and reuse them across chart refreshes.
  10. Imaging feature element construction — avoid duplicate projection/materialization across equivalent processing paths.

Validation

  • Focused DataAccessTests passed.
  • MsdialCore build passed after restore; restore reported existing package vulnerability/compatibility warnings.

Replace repeated dictionary lookups with TryGetValue in the imaging spectrum binning hot path.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@YukiMatsuzawa
YukiMatsuzawa merged commit 1104d4e into master Sep 7, 2026
9 checks passed
@YukiMatsuzawa
YukiMatsuzawa deleted the copilot/yukimatsuzawa-performance-hotspot-fix-e2b branch September 7, 2026 07:13
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