Uh oh!
There was an error while loading. Please reload this page.
First typed array: Allow profile.shared.stackTable.frame to be an Int32Array - #6087
Conversation
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.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@## main #6087 +/- ##
==========================================
+ Coverage 83.34% 83.37% +0.02%
==========================================
Files 338 339 +1 Lines 35868 35929 +61 Branches 9944 10056 +112 ==========================================
+ Hits 29895 29955 +60 - Misses 5545 5546 +1
Partials 428 428 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
canova
left a comment
There was a problem hiding this comment.
Sorry for the delay on the reviews. It looks great to me! I Also, thanks for the detailed explanations on the commit messages!
| * | ||
| * This function does not mutate rootObject. | ||
| */ | ||
| export function jsonEncodeObjectWithTypedArraysAsRegularArrays( |
There was a problem hiding this comment.
Oh, that's a mouthful 😄 (but it's good to be clearer than short! 😄 )
It's annoying that JS serializes typed arrays like {"0": 1, "1": 2}! But nothing we can do about it. This solution looks good to me!
Uh oh!
There was an error while loading. Please reload this page.
Changes: [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
…urrent index) (#6089) Another new version on top of #6087: - v66: Change stackTable.prefix to prefixOffset (with 0 for root nodes and `i - prefix[i]` offsets for non-roots) 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 (with [this corresponding size profile](https://share.firefox.dev/49IHi9U)) | 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 | | 66 | 89 MB | 468 MB | 5.3 seconds | https://share.firefox.dev/49JetKx | 125 MB -> 89 MB on the compressed size! That's a 29% reduction!
Main branch (loading v60 JSLB profile) | Deploy preview (loading v65 JSLB profile)
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.frameinto 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 (with this corresponding size profile)
The compressed size has grown a small bit, but the other savings are significant: