Skip to content

perf: improve large-sequence rendering - #13

Merged
bughht merged 1 commit into
bughht:mainfrom
AssociatedPrimeIdeal:release/v0.2.1
Jul 12, 2026
Merged

perf: improve large-sequence rendering#13
bughht merged 1 commit into
bughht:mainfrom
AssociatedPrimeIdeal:release/v0.2.1

Conversation

@AssociatedPrimeIdeal

Copy link
Copy Markdown
Contributor

Summary

Improves large .seq file opening and waveform interaction.

Issues Fixed

  1. Large files no longer open through a TextDocument (seqEditorProvider.ts)

    • Replaced CustomTextEditorProvider with CustomReadonlyEditorProvider.
    • Removed the redundant initial read and parse.
    • Avoids copying the complete file buffer before parsing.
  2. Large [SHAPES] sections used excessive temporary memory (reader.ts)

    • Replaced whole-file line splitting with incremental line scanning.
    • Parses shapes directly into growable typed buffers and skips the unused
      section filtering pass.
  3. M1 and PNS repeatedly sorted and searched ordered gradient data (m1.ts, pns.ts)

    • Collects gradient points in sequence order and uses forward-only sampling
      cursors, reducing the main paths to linear scans.
    • Fuses PNS padding, differentiation, and low-pass filtering into one pass.
  4. Large waveform views performed work proportional to sequence size (drawing.js, interaction.js, state.js)

    • Uses binary/visible-range lookup for tooltips and block boundaries.
    • Limits minimap TR rendering to the available pixel width.
  5. Zoomed-out waveform rendering processed sub-pixel raw events (derived-series.js, drawing.js)

    • Adds block-indexed multiresolution min/max summaries for RF and Gx/Gy/Gz.
    • Adds multiresolution ADC occupancy and uniformly sampled RF/ADC phase rendering.
    • Selects detailed or summarized rendering per channel, switching only when
      visible points exceed the available screen-pixel width.
  6. Open command supports custom editor tabs (extension.ts)

    • Resolves the active .seq URI from text or custom editor tabs.

Files Changed

  • src/editor/seqEditorProvider.ts
  • src/extension.ts
  • src/pulseq/reader.ts
  • src/pulseq/m1.ts
  • src/pulseq/pns.ts
  • src/editor/webview/assets/state.js
  • src/editor/webview/assets/derived-series.js
  • src/editor/webview/assets/drawing.js
  • src/editor/webview/assets/interaction.js

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR targets performance and memory usage when opening and interacting with large Pulseq .seq files by reducing up-front allocations (notably [SHAPES]), removing repeated sorting/searching work in PNS/M1 calculations, and switching the webview waveform rendering to use block-indexed multiresolution summaries when zoomed out.

Changes:

  • Streamline .seq parsing by incrementally scanning lines and parsing [SHAPES] with a dedicated typed-buffer parser (avoids whole-file split + redundant passes).
  • Reduce PNS and M1 computation overhead by collecting gradient points in order and using forward-only sampling/cursors, plus a fused PNS model pass.
  • Speed up webview interactions/rendering for large sequences via visible-range lookup, minimap TR decimation, and multiresolution waveform overview rendering when point density exceeds pixel budget.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/pulseq/reader.ts Incremental line scanning and a dedicated [SHAPES] parser using growable typed buffers to reduce temporary memory.
src/pulseq/pns.ts Refactors PNS to avoid repeated sorts/searches and fuses padding/differentiation/filtering into a forward-only pass.
src/pulseq/m1.ts Refactors M1 gradient sampling to use a forward cursor and removes per-sample binary searches.
src/editor/seqEditorProvider.ts Migrates to a readonly custom editor provider and removes redundant initial read/parse; avoids extra buffer copying on read.
src/extension.ts Improves “open viewer” command by resolving active .seq URIs from both text and custom editor tabs.
src/editor/webview/assets/state.js Adds waveform overview state creation and reduces minimap TR line work by stepping based on pixel width.
src/editor/webview/assets/derived-series.js Introduces block-indexed multiresolution min/max summaries and point-prefix indexing for overview rendering decisions.
src/editor/webview/assets/drawing.js Uses visible-range block bounds and switches channels to overview rendering when visible points exceed pixel budget.
src/editor/webview/assets/interaction.js Replaces linear block search for tooltips with a binary search helper and includes minimap drag handling state.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@bughht
bughht merged commit 3cecc20 into bughht:main Jul 12, 2026
9 checks passed
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.

3 participants