This doesn't change anything about the profile format, this is just about the derived in-memory representation.
`JSON.stringify` serializes typed arrays as objects with stringified
numeric keys (e.g. `{"0": 1, "1": 2}`), which is not what we want
when a profile contains typed arrays.
`jsonEncodeObjectWithTypedArraysAsRegularArrays` traverses the object
and converts any typed array it finds to a regular array of numbers
before it calls `JSON.stringify`.
The new function is not used yet; the next patch in this series will
switch profile serialization to use it.
…erialization. This will allow us to have typed arrays in the profile and still serialize them as regular JSON arrays whenever the profile is serialized to JSON.
Some of our tests were auto-stringifying profiles (e.g. the ones using fetchMock), which will produce bad results once profiles start containing typed arrays. Use explicit serializeProfileToJsonString calls in those places.
`RawStackTable` is being prepared to allow `frame` to be an `Int32Array` in a later commit. `Int32Array` is fixed-size and doesn't support `push`, so the existing "push to .frame and bump .length" pattern needs a builder that uses a plain `number[]` during construction and converts to the final representation via `finishRawStackTableBuilder` at the end. Switch all stack table construction sites to use the builder. The builder still produces a plain `number[]` for `frame` in this commit; the type change happens in a follow-up.
This is the first typed array that we're supporting inside the profile format. When a profile is saved in the JsonSlabs format, it will now have this column as a separate slab that doesn't require JSON parsing. Profile compacting now always turns `stackTable.frame` into a typed array, even if that column was a regular JS array in the input profile. We still allow a regular JSON array here, because profiles stored as JSON cannot contain typed arrays, and we want to use the same type definition for JSON and JSLB profiles. Here's how this change impacts profile sizes and loading times on this profile: https://storage.googleapis.com/profiler-get-symbols-fixtures/large-speedometer3-profile.json.gz | Version | .jslb.gz size | .jslb size | Load time | Profile of it loading | |---------|---------------|------------|-------------|-----------------------------------| | 64 | 122 MB | 605 MB | 7.6 seconds | https://share.firefox.dev/4ogUKba | | 65 | 125 MB | 544 MB | 6.0 seconds | https://share.firefox.dev/3Qopiem | The compressed size has grown a small bit, but the other savings are significant: - We no longer have 131 MB of text for the frame column in the JSON - the frame column is now stored in a 70 MB i32 slab. - Less time in GZ decompression, because the uncompressed size is now smaller. - There is a lot less time spent in TextDecoder.decode and JSON.parse, because we're no longer decoding and parsing 131 MB of text for the frame column.
Merged
Merged
canova added a commit that referenced this pull request
Jun 29, 2026Changes: [Nazım Can Altınova] Bump profiler-cli version to 0.3.0 (#6104) [Markus Stange] First typed array: Allow profile.shared.stackTable.frame to be an Int32Array (#6087) [Nazım Can Altınova] Show more user friendly errors for unsupported profile version in both the frontend and the cli (#6107) [fatadel] Expose counter information in profiler-cli (#6084) [Markus Stange] Split getSelfAndTotal. (#6113) [Markus Stange] Add missing transform shortcut key handling for S (focus-self) (#6117) [Markus Stange] Remove unused isInverted prop from FlameGraphCanvas. (#6116) [Markus Stange] Change sidebar splitter CSS to only apply to the sidebar, not to all splitters under .DetailsContainer (#6114) [Markus Stange] Pass callNodeInfo to handleCallNodeTransformShortcut. (#6115) [Markus Stange] Move column declarations out into a separate file (#6119) [fatadel] Keep menu panels above the selected-marker tooltip (#6125) [Nazım Can Altınova] Make sure to always sanitize source contents even when no PII sanitization is requested (#6127) [Markus Stange] Compute FlameGraphTiming rows lazily (#6126) [Markus Stange] Create a non-connected FlameGraph component (#6118) [Nazım Can Altınova] 🔃 Sync: l10n -> main (June 29, 2026) (#6130) And special thanks to our localizers: de: Michael Köhler el: Jim Spentzos en-GB: Ian Neal es-CL: ravmn fr: Théo Chevalier fur: Fabio Tomat fy-NL: Fjoerfoks ia: Melo46 it: Francesco Lodolo [:flod] nl: Mark Heijl ru: Valery Ledovskoy sv-SE: Luna Jernberg zh-TW: Pin-guang Chen