Skip to content

Convert eligible columns to typed arrays when outputting from profiler-edit#6167

Merged
mstange merged 2 commits into
firefox-devtools:mainfrom
mstange:push-ynskzmwyrxpm
Jul 13, 2026
Merged

Convert eligible columns to typed arrays when outputting from profiler-edit#6167
mstange merged 2 commits into
firefox-devtools:mainfrom
mstange:push-ynskzmwyrxpm

Conversation

@mstange

@mstange mstange commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Main | Deploy preview

profiler-edit runs profile compacting on the output profile, and profile compacting converts some columns to their typed array form but not others - it only touches columns which contain indexes which refer to other tables. So this adds a separate pass over the profile to "optimize the profile for storage".

We'll be able to use this new function for the "upload profile" code path once we switch that to uploading JSLB files; before we make that change, converting to typed arrays would be a waste because serializing to JSON would need to convert them back to regular arrays again.

I had these patches applied when I generated the "after" profile in #6139 (comment) - without this, profiler-edit would have left most of those columns alone and the size profile wouldn't have looked much different.

@mstange mstange requested a review from canova July 10, 2026 22:36
@mstange mstange self-assigned this Jul 10, 2026
@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 30.76923% with 27 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.49%. Comparing base (6963f9e) to head (fe04f38).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/profile-logic/process-profile.ts 0.00% 26 Missing ⚠️
src/node-tools/profiler-edit.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6167      +/-   ##
==========================================
- Coverage   83.55%   83.49%   -0.07%     
==========================================
  Files         343      344       +1     
  Lines       36859    36882      +23     
  Branches    10357    10241     -116     
==========================================
- Hits        30796    30793       -3     
- Misses       5635     5661      +26     
  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.

Comment thread src/profile-logic/profile-data.ts Outdated
Comment on lines +1952 to +1968
export function toInt32Array(
arr: Array<number> | Int32Array<ArrayBuffer>
): Int32Array<ArrayBuffer> {
return arr instanceof Int32Array ? arr : new Int32Array(arr);
}

export function toUint8Array(
arr: Array<number> | Uint8Array<ArrayBuffer>
): Uint8Array<ArrayBuffer> {
return arr instanceof Uint8Array ? arr : new Uint8Array(arr);
}

export function toFloat64Array(
arr: Array<number> | Float64Array<ArrayBuffer>
): Float64Array<ArrayBuffer> {
return arr instanceof Float64Array ? arr : new Float64Array(arr);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I wonder if it's better to move them to a utils file?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I wasn't sure, but I've gone ahead and moved it to src/utils/typed-arrays.ts now.

Comment thread src/profile-logic/process-profile.ts Outdated
Comment thread src/profile-logic/process-profile.ts Outdated
* of the file.
*
* Profile compaction already handles the columns that reference other tables;
* this function handles the remaining eligible columns.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, so this requires the compaction to run before this. I don't love that coupling. Should we include these fields no matter what?

Since the toInt32Array etc. functions that we added already check if they are typed array, it should be no extra cost to add them here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I've made that change.

@mstange mstange force-pushed the push-ynskzmwyrxpm branch from 281bda2 to 3d43eac Compare July 13, 2026 15:35
mstange added 2 commits July 13, 2026 11:41
…r-edit.

profiler-edit runs profile compacting on the output profile, and
profile compacting converts some columns to their typed array form
but not others - it only touches columns which contain indexes which
refer to other tables. So this is done as a separate pass over the profile.

We'll be able to use this new function for the "upload profile" code path
once we switch that to uploading JSLB files; before we make that change,
converting to typed arrays would be a waste because serializing to JSON
would need to convert them back to regular arrays again.
@mstange mstange force-pushed the push-ynskzmwyrxpm branch from 3d43eac to fe04f38 Compare July 13, 2026 15:45
@mstange mstange requested a review from canova July 13, 2026 15:46

@canova canova left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@mstange mstange merged commit 4129c72 into firefox-devtools:main Jul 13, 2026
21 of 23 checks passed
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.

2 participants