perf: improve large-sequence rendering - #12
Merged
bughht merged 1 commit intoJul 11, 2026
Conversation
Contributor
Author
|
ute_3d_rf-sinc_rw_s0.9791666666666666_N96_FOV0.4_TR0.00242_TE0.00024000000000000003_C=1.zip |
There was a problem hiding this comment.
Pull request overview
This PR targets performance bottlenecks when rendering and interacting with large Pulseq sequences, primarily by reducing algorithmic complexity in minimap/block selection and by decoupling “cursor hover” updates from full waveform / WebGL redraws.
Changes:
- Optimizes minimap block-position construction to linear time in
SeqEditorProvider. - Improves rendering performance by selecting visible blocks via binary search and batching waveform drawing by channel.
- Adds a dedicated cursor overlay canvas and coalesces pointer updates to avoid full redraws on hover; splits k-space WebGL trajectory redraws from lightweight overlay redraws.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/editor/seqEditorProvider.ts | Builds minimap block positions using a running cumulative sum (O(n) instead of O(n²)). |
| src/editor/webview/assets/drawing.js | Refactors waveform rendering to draw only visible blocks and adds cursor overlay rendering. |
| src/editor/webview/assets/interaction.js | Coalesces pointer events via requestAnimationFrame and updates overlays without full redraw. |
| src/editor/webview/assets/kspace.js | Separates fast 2D overlay redraws from WebGL trajectory redraws; adds debug counters. |
| src/editor/webview/assets/state.js | Introduces overlay canvas state and updates the draw scheduling to include k-space redraws. |
| src/editor/webview/assets/styles.css | Styles the new cursor overlay canvas (#moc). |
| src/editor/webview/assets/template.html | Adds the new overlay canvas element (<canvas id="moc">). |
| src/pulseq/trdetect.ts | Changes TR estimation rounding to microsecond quantization to avoid rounding short TR to zero. |
| web/index.html | Mirrors webview performance changes in the standalone web build (overlay canvas, coalesced pointer updates, batching). |
| web/pulseq-bundle.js | Updates bundled Pulseq version and mirrors TR rounding behavior change. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+542
to
+544
| moc.width=r.width*dpr;moc.height=r.height*dpr; | ||
| moc.style.width=r.width+'px';moc.style.height=r.height+'px'; | ||
| moctx.setTransform(dpr,0,0,dpr,0,0); |
Comment on lines
+331
to
+333
| moc.width=r.width*dpr;moc.height=r.height*dpr; | ||
| moc.style.width=r.width+'px';moc.style.height=r.height+'px'; | ||
| moctx.setTransform(dpr,0,0,dpr,0,0); |
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
Fixes large-sequence loading and interaction bottlenecks.
Performance Issues Fixed
Quadratic minimap block-position construction (
seqEditorProvider.ts)O(n^2)toO(n).Short estimated TR rounded to zero (
trdetect.ts)Full block scan and per-event Canvas state changes (
drawing.js)events extending beyond nominal block bounds are still considered.
save,clip,stroke, andrestorefor each event.O(n)toO(log n + v), wherevisthe number of visible blocks.
Full waveform redraw on every pointer event (
interaction.js,drawing.js,state.js,template.html,styles.css)requestAnimationFrame.Unnecessary WebGL trajectory redraw during waveform hover (
kspace.js)projection, point size, unit, or trajectory data changes.
Files Changed
src/editor/seqEditorProvider.tssrc/editor/webview/assets/drawing.jssrc/editor/webview/assets/interaction.jssrc/editor/webview/assets/kspace.jssrc/editor/webview/assets/state.jssrc/editor/webview/assets/styles.csssrc/editor/webview/assets/template.htmlsrc/pulseq/trdetect.tsweb/index.htmlweb/pulseq-bundle.js