Skip to content

Consider adding support for a binary container format #6024

@mstange

Description

@mstange

Currently our profile format uses plain JSON, often gzipped. However, using JSON is causing us some problems: We end up with files which are too large and which take too long to load.

For example, this profile is 119MB gzipped, 464MB uncompressed, and takes 900ms for TextDecoder.decode + JSON.parse. Here's a JSON size profile of its contents; this particular profile has a 246MB stackTable.

A lot of our profile data is stored in long arrays of numbers. It would save us a lot of pain if we didn't have to go through JSON strings to serialize/deserialize numbers to a file. It's just really inefficient when loading a profile:

  1. First, we have to decode the Uint8Array with the file contents to a JS string, because JSON.parse only takes strings, not buffers. Decoding UTF-8 walks all the bytes.
  2. Then we call JSON.parse on the JS string. This walks all the bytes again.

And for large profiles we even hit maximum string length restrictions (512MiB in V8).

It would be a lot nicer if we didn't have to "parse" those number arrays at all. For example, for stackTable.frame, we really just want an Int32Array.

I think we should consider adding support for a binary format which lets us get typed arrays (Int32Array, Float64Array) out of the profile data without walking the bytes, just by re-wrapping the underlying ArrayBuffer.

┆Issue is synchronized with this Jira Task

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions