Repository navigation
Conversation
93b5971 stopped the NV12 readback wait from sleeping in tokio's 1 ms ticks, but the surface waits macOS (PendingNv12Surface) and Linux external memory (PendingNv12External) export through still slept 100 µs after ten polls, which tokio rounds up to a millisecond, longer than a frame's GPU work. Spin on yield_now for NV12_READBACK_SPIN first, as the readback wait does, and sleep only once a frame is slow. Only export uses these NV12 waits; the editor's BGRA surface wait is unchanged.
This branch has not been 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.
#2450 stopped the NV12 readback wait from sleeping in tokio's 1 ms ticks. The surface waits that exports actually use were left alone:
PendingNv12Surface::wait: the default macOS export path.PendingNv12External::wait: the Linux external-memory path.Both still yield ten times, then sleep 100 µs at a time. tokio rounds that up to a full millisecond, longer than a frame's GPU work, so whenever the previous frame's GPU work takes longer than about ten polls, the render loop wakes up late.
This PR uses the same pattern as the readback wait: spin on
yield_nowforNV12_READBACK_SPIN, then sleep only once a frame is slow. Only export (and the render farm and examples) use these NV12 waits. The editor's BGRAPendingSurfacewait is untouched, so playback doesn't start spinning.Results
Measured with the
capCLI on an M5 Max, macOS 27. The source is a real 61 s, 3006×1480, 60 fps Studio recording. The command wascap export … --fps 60 --quality social, with 5 interleaved runs per case; medians are shown.The gain shows up whenever export is render-bound, as at 720p here. 1080p and 4K on this machine are limited by the VideoToolbox encoder instead. Total CPU time went down at 720p, because less time is spent waiting.
A useful cross-check: before this change,
CAP_EXPORT_DISABLE_ZERO_COPY=1(the readback path, which already had the fix) was faster than the default zero-copy path, at 5.56 s vs 5.95 s, despite its extra copies.Correctness
inf, both have 3210 frames, and the decoded YUV md5 matches.cargo test -p cap-rendering --lib: 296 passed.cargo clippy -p cap-rendering -- -D warningsis clean.