Skip to content

Change profile.shared.stackTable.prefix to prefixOffset (delta from current index)#6089

Open
mstange wants to merge 2 commits into
firefox-devtools:mainfrom
mstange:stacktable-prefix-offset
Open

Change profile.shared.stackTable.prefix to prefixOffset (delta from current index)#6089
mstange wants to merge 2 commits into
firefox-devtools:mainfrom
mstange:stacktable-prefix-offset

Conversation

@mstange

@mstange mstange commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Two new versions on top of #6087:

  • v66: Change stackTable.prefix to an Int32Array (with -1 instead of null for root nodes)
  • v67: 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)

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 130 MB 468 MB 5.7 seconds https://share.firefox.dev/4uePEgU
67 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!

@codecov

codecov Bot commented Jun 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.00000% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.30%. Comparing base (53a3071) to head (610f1a9).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/profile-logic/profile-compacting.ts 57.44% 20 Missing ⚠️
src/profile-logic/transforms.ts 95.91% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6089      +/-   ##
==========================================
- Coverage   83.35%   83.30%   -0.05%     
==========================================
  Files         339      339              
  Lines       35941    36048     +107     
  Branches    10058     9997      -61     
==========================================
+ Hits        29957    30030      +73     
- Misses       5556     5590      +34     
  Partials      428      428              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mstange mstange force-pushed the stacktable-prefix-offset branch from 372c5dd to b581752 Compare June 6, 2026 18:12
@mstange mstange force-pushed the stacktable-prefix-offset branch from b581752 to 2b6a379 Compare June 18, 2026 17:34
The `prefix` column of both `RawStackTable` and `StackTable` is now an
`Int32Array`, with `-1` (instead of `null`) indicating that a stack node is a
root. The wire format changes accordingly, so the processed profile version is
bumped to 63 with an upgrader that converts the column on load.
@mstange mstange force-pushed the stacktable-prefix-offset branch from 2b6a379 to c8f1a69 Compare June 18, 2026 17:49
@mstange mstange marked this pull request as ready for review June 18, 2026 17:50
@mstange mstange requested a review from canova June 18, 2026 17:50
@mstange mstange force-pushed the stacktable-prefix-offset branch from c8f1a69 to 74b6c2e Compare June 18, 2026 17:56
@mstange

mstange commented Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

This is now ready for review.

@canova, how do you feel about this? People will have to change any code that generates profiles, but I actually think the changes would be pretty straightforward and non-controversial.

Also, I can fold the two versions into one if you'd prefer that, so that we don't have an intermediate version that uses -1 values.

Replace `RawStackTable.prefix` with a `prefixOffset` column. For each
stack i, `prefixOffset[i] === 0` means i is a root, and `prefixOffset[i]
=== k` (with k > 0) means i's parent is at index i - k. All values are
non-negative because the stack table is stored in topological order.

The motivation is profile size: relative offsets are typically small numbers
(stack depth) instead of large absolute indexes, so they compress better in
the on-wire JSON. The derived `StackTable.prefix` keeps its absolute Int32Array
representation for consumers that prefer that form.
@mstange mstange force-pushed the stacktable-prefix-offset branch from 74b6c2e to 610f1a9 Compare June 18, 2026 18:04
@mstange

mstange commented Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

When we compute the derived stack table, we turn prefixOffset back into prefix. We could shave off another few milliseconds if the derived stack table also switched to the prefixOffset format, then we wouldn't need to do the conversion. We can do that as a follow-up if we think it's worth doing.

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.

1 participant