Closed Bug 2094798 Opened 4 days ago Closed 1 day ago

WebGPU should tell garbage collection / cycle collection that GPUDevices are expensive

Categories

(Core :: Graphics: WebGPU, defect, P1)

defect

Tracking

()

RESOLVED FIXED
163 Branch
Tracking Status
firefox163 --- fixed

People

(Reporter: jimb, Assigned: jimb)

References

Details

Attachments

(1 external file)

WebGPU CTS test runs that create many GPUDevices can run out of memory because cycle collection takes too long to get around to freeing them.

For example, the fix for bug 1870699 caused the webgpu:api,validation,capability_checks,limits,maxInterStageShaderVariables:createRenderPipeline,at_over:* test to start encountering the error:

assert_unreached:
EXCEPTION: OperationError: Not enough memory left.
Reached unreachable code

As explained in this comment, we suspect that this is because 1870699 allowed the test to make progress faster than usual, such that GC/CC did not naturally clean up GPUDevices from prior test variants.

To address this, we should give GC/CC a more accurate assessment of the memory cost of a GPUDevice.

Preparation for bug 1870899, poll from a thread:

A device's GPU-side resources are freed only when its id is dropped,
which waits for its GPUDevice to be garbage collected, even if content
has already called destroy(). With polling no longer tied to a 100ms
timer, device.lost resolves promptly after destroy(), so tests that
create and destroy many devices run much faster. On Windows,
webgpu:api,validation,capability_checks,limits,maxInterStageShaderVariables:createRenderPipeline,at_over:*
then fails: partway through, requestDevice starts reporting "Not
enough memory left", and soon does so for every remaining subcase. It
seems that destroyed devices accumulate faster than garbage collection
frees them.

Following the precedent of CommandEncoder (bug 1963926), overload
BindingJSObjectMallocBytes for Device to associate 32 MiB with each
GPUDevice wrapper, roughly the size of the shader-visible descriptor
heap that wgpu-hal's D3D12 backend allocates for every device. This makes
the JS engine schedule garbage collection sooner when many devices are
created.

Assignee: nobody → jimb
Status: NEW → ASSIGNED
See Also: 1870966 → 1870699

try push against the parent commit, for comparison.

See Also: → 2094974
See Also: → 2094973
Pushed by jblandy@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/8881e293ed85 https://hg.mozilla.org/integration/autoland/rev/e77fd83604f8 Associate external memory with each WebGPU device, to encourage GC. r=webgpu-reviewers,aleiserson
Status: ASSIGNED → RESOLVED
Closed: 3 days ago
Resolution: --- → FIXED
Target Milestone: --- → 162 Branch
Pushed by sstanca@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/6d6f414f5eda https://hg.mozilla.org/integration/autoland/rev/55b1289e3236 Revert "Bug 2094798: Associate external memory with each WebGPU device, to encourage GC. r=webgpu-reviewers,aleiserson" for causing webgpu failures.

Reverted this because it was causing webgpu failures.

  • Revert link
  • Push with failures
  • Failure Log
  • Failure line: TEST-UNEXPECTED-FAIL | /_mozilla/webgpu/cts/webgpu/api/validation/image_copy/layout_related/cts.https.html?q=webgpu:api,validation,image_copy,layout_related:required_bytes_in_copy:* | :method="CopyT2B";format="rg16sint";dimension="2d" - assert_unreached:
Status: RESOLVED → REOPENED
Flags: needinfo?(jimb)
Resolution: FIXED → ---
Target Milestone: 162 Branch → ---

Widened the expected fails for mac. Per bug 2094973, this failure is likely to jump around.

try push

Flags: needinfo?(jimb)

Demoting webgpu:api,validation,image_copy,layout_related:required_bytes_in_copy:* to backlog on Mac.
try push

Pushed by jblandy@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/1def13459a52 https://hg.mozilla.org/integration/autoland/rev/5cc6e61f3617 Associate external memory with each WebGPU device, to encourage GC. r=webgpu-reviewers,aleiserson
Status: REOPENED → RESOLVED
Closed: 3 days ago → 1 day ago
Resolution: --- → FIXED
Target Milestone: --- → 163 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: