Skip to content

perf(candles): avoid sorting history on updates - #2119

Closed
antonbelous0v wants to merge 1 commit into
dydxprotocol:mainfrom
antonbelous0v:codex/perf-candle-updates
Closed

antonbelous0v wants to merge 1 commit into
dydxprotocol:mainfrom
antonbelous0v:codex/perf-candle-updates

Conversation

@antonbelous0v

Copy link
Copy Markdown

Summary

  • replace full candle-history filtering and sorting with binary-search insertion
  • replace candles with matching timestamps and insert new candles in chronological order
  • preserve immutable updates and cover append, replacement, and unordered batches

Benchmark

Single-candle update, local Node 24 benchmark (average per update):

Candles Before After
1,000 0.088 ms 0.001 ms
10,000 0.599 ms 0.003 ms
50,000 3.391 ms 0.077 ms

Testing

  • pnpm vitest run src/bonsai/websocket/__test__/candles.test.ts
  • pnpm eslint src/bonsai/websocket/candles.ts src/bonsai/websocket/__test__/candles.test.ts
  • pnpm tsc --noEmit

@antonbelous0v
antonbelous0v requested a review from a team as a code owner September 2, 2026 15:10
@vercel

vercel Bot commented Sep 2, 2026

Copy link
Copy Markdown

@AntonBelousovWEB is attempting to deploy a commit to the dYdX Trading Team on Vercel.

A member of the Team first needs to authorize it.

@antonbelous0v
antonbelous0v deleted the codex/perf-candle-updates branch September 2, 2026 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant