First typed array: Allow profile.shared.stackTable.frame to be an Int32Array#6087
Open
mstange wants to merge 6 commits into
Open
First typed array: Allow profile.shared.stackTable.frame to be an Int32Array#6087mstange wants to merge 6 commits into
mstange wants to merge 6 commits into
Conversation
46dde73 to
0002a8e
Compare
This doesn't change anything about the profile format, this is just about the derived in-memory representation.
0002a8e to
e7d0b56
Compare
`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.
e7d0b56 to
bc1ff2e
Compare
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.
bc1ff2e to
d116be9
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6087 +/- ##
==========================================
+ Coverage 83.70% 83.71% +0.01%
==========================================
Files 337 339 +2
Lines 35575 35754 +179
Branches 9971 10026 +55
==========================================
+ Hits 29778 29933 +155
- Misses 5369 5393 +24
Partials 428 428 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
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: