Implement high-performance stream architecture with circular buffers - #11
Open
google-labs-jules[bot] wants to merge 2 commits into
Conversation
…nd virtualization
Owner
|
resolve the conflicts and prioritise performance |
Author
|
I have resolved the merge conflicts by retaining the high-performance virtualization approach for the browser UI and discarding the obsolete manual DOM pruning. Additionally, I ensured that the |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
This pull request introduces a robust, high-performance architecture for managing live data streams. The primary objective is to resolve performance degradation and browser crashes caused by unbounded memory consumption during long-running logging sessions.
Why these changes are necessary
Previously, both the server and the browser accumulated incoming log data indefinitely. In high-velocity production environments, this led to Out-Of-Memory (OOM) errors on the server and UI freezes (or tab crashes) in the browser once the DOM became overwhelmed by hundreds of thousands of text nodes.
Key Architectural Decisions
The server now utilizes a
RingBufferinstead of an unbounded byte slice. By implementing a fixed-size buffer (defaulting to 10MB but configurable via CLI), we ensure the server maintains a constant memory footprint regardless of how long a stream runs. Old data is automatically evicted as new data arrives.The log viewer in
app.jshas been refactored to use a virtualization strategy. Instead of rendering every log line to the DOM, theVirtualLogVieweronly mounts the nodes currently visible in the viewport.To ensure the tool remains user-friendly for debugging, the virtualization logic is selection-aware. It prevents the UI from collapsing or resetting the scroll position while a user is actively highlighting and copying text from the stream.
The system continues to support both SSE and WebRTC. New clients instantly receive the current state of the server's circular buffer upon connection, ensuring a seamless "catch-up" experience.
Impact