You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
perf: obs-ffmpeg-mux: one write per packet on the mux pipe #3211
plugins/obs-ffmpeg/obs-ffmpeg-mux.c.h:615-622 writes the info header and the data separately (util/pipe-posix.c.h:182-194): two syscalls for large packets.
Proposed change
writev on the raw fd, or coalesce small headers.
Acceptance criteria
Before/after numbers (strace -c -e write on ffmpeg-mux over 60 s) in the PR; nothing lands unmeasured.
RED then GREEN; Tier 3 parity stays bit-exact unless this issue says otherwise.
Found by a read-only code scout and not yet measured. Parent: #3176.
Claiming: perf: obs-ffmpeg-mux one write per packet on the mux pipe
What I found: the shipped os_process_pipe_write is Rust (rust/obs-util/src/platform/unix/pipe.rs). It writes straight to the child's stdin with no buffering, so every packet costs two write syscalls: the 32-byte ffm_packet_info, then the data. That includes small audio packets, which the C fwrite used to coalesce in its stdio buffer.
Plan, one PR:
RED: a new cmocka test that compiles obs-ffmpeg-mux.c.h against a counting os_process_pipe_write and checks one call per packet below the threshold, and that the child receives the same byte stream (info, then data).
GREEN: write_packet copies the info and the data into a reused per-stream buffer and makes one os_process_pipe_write when the packet is at most 64 KiB. Larger packets keep the two writes, since a copy of a large packet costs more than the syscall it saves. No public header and no pipe semantics change.
Numbers: syscalls per packet, and strace -c -e write on a short headless recording if I can run one here; I'll say so if not.
Decisions: no new libobs API (a writev export would need a public header), so the coalescing stays in the plugin. First PR next tick.
Activity
zackees commentedon Oct 31, 2026
/ready
zackees commentedon Nov 1, 2026
Claiming: perf: obs-ffmpeg-mux one write per packet on the mux pipe
What I found: the shipped
os_process_pipe_writeis Rust (rust/obs-util/src/platform/unix/pipe.rs). It writes straight to the child's stdin with no buffering, so every packet costs twowritesyscalls: the 32-byteffm_packet_info, then the data. That includes small audio packets, which the Cfwriteused to coalesce in its stdio buffer.Plan, one PR:
obs-ffmpeg-mux.c.hagainst a countingos_process_pipe_writeand checks one call per packet below the threshold, and that the child receives the same byte stream (info, then data).write_packetcopies the info and the data into a reused per-stream buffer and makes oneos_process_pipe_writewhen the packet is at most 64 KiB. Larger packets keep the two writes, since a copy of a large packet costs more than the syscall it saves. No public header and no pipe semantics change.strace -c -e writeon a short headless recording if I can run one here; I'll say so if not.Decisions: no new libobs API (a
writevexport would need a public header), so the coalescing stays in the plugin. First PR next tick.linux-pulseaudio: Follow the default device (obs-rust#2271)
perf(obs-ffmpeg): send a mux packet up to 64 KiB in one pipe write (o…