Repository navigation
perf(obs-ffmpeg): send a mux packet up to 64 KiB in one pipe write (#3211) - #3361
Merged
Merged
Conversation
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.
Fixes #3211
RED b7993d7: a new cmocka test,
test_ffmpeg_mux_write_packet, buildsobs-ffmpeg-mux.cand wrapsos_process_pipe_write(--wrap) to count calls and capture bytes. Against unchanged code it fails with2 != 1for a 400-byte packet and a 64 KiB packet; the 150 KB case passes.GREEN e3a9abe:
write_packetcopies theffm_packet_infoheader and a packet of up to 64 KiB into a reused per-stream buffer (packet_buf, freed in destroy) and makes oneos_process_pipe_write. Larger packets keep two writes, since copying them costs more than the syscall saved. The helper receives the same byte stream either way; the test checks the header fields and the data byte for byte. All 3 cases pass.Why it matters: the shipped
os_process_pipe_writeis Rust (rust/obs-util/src/platform/unix/pipe.rs) and writes straight to the child's stdin with no buffering. Each call is onewrite(2). C'sfwriteused to batch small packets in the stdio buffer.Measured:
writecalls per packet drop from 2 to 1 for packets of up to 64 KiB. That covers every audio packet and most video P-frames at common bitrates. I did not run thestrace -cover a 60 s recording that the issue asks for: this box can't run a headless OBS recording session. The per-packet syscall count above is what the test verifies.Tiers: plugin C only, no public header or libobs change. Tier 2: the new test; it runs on Linux. Tiers 1, 3 and 4 do not apply (no Rust or protocol change).
./lintpasses.