Fix multi-model performance review findings#19
Draft
mrecachinas wants to merge 5 commits intospectriclabs:mainfrom
Draft
Fix multi-model performance review findings#19mrecachinas wants to merge 5 commits intospectriclabs:mainfrom
mrecachinas wants to merge 5 commits intospectriclabs:mainfrom
Conversation
- F3: Remove console.log from mx.trace() highlight fill hot path
- F4: Hoist Math.exp(-decay) computation outside vmovmax loop
- F8: Pass existing xpoint/ypoint views instead of creating new PointArray wrappers
- F8: Use subarray() instead of slice() for maxhold data (avoids copy)
- F9: Hoist clipping object {tL, tE} outside the per-point loop
- F15: Use shared DASHED_STYLE constant instead of per-call allocation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- F1: Pool pixx/pixy Int32Array buffers on Mx object in mx.trace(), grow-only - F5: Guard SDS 1D buffer allocation with size check to avoid per-frame alloc - F10: Pre-allocate typed arrays for highlight fill instead of push()-based growth - F13: Cache ImageData objects in both renderImage paths, reuse when dimensions match Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- F7: Replace deprecated createEvent/initEvent with CustomEvent; add suppress_lyrdraw opt-out flag
- F14: Cache measureText results for legend labels, invalidated on layer name changes
- F16: Add getCachedCtx() helper using WeakMap to avoid repeated getContext('2d') lookups
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- F2: Replace zbuf slice/push churn with in-place copyWithin+set for 2D scrolling modes - F6: Cache prep() bounds from draw() for reuse in get_pan_bounds(), avoiding double computation - F11: Replace flat loop with nested y/x loops in scaleImage, eliminating modulo/division per pixel - F12: Hoist origin/direction checks outside pixel loop in create_image, use nested loops Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Implement min-max decimation in Layer1D.draw() that reduces point count to at most 2*screenWidth when data significantly exceeds pixel resolution. Preserves visual peaks/valleys while skipping redundant sub-pixel points. - Only activates for line-only rendering (not symbols) when pts > 2*screenWidth - Full data still used for bounds calculation, maxhold, and pan operations - Controlled by layer.decimate flag (defaults to true) - Reuses decimation buffers across frames to minimize GC pressure Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Performance optimizations from multi-model review
Addresses 17 findings from a multi-model performance review across the rendering hot paths.
Allocation reduction:
pixx/pixytrace buffers on Mx object (grow-only)ImageDataobjects, reuse when dimensions matchHot-path improvements:
console.logfrommx.trace()fill pathMath.exp(-decay)outsidevmovmaxloopPointArraywrappers; usesubarray()overslice()DASHED_STYLEconstantAlgorithmic improvements:
zbufslice/push with in-placecopyWithin+setfor 2D scrollingprep()bounds for reuse inget_pan_bounds()scaleImageandcreate_image(eliminates per-pixel modulo/division)Caching & event dispatch:
createEvent/initEventwithCustomEventmeasureTextresults for legend labelsgetCachedCtx()helper viaWeakMapto avoid repeatedgetContext("2d")Level-of-detail rendering:
Layer1D.draw()— reduces points to ≤2×screenWidth when data far exceeds pixel resolution, preserving peaks/valleys. Controlled bylayer.decimate(default: true).6 files changed (
m.js,mx.js,sigplot.js,sigplot.layer1d.js,sigplot.layer1dSDS.js,sigplot.layer2d.js).