perf: improve large-sequence rendering - #13
Merged
Conversation
There was a problem hiding this comment.
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
.seqparsing 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Improves large
.seqfile opening and waveform interaction.Issues Fixed
Large files no longer open through a
TextDocument(seqEditorProvider.ts)CustomTextEditorProviderwithCustomReadonlyEditorProvider.Large
[SHAPES]sections used excessive temporary memory (reader.ts)section filtering pass.
M1 and PNS repeatedly sorted and searched ordered gradient data (
m1.ts,pns.ts)cursors, reducing the main paths to linear scans.
Large waveform views performed work proportional to sequence size (
drawing.js,interaction.js,state.js)Zoomed-out waveform rendering processed sub-pixel raw events (
derived-series.js,drawing.js)visible points exceed the available screen-pixel width.
Open command supports custom editor tabs (
extension.ts).seqURI from text or custom editor tabs.Files Changed
src/editor/seqEditorProvider.tssrc/extension.tssrc/pulseq/reader.tssrc/pulseq/m1.tssrc/pulseq/pns.tssrc/editor/webview/assets/state.jssrc/editor/webview/assets/derived-series.jssrc/editor/webview/assets/drawing.jssrc/editor/webview/assets/interaction.js