Repository navigation
perf(media-io): read a decompress row once instead of per pixel (#3111) - #3114
Conversation
|
CI on Still a draft for the one thing CI cannot show and this host cannot measure: the Local gate stamp: none. The only host-visible input is |
|
Measurement attempt today (2026-10-31, worker tick, same host, 1.
The two untouched 2. A load-independent metric does not rescue it. I wrapped Criterion's
Two runs of the same binary differing by 30-45% on instruction ratio for conversions this PR does not touch means the counters are being skewed (SMT sibling and a second worker's compile on this host), not that the branch regressed Still a draft: the evidence has to come from a quiet host, and |
|
Blocked: the code and CI are done; only the What unblocks it: one Re-measuring on this checkout again is wasted work; the earlier comment says so and this tick confirms it. |
|
Evidence-lane attempt today (worker tick): a load-independent measurement instead of Criterion wall time. The plan: run one conversion a fixed number of times over one 1080p fixture and count retired user instructions with It did not produce numbers: the local soldr daemon died mid-build, twice, and the build never linked the driver: Two things worth knowing before the next attempt on this box:
Nothing changed in the tree. Still blocked on the same thing as the comment above: one quiet |
The three decompress conversions called the generic Source/Sink traits per pixel: for i420_to_uyvx that was two u8 reads and two u32 writes per output pixel, each one bounds-checked and copied through a fixed-size array, against a C loop that walks row pointers. Measured 1.5-3.2x the C (#3029's baselines). Source gains bytes(offset, len): the row as a slice, once per row, and the pixel loops index it. RawSource builds the slice from the caller's pointer under the same safety contract as read(). The write side stays offset-addressed, because output rows may overlap each other (#3031), but each pair of adjacent pixels is now one 8-byte store like the C's two adjacent uint32_t stores, in the C's order. Parity is unchanged: obs-media-io's 284 lib tests pass, including format_conversion_parity against the C, the _c_scalar stand-ins and the shim, and decompress_422_one_row (the #3031 overlap fixture). Local format ratios (rust/C, best of two record.py runs on a loaded Ryzen 7 3700X; the untouched compress cases move 25% between runs, so this box cannot demonstrate the 1.10 bound): i420_to_uyvx 1.43 -> 0.93 nv12_to_uyvx 1.29 -> 1.17 uyvy_to_uyvx 1.04 -> 1.35 yuy2_to_uyvx 1.28 -> 1.02
f1df319 to
7fedebd
Compare
|
Rebased onto master (
The instruction-count lane does not settle it either — closing that avenueI retried the load-independent idea from the comment above now that the soldr daemon is healthy ( Two-sample slope (samples 40 vs 160, One run per side at identical settings (samples 40, divide the process-wide counter by the reported iteration count) does produce numbers, and they are not believable:
The counter itself is impossible on this host: 32.4 × 10⁹ user instructions for a run whose 1640 iterations take ~1.8 s (≈18 G instr/s), and the derived 1.8–4.2× ratios contradict the ~1.0–1.2× wall-time ratios for the same binary in the same session. Whatever So the PR still stands where it was: code and CI done, |
|
Handed off to the coordinator — green CI Gate, auto-merge enabled from worker tick (obs-studio4). |
What
decompress_420,decompress_nv12anddecompress_422called the genericSource/Sinktraits per pixel — fori420_to_uyvx, twou8reads and twou32writes per output pixel, each bounds-checked and copied through a fixed-size array — where the C walks row pointers and stores*(uint32_t *)dst = y << 16 | uv. That per-pixel call traffic, not arithmetic, is the 1.5-3.2x gap #3111 measured.Refs #3111.
Change
Sourcegainsbytes(offset, len): the row as a slice, built once per row.RawSourcebuilds it from the caller's pointer under the same safety contract asread();[u8]returns a subslice, so it panics the same way on an out-of-bounds row.pair()emits the C's two adjacentuint32_tstores as one 8-byte write, anddecompress_422'sdw/duppair likewise.width_d2 == 0nowcontinues: a zero-length row slice would be taken at an offset that can be past the plane.Parity
obs-media-iolib tests, 284 passed / 0 failed — includingformat_conversion_parity(decompress_420_matches_c,decompress_nv12_matches_c,decompress_422_matches_c,decompress_422_one_row,decompress_422_wrapping_row_offset) and the zero-width case. No test or public header changed.cargo fmt --check -p obs-media-ioclean.Numbers — read the caveat
record.py --category format, two runs per side,--cpu 7, on this worker host (Ryzen 7 3700X under four concurrent worker checkouts). Ratios, rust/C, best of two:i420_to_uyvxnv12_to_uyvxyuy2_to_uyvxuyvy_to_uyvxThis host cannot demonstrate #3111's ≤ 1.10 bound. The compress cases, which this PR does not touch, moved 25% between the two runs (
uyvx_to_i4201.30 vs 3.62,uyvx_to_i4441.61 vs 2.01), so the spread above is dominated by load, and theuyvy_to_uyvx"regression" is the same code asyuy2_to_uyvx. The two signals that do repeat —i420_to_uyvxandyuy2_to_uyvx— both land at/below 1.10, andnv12_to_uyvximproved but is not there yet.Left as a draft for that reason: it needs one quiet measurement on a 5950X-class host (
record.py --category format, the recorded Linux baseline machine) before it can be called done, andnv12_to_uyvxmay need a second pass.Notes
record.py'sformatcategory, andrecord.pyonly recordsthreshold_rust_over_c: 1.10today — it asserts nothing. Adding that gate is a separate change (and it would have to be honest about a loaded host), so this PR carries GREEN evidence plus the parity tests rather than a red run.docs/features.md: no line — the issue states these functions have no caller in OBS (upstream removed the CPU YUV conversion), so they are plugin-API quality, not behaviour a user sees.record.pycould not run at all before that.