Skip to content

Some performance improvements#5878

Merged
mstange merged 6 commits intofirefox-devtools:mainfrom
mstange:push-trrquwtstqkw
Mar 5, 2026
Merged

Some performance improvements#5878
mstange merged 6 commits intofirefox-devtools:mainfrom
mstange:push-trrquwtstqkw

Conversation

@mstange
Copy link
Contributor

@mstange mstange commented Mar 3, 2026

Production | Deploy preview

This PR contains some changes which make it faster to change the selected call node in the call tree. Whenever the selected call node changes, we redraw the activity graph and we compute which information to display in the sidebar.

@mstange mstange requested a review from canova March 3, 2026 18:46
@mstange mstange self-assigned this Mar 3, 2026
@mstange mstange force-pushed the push-trrquwtstqkw branch 4 times, most recently from f48f421 to f4e1be1 Compare March 3, 2026 19:10
@codecov
Copy link

codecov bot commented Mar 3, 2026

Codecov Report

❌ Patch coverage is 94.73684% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.42%. Comparing base (a580c09) to head (23fea36).
⚠️ Report is 10 commits behind head on main.

Files with missing lines Patch % Lines
src/profile-logic/profile-data.ts 92.85% 4 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5878   +/-   ##
=======================================
  Coverage   85.41%   85.42%           
=======================================
  Files         321      321           
  Lines       32036    32073   +37     
  Branches     8815     8821    +6     
=======================================
+ Hits        27364    27398   +34     
- Misses       4241     4244    +3     
  Partials      431      431           

☔ View full report in Codecov by Sentry.
📢 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.

Copy link
Member

@canova canova left a comment

Choose a reason for hiding this comment

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

Looks good to me, thanks! Fewer branches FTW!

* A helper function for creating a new StackTable.
*
* The caller passes in the prefix column of the new StackTable,
* and a bitset about which stacks to "discard". Then this function
Copy link
Member

Choose a reason for hiding this comment

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

"discard"

nit: The comment mentions that the bitset is about which stacks to discard, but the function takes keepStack bitset which is the inverted version.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, thanks for catching that.

stackIndex === null
? greyCategoryIndex
: stackTable.category[stackIndex];
const category = samples.category[i];
Copy link
Member

Choose a reason for hiding this comment

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

Nice fewer branches!

Copy link
Contributor Author

@mstange mstange Mar 5, 2026

Choose a reason for hiding this comment

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

Yes, fewer branches, but more importantly less memory traffic. Now it reads one byte per sample instead of 16 bytes (8 bytes for the stack + 8 bytes for the category), and it reduces the number of dependent loads.

// Derived from RawStackTable + FrameTable
category: IndexIntoCategoryList[];
subcategory: IndexIntoSubcategoryListForCategory[];
category: Uint8Array<ArrayBuffer>; // represents a Map<IndexIntoStackTable, IndexIntoCategoryList>
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if it's worth documenting this new 256 limitation now. But I'm not so sure where. Ideally this should be a safe number, but let's see if there will be an importer that has a lot of categories that we don't know of 😄 But at least it's good that we are showing a console error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I'm hoping that our hardcoded set of category colours makes it so that people aren't tempted to create a high number of categories; lots of them would end up with the same colour.

mstange added 6 commits March 5, 2026 15:10
Create the newPrefixCol first, and then, once we know the new stackTable length
and the remapping, compute the other columns from the remapping.
…le, and use the new column during activity graph drawing.
We are iterating over the filtered samples, which were already constrained
to the zoomed range. Checking the time again might be useful to handle
error cases where samples not sorted by time and the range filtering didn't
work properly, but I don't think that's useful either; _accumulateInBuffer
will make sure to never write outside of its bounds.
@mstange mstange force-pushed the push-trrquwtstqkw branch from f4e1be1 to 23fea36 Compare March 5, 2026 20:12
@mstange mstange enabled auto-merge March 5, 2026 20:12
@mstange mstange merged commit 54536aa into firefox-devtools:main Mar 5, 2026
19 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