feat: high-frequency WebSocket streaming buffer throttler (#6)#88
Merged
elizabetheonoja-art merged 1 commit intoJun 25, 2026
Merged
Conversation
…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
approved these changes
Jun 25, 2026
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.
High-Frequency WebSocket Streaming Buffer Throttler (#6)
Closes #6
What's included
src/utils/buffer.tsRingBuffer— fixedMAX_POINTS = 200capacity,slice(-capacity)eviction, runtimesetCapacity.StreamBatcher— accumulates writes and flushes into the ring everyBATCH_INTERVAL = 50ms(injectable clock).AdaptiveCapacityMonitor— shrinks the retained window after sustained frames overSLOW_FRAME_MS = 33(<30 FPS) and grows it back when the frame rate recovers.src/utils/helpers.tsthrottle<T>(fn, wait)(leading + trailing) plus adebouncecompanion.src/components/spatial/LiveDataView.tsxResizeObserverupdates are throttled.tests/unit/buffer.test.ts,tests/unit/helpers.test.ts