fix(performance): chunked buffer parsing to prevent OOM on large traces - #2736
Closed
gaurav9949 wants to merge 1 commit into
Closed
gaurav9949 wants to merge 1 commit into
gaurav9949 wants to merge 1 commit into
Conversation
Resolves ChromeDevTools#2701 ### Cause `parseRawTraceBuffer` previously decoded the entire trace `Uint8Array` into a single JavaScript string using `TextDecoder().decode(buffer)`. When processing trace files exceeding ~512 MB, this exceeded V8's maximum string length limit (`0x1fffffe8` characters), causing the process to throw an out-of-memory error. ### Solution - Introduced `extractTraceEvents` to scan the `Uint8Array` byte-by-byte for JSON structural boundaries without allocating a giant intermediate string. - Slices and decodes trace events incrementally, parsing each event object independently. - Maintains compatibility with both top-level JSON arrays and objects containing a `traceEvents` array.
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Collaborator
|
Thanks for the PR but it will be closed by #2721 |
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.
Resolves #2701
Cause
parseRawTraceBufferpreviously decoded the entire traceUint8Arrayinto a single JavaScript string usingTextDecoder().decode(buffer). When processing trace files exceeding ~512 MB, this exceeded V8's maximum string length limit (0x1fffffe8characters), causing the process to throw an out-of-memory error.Solution
extractTraceEventsto scan theUint8Arraybyte-by-byte for JSON structural boundaries without allocating a giant intermediate string.traceEventsarray.