Skip to content

Optimize repeated MSDec chromatogram metadata lookups - #756

Open
YukiMatsuzawa wants to merge 1 commit into
masterfrom
copilot/yukimatsuzawa-optimize-high-impact-path
Open

Optimize repeated MSDec chromatogram metadata lookups#756
YukiMatsuzawa wants to merge 1 commit into
masterfrom
copilot/yukimatsuzawa-optimize-high-impact-path

Conversation

@YukiMatsuzawa

Copy link
Copy Markdown
Contributor

Summary

  • audited the MSDIAL5/Common processing and visualization paths for performance opportunities
  • hoisted invariant chromatogram type/unit lookups out of the per-spectrum loop in MSDecResult.DecChromPeaks
  • preserves existing output while avoiding repeated LINQ enumeration and allocations during chart refreshes

Ranked performance opportunities

  1. Hoist DecChromPeaks metadata lookups — high impact in repeated chart refreshes, one-line surgical fix (implemented here).
  2. Replace OrderByDescending(...).Take(n) in spectrum display paths with a bounded top-N selection when spectra are large.
  3. Replace nearest-RT OrderBy(...).First() with a linear minimum scan in retention-time chart rendering.
  4. Cache repeated ModelPeakChromatogram.Count and collection references in EIC generation loops.
  5. Avoid repeated Where(...).OrderBy(...).FirstOrDefault() scans in raw spectrum S/N distribution calculation.
  6. Reuse a mass-indexed lookup for MS1/MS2 partial-link matching instead of repeatedly traversing candidate peaks.
  7. Cache chromatogram extraction results across correlation comparisons in PeakCharacterEstimator.
  8. Replace repeated Select(...).ToArray() materialization in coefficient calculations with direct array reuse where safe.
  9. Use a HashSet for repeated feature-ID membership tests in alignment/linking workflows.
  10. Review repeated GroupBy(...).OrderByDescending(...).Take(...) network pruning for a bounded per-group selection algorithm.

Validation

  • dotnet test tests\\MSDIAL5\\MsdialCoreTests\\MsdialCoreTests.csproj --no-restore --filter FullyQualifiedName~MSDec
  • dotnet test tests\\MSDIAL5\\MsdialCoreTests\\MsdialCoreTests.csproj --no-restore --filter FullyQualifiedName~AnnotatedMSDecResult
  • git diff --check

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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