Closed Bug 1859736 Opened 2 years ago Closed 2 years ago

Vec allocation time is too high in WGR::PathBuilder

Categories

(Core :: Graphics: Canvas2D, defect)

defect

Tracking

()

RESOLVED FIXED
121 Branch
Tracking Status
firefox121 --- fixed

People

(Reporter: jnicol, Assigned: jnicol)

References

(Blocks 1 open bug)

Details

(Whiteboard: [sp3])

Attachments

(2 files)

GenerateQuantizedPath() shows up in profiles of Charts-chartjs: https://share.firefox.dev/48T9STP (and Perf-Dashboard too)

This is mostly caused by reallocs when push()ing items in to the points and types vectors, eg in curve_to(). Then much less significantly in get_path() calling Vec::into_boxed_slice() causes the vectors' storages to be realloced to the exact size.

If we allocate a single PathBuilder in DrawTargetWebgl::SharedContext and reset it between uses, whilst persisting the Vec storage, then we can effectively reduce this just to allocating the Boxed slices in PathBuilder::get_path()

Unfortunately this doesn't translate to a win in the test overall, as the improvements it leads to in the sync portions are undone by an increased wait in ClientWebGLContext::GetFrontBuffer() in the async step. See profile. Which is unfortunate, but this still seems worthwhile fixing anyway.

We could go even further and provide nsTArray/thin_vecs from the gecko side, only needing additional allocs/copies when there is a cache miss in PathCache::FindOrInsertEntry. But given this will need invasive API changes and the gains will be eaten up by the sync texture wait anyway, I don't think that's a good idea.

DO NOT LAND: Change back to FirefoxGraphics repo after
https://github.com/FirefoxGraphics/wpf-gpu-raster/pull/2 has been
merged

This avoids some expensive vector reallocations.

Depends on D191282

Whiteboard: [sp3]
Pushed by jnicol@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/92dd9aca656c Update wpf-gpu-raster. r=gfx-reviewers,lsalzman https://hg.mozilla.org/integration/autoland/rev/da6a29fc726b Reuse WGR::PathBuilder instance in DrawTargetWebgl. r=gfx-reviewers,lsalzman https://hg.mozilla.org/integration/autoland/rev/baf6a4468415 apply code formatting via Lando
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: