Skip to content

Replace child count with "has children"#4829

Merged
mstange merged 3 commits into
firefox-devtools:mainfrom
mstange:no-childcount
Dec 4, 2023
Merged

Replace child count with "has children"#4829
mstange merged 3 commits into
firefox-devtools:mainfrom
mstange:no-childcount

Conversation

@mstange

@mstange mstange commented Dec 4, 2023

Copy link
Copy Markdown
Contributor

Main | Deploy preview

Small simplification for the call tree timings, with a little bonus perf at the end.

@mstange mstange requested a review from julienw December 4, 2023 16:28
@mstange mstange self-assigned this Dec 4, 2023
@codecov

codecov Bot commented Dec 4, 2023

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (9fd444c) 88.30% compared to head (3c9a966) 88.30%.

❗ Current head 3c9a966 differs from pull request most recent head 64d6cc8. Consider uploading reports for the commit 64d6cc8 to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4829   +/-   ##
=======================================
  Coverage   88.30%   88.30%           
=======================================
  Files         301      301           
  Lines       26968    26968           
  Branches     7290     7290           
=======================================
  Hits        23814    23814           
  Misses       2936     2936           
  Partials      218      218           

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

@julienw julienw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

thanks!

Comment thread src/profile-logic/call-tree.js Outdated
callNodeTotalSummary[prefixCallNode] +=
callNodeTotalSummary[callNodeIndex];
callNodeChildCount[prefixCallNode]++;
callNodeHasChildren[prefixCallNode]++;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

do we want = 1 here? (for consistency mostly, but also to avoid overflow)

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.

Oops, yes, that was the intent. Thanks for catching it!


hasChildren(callNodeIndex: IndexIntoCallNodeTable): boolean {
return this.getChildren(callNodeIndex).length !== 0;
return this._callNodeHasChildren[callNodeIndex] !== 0;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I guess we could have used the previous childCount too, but I'm not opposed to changing childCount to hasChildren

We no longer need the child count, because the call tree's getChildren()
method now uses nextSibling to find the children, so it doesn't need the
child count any more for ending the search early.
And the new flame graph implementation has dropped the other use of the
child count.

Having just one byte per call node rather than four bytes might improve
the performance of computeCallTreeCountsAndSummary slightly, because it
needs to touch fewer bytes in memory.
This avoids calls to getChildren for nodes which are visible but not expanded.
The tree view calls hasChildren in order to determine whether to show the
disclosure arrow.
Avoiding the call to getChildren means that we don't have to allocate the
array and sort it. This is especially useful in the inverted tree, which
has lots of non-expanded nodes at the root level.
@mstange mstange merged commit 1b08327 into firefox-devtools:main Dec 4, 2023
@julienw julienw mentioned this pull request Dec 5, 2023
@mstange mstange added the perf Issues where the profiler itself is slow. label Dec 7, 2023
mstange added a commit to mstange/perf.html that referenced this pull request Jan 20, 2024
I missed this in firefox-devtools#4829; the changes there made this field unnecessary.
mstange added a commit to mstange/perf.html that referenced this pull request Jan 22, 2024
This seems to have been unused for a while now. Initially I thought I
had missed this in firefox-devtools#4829, but it seems to have been unused even before
then.
mstange added a commit to mstange/perf.html that referenced this pull request Jan 23, 2024
This seems to have been unused for a while now. Initially I thought I
had missed this in firefox-devtools#4829, but it seems to have been unused even before
then.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

perf Issues where the profiler itself is slow.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants