Skip to content

Reduce descriptor contention during parallel command-list recording on macOS - #169

Merged
pragyaangaur merged 3 commits into
pragyaangaur:mainfrom
gdemontalivet:perf/macos-list-recording
Nov 26, 2026
Merged

pragyaangaur merged 3 commits into
pragyaangaur:mainfrom
gdemontalivet:perf/macos-list-recording

Conversation

@gdemontalivet

Copy link
Copy Markdown
Contributor

Ports the generated command-list recording benchmark and descriptor contention fixes by 0xkn0wh3r3. The benchmark records real host draws and dispatches from five threads using hand-assembled shaders. It runs as an ignored test. Upstream benchmark #2820 · Upstream optimization #2821

Descriptor writers can share registry lookups. A per-slot atomic record lets the common case reuse a materialized descriptor. It costs eight additional bytes per title slot. The slow path re-reads the guest slot after acquiring the materialization lock, and eviction takes that lock before selecting the slots to clear.

Measurements on an M5 Max

On a macOS integration branch using CrossOver Preview and D3DMetal, five alternating pairs of release benchmark runs reduced median wall time for all recording threads from 18.82 to 11.48 ms per fixture frame. Each run executed 19,200 draws and 600 dispatches with zero drops (five threads, 640 draws per thread per frame, six frames). The candidate was faster in all five pairs.

A separate checkpoint comparison used one instrumented game run per variant, with the same starting checkpoint, cache and settings at 720p output. Across world frames +8 to +90, throughput went from 0.76 to 1.08 FPS. Over +48 to +90 it went from 0.60 to 0.87 FPS. The median of the reported per-frame aggregate descriptor-writer wait fell from 209.2 ms to 0.1 ms (19 control samples and 13 candidate samples). The scene still exhibited the existing overexposure. Run-to-run streaming and shader work can vary.

Verification on this PR branch

  • Native serial workspace suite passed 454 tests.
  • CrossOver debug GPU suite with diagnostics passed 232 tests, with two ignored.
  • Explicitly running the ignored benchmark on the PR build executed 320 draws and 10 dispatches with zero drops.
  • cargo xtask policy passed for 217 files.

Adapt Marvisak/VIctory#2821 for the Mac test branch. Revalidate the title slot under the materialization lock and serialize eviction with slot rebinding.
@pragyaangaur

Copy link
Copy Markdown
Owner

Thanks, the lock changes look careful. This now conflicts with #165 (both change find and the BUFFERS lock in shadow.rs) and with the open descriptor PRs #145, #151, #174, #191 and #192. Please say which order you want these in, then rebase onto main once the earlier ones land, so CI can run on a clean branch.

@pragyaangaur
pragyaangaur merged commit c0bd645 into pragyaangaur:main Nov 26, 2026
1 check passed
@pragyaangaur

Copy link
Copy Markdown
Owner

I merged main into this branch. The conflicts were in descriptor.rs, where I kept the read-write lock on SHADER_HEAPS and used main's register_heap and unregister_heap (registration now happens after the heap is handed out), and in shadow.rs, where find now uses main's enclosing lookup with the longest-span bound on both the read and the write path, so the old innermost helper is gone. CI passed and the PR is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:gpu Host GPU runtime: resources, copies, presenting d3dmetal A difference in Apple's D3DMetal

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants