From 3a35e5fda4b730e38f9ec7c62360737d22ffda89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Sat, 5 Sep 2026 11:49:31 +0300 Subject: [PATCH] perf(av1): constant-length row copies on the whole-pel inter path A whole-pel prediction is a clamped copy, and its per-row `copy_from_slice` compiled to a `memcpy` call with a runtime length -- for the 8-sample row of an 8x8 block (the most common inter shape on real 4K content) the call costs more than the move it makes. The three common widths get a constant length, which inlines. -0.11% instructions on the 4K segment (523.67 -> 523.07 G at one thread), -5.4% cumulative; all twelve gate hashes unchanged. --- crates/ec-av1/src/mc.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/crates/ec-av1/src/mc.rs b/crates/ec-av1/src/mc.rs index a41d3746..10e364f5 100644 --- a/crates/ec-av1/src/mc.rs +++ b/crates/ec-av1/src/mc.rs @@ -1063,7 +1063,16 @@ pub(crate) fn predict_with_filters_kern( // lane-perf2: an interior row is one contiguous copy. if x0 >= 0 && x0 as usize + block_w <= true_width { if let Some(src) = reference.get(row_base + x0 as usize..row_base + x0 as usize + block_w) { - out.copy_from_slice(src); + // The common widths get a constant-length copy: at 8 + // samples a `memcpy` call costs more than the move it + // makes, and 8x8 is the most common inter block on real + // 4K content. + match block_w { + 4 => out[..4].copy_from_slice(&src[..4]), + 8 => out[..8].copy_from_slice(&src[..8]), + 16 => out[..16].copy_from_slice(&src[..16]), + _ => out.copy_from_slice(src), + } continue; } }