Skip to content

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

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

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

Conversation

@antonbelous0v

Copy link
Copy Markdown

Summary

  • use binary search to update the already sorted candle history
  • replace existing candles or insert new candles without sorting the full history
  • add regression coverage for append, replacement, and unordered batches

Benchmark

Single-candle update: 50,000 candles improved from 3.391 ms to 0.077 ms locally.

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:17
@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.

This branch has not been deployed

No deployments
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