Skip to content

fix: keep valid setData on a no-copy fast path - #108

Merged
cursor[bot] merged 1 commit into
mainfrom
cursor/setdata-fast-path-0692
Nov 10, 2026
Merged

cursor[bot] merged 1 commit into
mainfrom
cursor/setdata-fast-path-0692

Conversation

@joeblau

@joeblau joeblau commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #106. Sorted setData of 100k valid candles had gone from 0.8122 ms to 0.9959 ms because every load both scanned and copied the array.

Behavior

DataStore.setData makes 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.

Chart still copies once at setData, construction, and updateConfig({ 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:tsc passed.

Benchmarks

node bench/suite/run.mjs --samples=7 --sizes=100000, Node 24, median ms/op, timed back to back.

Case Before #106 #106 This change
100000 setData sorted 1.0430 1.2069 0.6442

Valid setData is 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.

Open in Web Open in Cursor 

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>
@cursor
cursor Bot merged commit 4b64fc4 into main Nov 10, 2026
8 checks passed
@cursor
cursor Bot deleted the cursor/setdata-fast-path-0692 branch November 10, 2026 19:50
@joeblau joeblau mentioned this pull request Nov 11, 2026
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.

2 participants