Skip to content

Draw bar charts in custom marker tracks faster.#4711

Merged
fqueze merged 2 commits into
firefox-devtools:mainfrom
fqueze:marker-track-speed
Aug 4, 2023
Merged

Draw bar charts in custom marker tracks faster.#4711
fqueze merged 2 commits into
firefox-devtools:mainfrom
fqueze:marker-track-speed

Conversation

@fqueze

@fqueze fqueze commented Aug 1, 2023

Copy link
Copy Markdown
Contributor

Short example profile (about 3k samples) : https://deploy-preview-4711--perf-html.netlify.app/public/kgqe66dn8k0r2k89kbsrxxp7tv1fbahfcgp722r/ (compare with https://main--perf-html.netlify.app/public/kgqe66dn8k0r2k89kbsrxxp7tv1fbahfcgp722r)
Longer example profile (22.5k samples) : https://deploy-preview-4711--perf-html.netlify.app/public/mgtzdc7myr2j56hs2jjnrg68fmsm36g1az8cgx0 (hangs the current main--perf-html.netlify.app; try at your own risk :-)).

The first commit has the most impact here: drawing 1px rectangles is much faster than drawing a line and calling stroke. The second commit saves some redundant work by reducing the number of rectangles when more than one would be starting on the same horizontal pixel.

I only fixed bar charts because it's an easier subset of the problem, and their performance issues will become very noticeable if we land CPU frequency recording and people try playing with that new experimental feature.

It should be possible to also improve the performance of drawing line charts with an approach similar to #4636, but I would prefer to do that in a separate PR to ensure the bar chart perf improvement becomes available sooner.

@codecov

codecov Bot commented Aug 1, 2023

Copy link
Copy Markdown

Codecov Report

Patch coverage: 86.36% and no project coverage change.

Comparison is base (ca152dd) 88.33% compared to head (31fdfe7) 88.34%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4711   +/-   ##
=======================================
  Coverage   88.33%   88.34%           
=======================================
  Files         299      299           
  Lines       26714    26720    +6     
  Branches     7208     7210    +2     
=======================================
+ Hits        23599    23605    +6     
  Misses       2902     2902           
  Partials      213      213           
Files Changed Coverage Δ
src/components/timeline/TrackCustomMarkerGraph.js 74.35% <86.36%> (+0.57%) ⬆️

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

@fqueze fqueze requested a review from canova August 1, 2023 15:03

@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.

It's a very big difference in the performance, thanks!

Looks good to me with the Math.max/min comment I mentioned below.

)
: x + 1;

ctx.fillRect(x, y, x2 - x, deviceHeight - y);

@canova canova Aug 4, 2023

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.

Nice improvement, thanks for investigating this!

}

marker = nextMarker;
y = Math.min(y, getY(++i));

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.

Don't we want to get the max value with the Math.max here instead of min?

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.

We want the max value, which (unless I'm confused) is the min y (as y = 0 would mean top of the canvas).

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.

Oh welp right, I was the one who's confused not you. Sorry about the confusion!

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