Repository navigation
fix: keep valid setData on a no-copy fast path - #108
Merged
Merged
Conversation
A finite, strictly increasing, unique, OHLC-consistent series is stored as-is. The chart still copies at its boundary so callers and the default config stay untouched. Dirty rows still take the normalize path. Co-authored-by: Joe Blau <joeblau@users.noreply.github.com>
Merged
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.
Follow-up to #106. Sorted
setDataof 100k valid candles had gone from 0.8122 ms to 0.9959 ms because every load both scanned and copied the array.Behavior
DataStore.setDatamakes one pass. When every row is finite, strictly increasing, unique, and OHLC-consistent (and volume, if present, is finite and>= 0), the array is stored as-is. No second pass and no copy. A row that fails still takes the existing drop, repair, dedupe, and sort path.Chartstill copies once atsetData, construction, andupdateConfig({ data }), so a caller's array and the shared default config are not mutated when the chart appends.Tests
1905 tests passed. Coverage is 100% line, branch, and function.
bun run typecheck:tscpassed.Benchmarks
node bench/suite/run.mjs --samples=7 --sizes=100000, Node 24, median ms/op, timed back to back.Valid
setDatais faster than the pre-validation build (0.6442 vs 1.0430, and 0.6442 vs the 0.8122 ms figure from #106). That is well inside a 5% budget. The minimums in the same run were 0.7880 ms before #106 and 0.6145 ms here.