Open Bug 1821937 Opened 2 years ago Updated 2 years ago

CanvasRenderingContext2D::BeginPath() show up in Speedometer 3 canvas (Charts-chartjs, Performance-Dashboard) profiles

Categories

(Core :: Graphics: Canvas2D, defect, P2)

defect

Tracking

()

People

(Reporter: smaug, Unassigned)

References

(Blocks 1 open bug)

Details

(Whiteboard: [sp3])

Looks like at least mPath = nullptr; is causing quite a bit allocator traffic.
Could we reuse some of the objects?
https://searchfox.org/mozilla-central/rev/2ede53e39955988f98db4369f7ce09614b22104a/dom/canvas/CanvasRenderingContext2D.cpp#2842-2843

I used https://speedometer-preview.netlify.app/interactiverunner for running the test, and it is ZoomTheChart-sync part where the BeginPath shows up.

Jeff, would this be at all impacting SP3?

Severity: -- → S3
Flags: needinfo?(jmuizelaar)
Priority: -- → P2

This is all about sp3 ;) React-Stockcharts is part of that.

Can you include a link to the profile? Path objects are immutable so reuse is not so easy or pleasant.

Flags: needinfo?(jmuizelaar) → needinfo?(smaug)
Whiteboard: [sp3]
Flags: needinfo?(smaug) → needinfo?(jmuizelaar)

PathRecording currently keeps two copies of the Path data: mPathOps and mPath. mPath is used for implementing ContainsPoint(), StrokeContainsPoint(), GetBounds() and GetStrokedBounds() however we rarely use these methods. It's probably reasonable to make conversion to mPath on demand instead of eager. That would make recording cheaper and reduce the amount of time spent freeing. It should also help SVG blob performance.

Flags: needinfo?(jmuizelaar)
Depends on: 1447839

Olli, can you get a new profile now that bug 1447839 has landed?

Flags: needinfo?(smaug)

It is better, but still quite (de)allocation heavy: https://share.firefox.dev/400eB1m

Without looking at the code, just the profile:
Would it make sense to not use std::vector, but AutoTArray?
I see also std::unordered_set. Is that possibly more allocator heavy than the hashtables we normally use?

Flags: needinfo?(smaug)

This also shows up on the Charts-chartjs and Perf-Dashboard subtests. Fixing the performance difference with Chrome would improve Firefox's score on these subtests by 0.9% and 0.5% respectively.

Firefox: https://share.firefox.dev/44EoIv0
Chrome: https://share.firefox.dev/3Y5OOV8

Summary: CanvasRenderingContext2D::BeginPath() show up in React-Stockcharts profiles → CanvasRenderingContext2D::BeginPath() show up in Speedometer 3 canvas (Charts-chartjs, Performance-Dashboard) profiles
You need to log in before you can comment on or make changes to this bug.