Skip to content

perf(avsynctest): improve video rendering performance - #161

Open
souravpaul98 wants to merge 1 commit into
NVIDIA:mainfrom
souravpaul98:perf/avsynctest-parallel-rendering
Open

souravpaul98 wants to merge 1 commit into
NVIDIA:mainfrom
souravpaul98:perf/avsynctest-parallel-rendering

Conversation

@souravpaul98

Copy link
Copy Markdown
Contributor

Summary

avsyncvideotestsrc can now render v210 and UYVP frames across row ranges. The new n-threads property defaults to 1 (the source thread). Set it to N > 1 to use up to N rendering worker threads, or 0 for automatic mode, which uses about one worker per megapixel, capped by the available CPUs and the frame height.

Worker creation failure is reported as a GStreamer error. Packed pixels, timestamps, and ANC metadata stay the same across worker counts and across a restart.

Performance

3840×2160, 60 fps caps, release builds, fakesink sync=false. Each case is 600 frames × 3 trials. is-live=false, so FPS is generation throughput. CPU% is process CPU (100% = one logical CPU). RAM is the highest peak resident set across the three runs.
Host: Intel Xeon Silver 4514Y (16 cores / 32 threads), GStreamer 1.24.2, Rust 1.92. Automatic mode selected 8 workers.

Format Packer Median FPS FPS range CPU% Peak RAM Speedup
v210 main (single-thread) 50.0 40.2–50.7 100.0% 71.9 MiB 1.00×
v210 This PR, n-threads=1 82.1 81.7–83.1 100.0% 72.1 MiB 1.64×
v210 This PR, n-threads=0 (auto) 342.7 328.0–357.1 629.8% 70.6 MiB 6.85×
UYVP main (single-thread) 58.3 51.2–60.2 100.0% 68.5 MiB 1.00×
UYVP This PR, n-threads=1 58.8 54.3–63.2 100.0% 68.5 MiB 1.01×
UYVP This PR, n-threads=0 (auto) 287.8 286.6–289.3 622.4% 65.9 MiB 4.94×

Automatic mode raises median throughput by 6.85× for v210 and 4.94× for UYVP, using about 6.3 logical CPUs. Single-threaded UYVP is unchanged. Single-threaded v210 is 1.64× the previous packer. Peak RAM does not grow.

@souravpaul98
souravpaul98 force-pushed the perf/avsynctest-parallel-rendering branch from b1b55a2 to dc1c6dc Compare November 12, 2026 09:19
Every row of the v210 and UYVP test pattern is the same, so pack only
the first row and copy it into the rest of the frame. At 3840x2160 on
one CPU this generates frames about five to six times as fast as
packing every row.

Fill the stride padding after the last packing group with zeros. It
previously kept whatever bytes were left in the pooled buffer, so the
output now repeats exactly across restarts. A new test checks the
frames, timestamps and ANC metadata across a restart.

Signed-off-by: Sourav Paul <sopaul@nvidia.com>
Co-authored-by: Gareth Sylvester-Bradley <garethsb@nvidia.com>
Signed-off-by: Gareth Sylvester-Bradley <garethsb@nvidia.com>
@garethsb
garethsb force-pushed the perf/avsynctest-parallel-rendering branch from dc1c6dc to ddcefe5 Compare November 12, 2026 10:04
@garethsb

Copy link
Copy Markdown
Collaborator

I've force-pushed a reworked version of this onto the branch, keeping you as author.

Every row of the v210 and UYVP pattern is the same, because luma_at depends only on x. So the new version packs the first row, zeroes the stride padding, and copies that row into the rest of the frame. It doesn't use threads, so I removed n-threads.

I measured with your setup (3840×2160, 60/1, 600 frames, fakesink sync=false, release builds), on a Core Ultra 7 165H under WSL2:

Format main This PR, n-threads=1 This PR, n-threads=0 (8 workers) Copy first row, 1 thread
v210 91 fps about 170 fps about 450 fps about 535 fps
UYVP 109 fps about 108 fps about 435 fps about 560 fps

The output is byte-for-byte identical to your version for both formats, at 1030×1021 and at 4K. On this laptop the threaded runs used less total CPU than the single-threaded one, so I wouldn't rely on its thread speedups. The copy-first-row version still uses one CPU and is faster.

The zeroed padding and your restart test are kept. Before, the padding held whatever was left in the pooled buffer. The test no longer loops over thread counts. If we later want a pattern that varies by row, we can bring back the threaded rendering from this PR's history.

@garethsb garethsb changed the title perf(avsynctest): add opt-in parallel video rendering perf(avsynctest): improve video rendering performance Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants