Closed Bug 1912019 Opened 6 months ago Closed 4 months ago

Experiment with a custom allocator for the contents of the built frame

Categories

(Core :: Graphics: WebRender, task, P3)

task

Tracking

()

RESOLVED FIXED
132 Branch
Tracking Status
firefox132 --- fixed

People

(Reporter: nical, Assigned: nical)

References

(Regressed 1 open bug)

Details

Attachments

(6 files, 1 obsolete file)

The goal is to avoid expensive allocations in the frame builder thread and expensive deallocations on the renderer thread when the built frame is dropped.

The idea is to use simple and fast bump allocators to for anything that is allocated on the render backend thread, sent to the renderer and have the same lifetime as the frame (all of them are dropped along with the frame).

There are a fair amount of other types of allocations on the render backend thread (mostly longer lived allocations that stay on the RB thread to describe retained state and cached). These will not be affected by this work.

The WIP prototype uses allocator_api2.

Attached file WIP: Bug 1912019 - WIP - Use FrameVec. (obsolete) —

The safety of this allocator relies on it counting allocations and deallocations.
When the allocator is dropped or reset, the live allocation count is checked and failure to deallocate all live allocations in time crashes the process.
The allocator is created on the render backend thread, where allocations are made and sent along with the frame to the renderer thread where the frame is read. As soon as a new frame comes in to replace the current one, all of the current frame's allocations are dropped along with it. It is then safe to dispose of the allocator's memory or reset and reuse the allocator.
The allocator move between threads (along with its allocations) but is never used concurrently from multiple threads.

Depends on D218729

Attempting to use malloc_size_of with allocations that aren't directly backend by the global allocator crashes, so this commits compute the render task's report by in a more manual way.
In addition, add the allocator's memory footprint to memory reports.

Depends on D219269

Depends on D219270

Attachment #9418111 - Attachment is obsolete: true
Attachment #9419285 - Attachment description: WIP: Bug 1912019 - Add FrameAllocator, backed by a bump allocator. → Bug 1912019 - Add FrameAllocator, backed by a bump allocator. r=#gfx-reviewers
Attachment #9419286 - Attachment description: WIP: Bug 1912019 - Use FrameVec for most of the frame's vectors. → Bug 1912019 - Use FrameVec for most of the frame's vectors. r=#gfx-reviewers
Attachment #9419287 - Attachment description: WIP: Bug 1912019 - Don't use malloc_size_of for the render task graph. → Bug 1912019 - Don't use malloc_size_of for the render task graph. r=#gfx-reviewers
Attachment #9419288 - Attachment description: WIP: Bug 1912019 - Work around serde(skip) → Bug 1912019 - Work around serde(skip). r=#gfx-reviewers
Attachment #9418110 - Attachment description: WIP: Bug 1912019 - (Do not land) Add dependency to allocator_api2. → Bug 1912019 - Add a dependency to allocator_api2. r=glandium
Attachment #9418110 - Attachment description: Bug 1912019 - Add a dependency to allocator_api2. r=glandium → Bug 1912019 - Add a modified dependency to allocator_api2. r=glandium

WebRender depends on allocator-api2 now.

Attachment #9418110 - Attachment description: Bug 1912019 - Add a modified dependency to allocator_api2. r=glandium → Bug 1912019 - Add a dependency to allocator_api2. r=glandium
Attachment #9418110 - Attachment description: Bug 1912019 - Add a dependency to allocator_api2. r=glandium → Bug 1912019 - Add a modified dependency to allocator_api2. r=glandium
Pushed by nsilva@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/3521a2abcbfb Add a modified dependency to allocator_api2. r=supply-chain-reviewers https://hg.mozilla.org/integration/autoland/rev/f7a971f4161e Add FrameAllocator, backed by a bump allocator. r=gfx-reviewers,lsalzman https://hg.mozilla.org/integration/autoland/rev/30c81d683bef Use FrameVec for most of the frame's vectors. r=gfx-reviewers,lsalzman https://hg.mozilla.org/integration/autoland/rev/80057a2b320b Don't use malloc_size_of for the render task graph. r=gfx-reviewers,lsalzman https://hg.mozilla.org/integration/autoland/rev/e3195c10d336 Work around serde(skip). r=gfx-reviewers,lsalzman,ErichDonGubler https://hg.mozilla.org/integration/autoland/rev/5c0408e2fee2 Undo the gpu-descriptor crate override. r=ErichDonGubler,supply-chain-reviewers
Regressions: 1920678
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: