Repository navigation
perf(rendering): wake macOS surface exports on Metal completion instead of polling - #2648
Merged
Merged
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
macOS hardware exports render each frame into an IOSurface for VideoToolbox. They then waited for the GPU by polling wgpu and sleeping for up to 1 ms per poll. Waking on Metal's own completion handler instead makes exports 18 to 27% faster, with byte-identical output.
sequenceDiagram participant Export participant wgpu participant Metal Export->>wgpu: submit NV12 surface conversion Export->>Metal: commit empty marker command buffer on the same queue Metal-->>Export: marker completed handler (oneshot) Export->>wgpu: one non-blocking poll to retire wgpu's own work Export->>Export: hand the IOSurface to VideoToolboxRgbaToNv12Converter::after_submitcommits an empty command buffer on wgpu's Metal queue, holding the HAL queue lock. Its completed handler sends the buffer status over a oneshot (crates/rendering/src/frame_pipeline.rs:896).PendingNv12Surface::waitawaits the oneshot under the existing export or playback deadline. A marker that completes with an error status, or a dropped handler, still fails withBufferMapWaitingFailed.Export wall time
Apple silicon, release build, 8 interleaved control/candidate pairs per workload, median:
export/basic/*export/jitter-camera-120s/*export/*(full tier) have the same per-frame video MD5s and the same PCM as main's.render_video_to_channel_nv12.🤖 Generated with Claude Code


Confidence Score: 5/5
The PR appears safe to merge; no actionable issues were found.Summary
macOS NV12 surface exports now await a Metal completion signal instead of repeatedly polling
wgpu.Reviews (1) · Last reviewed commit: "fix: wake macOS surface exports on GPU c..." · Reviewed by Greptile