Skip to content

fix(performance): chunked buffer parsing to prevent OOM on large traces - #2736

Closed
gaurav9949 wants to merge 1 commit into
ChromeDevTools:mainfrom
gaurav9949:patch-1
Closed

gaurav9949 wants to merge 1 commit into
ChromeDevTools:mainfrom
gaurav9949:patch-1

Conversation

@gaurav9949

Copy link
Copy Markdown

Resolves #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.

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.
@google-cla

google-cla Bot commented Sep 13, 2026

Copy link
Copy Markdown

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.

@OrKoN

OrKoN commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the PR but it will be closed by #2721

@OrKoN OrKoN closed this Sep 17, 2026
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.

performance_stop_trace throws on traces over ~512 MB since the 1.2 GB buffer default

2 participants