Skip to content

feat: high-frequency WebSocket streaming buffer throttler (#6)#88

Merged
elizabetheonoja-art merged 1 commit into
Utility-Protocol:mainfrom
real-venus:feat/ws-streaming-throttler
Jun 25, 2026
Merged

feat: high-frequency WebSocket streaming buffer throttler (#6)#88
elizabetheonoja-art merged 1 commit into
Utility-Protocol:mainfrom
real-venus:feat/ws-streaming-throttler

Conversation

@real-venus

Copy link
Copy Markdown
Contributor

High-Frequency WebSocket Streaming Buffer Throttler (#6)

Closes #6

What's included

File Responsibility
src/utils/buffer.ts RingBuffer — fixed MAX_POINTS = 200 capacity, slice(-capacity) eviction, runtime setCapacity. StreamBatcher — accumulates writes and flushes into the ring every BATCH_INTERVAL = 50ms (injectable clock). AdaptiveCapacityMonitor — shrinks the retained window after sustained frames over SLOW_FRAME_MS = 33 (<30 FPS) and grows it back when the frame rate recovers.
src/utils/helpers.ts throttle<T>(fn, wait) (leading + trailing) plus a debounce companion.
src/components/spatial/LiveDataView.tsx Routes ingestion through the batcher; the RAF draw loop reads the ring buffer directly (no React state on the hot path) and feeds frame-to-frame time to the CPU monitor to adapt capacity; ResizeObserver updates are throttled.
tests/unit/buffer.test.ts, tests/unit/helpers.test.ts Ring eviction/resize, batch flush timing (deterministic clock), adaptive shrink/grow/streak-reset, and throttle/debounce edge behavior (fake timers).

…otocol#6)

Decouples telemetry ingestion from the canvas draw loop so 50+ msg/s bursts no
longer drop frames or cause tab unresponsiveness.

- utils/buffer.ts: RingBuffer (fixed MAX_POINTS=200 capacity, slice(-cap)
  eviction, runtime setCapacity), StreamBatcher (accumulate writes, flush into
  the ring every BATCH_INTERVAL=50ms; injectable clock), and
  AdaptiveCapacityMonitor (shrinks the window after frames exceed 33ms / <30 FPS,
  grows back when healthy)
- utils/helpers.ts: throttle<T>(fn, wait) (leading + trailing) plus debounce
- components/spatial/LiveDataView.tsx: routes ingestion through the batcher, the
  RAF draw loop reads the ring buffer directly (no React state on the hot path)
  and feeds frame time to the CPU monitor to adapt capacity; ResizeObserver
  updates are throttled
- tests for the ring buffer, batching/flush timing, the adaptive monitor, and
  throttle/debounce

Test file lives under tests/unit (vitest only collects tests/**, not
src/__tests__).
@elizabetheonoja-art elizabetheonoja-art merged commit 4628a37 into Utility-Protocol:main Jun 25, 2026
4 checks passed
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.

Issue 6: High-Frequency WebSocket Streaming Buffer Throttler

2 participants