forge
Explore
Log in

Don't you dare go Hollow

Snapshot the remaining per-pixel EC_* env reads

Browse files at this commit

2baca5a6872e22e959ab60b7c27d48a29a02909dAhmet Kaan GümüşParent: 4256150
  • perf
    • snapshot the remaining per-pixel EC_* env reads
Show full message
perf(av1): snapshot the remaining per-pixel EC_* env reads

`restoration.rs`'s three `EC_LR_CALL_DUMP` guards sit inside the sgrproj
per-pixel loops (`compute_ab`, the combine tap) and `warp.rs`'s
`EC_MC_TRACE` on the per-MC-call warp entry; each was a live `getenv` +
`strlen` + `CStr` validation, 17.75% of `decode_probe`'s self time at 4K.
Same predicates, served by `envflags::env_flag!` (one `LazyLock<bool>`
per call site). `motion_field.rs`'s two `EC_TRACE_TPL` reads move with
them. `tile.rs`'s two sites stay: :34 already caches into an atomic and
:3002 is test-only.

Byte-exact on seg1080/seg4k/seg4k_lr/palette; 4K 55.31 s -> 48.53 s
(interleaved medians of 3), 1080p 10.54 s -> 9.83 s.
crates/ec-av1/src/motion_field.rsmodified+2 -2
@@ -461,7 +461,7 @@ pub fn setup_motion_field(
461 );461 );
462 }462 }
463 463
464- if std::env::var_os("EC_TRACE_TPL").is_some() {464+ if crate::envflags::env_flag!("EC_TRACE_TPL") {
465 eprintln!("EC_TPL_FIELD oh={cur_order_hint} rows={rows} cols={cols}");465 eprintln!("EC_TPL_FIELD oh={cur_order_hint} rows={rows} cols={cols}");
466 for r in 0..rows {466 for r in 0..rows {
467 let row: String = (0..cols)467 let row: String = (0..cols)
@@ -516,7 +516,7 @@ pub fn add_tpl_ref_mv(
516 return None;516 return None;
517 }517 }
518 let probe = tpl.get(row8 as usize / 2, col8 as usize / 2);518 let probe = tpl.get(row8 as usize / 2, col8 as usize / 2);
519- if std::env::var_os("EC_TRACE_TPL").is_some() {519+ if crate::envflags::env_flag!("EC_TRACE_TPL") {
520 match probe {520 match probe {
521 None => eprintln!("EC_TPL mi_row={mi_row} mi_col={mi_col} blk=({blk_row},{blk_col}) INVALID"),521 None => eprintln!("EC_TPL mi_row={mi_row} mi_col={mi_col} blk=({blk_row},{blk_col}) INVALID"),
522 Some((m, rfo)) => eprintln!(522 Some((m, rfo)) => eprintln!(
crates/ec-av1/src/restoration.rsmodified+3 -3
@@ -705,7 +705,7 @@ fn compute_ab(
705 (256 - a_val) as i64 * b * SGR_ONE_BY_X[(n - 1) as usize] as i64,705 (256 - a_val) as i64 * b * SGR_ONE_BY_X[(n - 1) as usize] as i64,
706 SGRPROJ_RECIP_BITS,706 SGRPROJ_RECIP_BITS,
707 );707 );
708- if std::env::var("EC_LR_CALL_DUMP").is_ok()708+ if crate::envflags::env_flag!("EC_LR_CALL_DUMP")
709 && v_start as i64 + i == 60709 && v_start as i64 + i == 60
710 && h_start as i64 + j == 6710 && h_start as i64 + j == 6
711 && r == 1711 && r == 1
@@ -759,7 +759,7 @@ fn apply_sgrproj_stripe(
759 // r7 traced (`[-16,-32]`); dump the real 9-byte dense-arm (r1) "u"-tap759 // r7 traced (`[-16,-32]`); dump the real 9-byte dense-arm (r1) "u"-tap
760 // window (physical rows 59..=61, cols 5..=7 -- r7's traced tap) straight760 // window (physical rows 59..=61, cols 5..=7 -- r7's traced tap) straight
761 // from `lr_sample` for this exact call, no coordinate matching involved.761 // from `lr_sample` for this exact call, no coordinate matching involved.
762- if std::env::var("EC_LR_CALL_DUMP").is_ok() && r1 > 0 && info.xqd == [-16, -32] {762+ if crate::envflags::env_flag!("EC_LR_CALL_DUMP") && r1 > 0 && info.xqd == [-16, -32] {
763 let bytes: Vec<i32> = (59..=61)763 let bytes: Vec<i32> = (59..=61)
764 .flat_map(|row| {764 .flat_map(|row| {
765 (5..=7).map(move |col| {765 (5..=7).map(move |col| {
@@ -844,7 +844,7 @@ fn apply_sgrproj_stripe(
844 let b = (b_c + b_u + b_d + b_l + b_r) * 4 + (b_ul + b_ur + b_dl + b_dr) * 3;844 let b = (b_c + b_u + b_d + b_l + b_r) * 4 + (b_ul + b_ur + b_dl + b_dr) * 3;
845 let flt1 = round2(a * dgd + b, SGRPROJ_SGR_BITS + 5 - SGRPROJ_RST_BITS);845 let flt1 = round2(a * dgd + b, SGRPROJ_SGR_BITS + 5 - SGRPROJ_RST_BITS);
846 v += xq[1] as i64 * (flt1 - u);846 v += xq[1] as i64 * (flt1 - u);
847- if std::env::var("EC_LR_CALL_DUMP").is_ok()847+ if crate::envflags::env_flag!("EC_LR_CALL_DUMP")
848 && info.xqd == [-16, -32]848 && info.xqd == [-16, -32]
849 && v_start as i64 + i == 61849 && v_start as i64 + i == 61
850 && h_start as i64 + j == 6850 && h_start as i64 + j == 6
crates/ec-av1/src/warp.rsmodified+1 -1
@@ -444,7 +444,7 @@ pub fn warp_affine(
444 subsampling_x: i32,444 subsampling_x: i32,
445 subsampling_y: i32,445 subsampling_y: i32,
446 ) {446 ) {
447- if std::env::var_os("EC_MC_TRACE").is_some() {447+ if crate::envflags::env_flag!("EC_MC_TRACE") {
448 eprintln!("EC_MC_WARP x={p_col} y={p_row} w={p_width} h={p_height}");448 eprintln!("EC_MC_WARP x={p_col} y={p_row} w={p_width} h={p_height}");
449 }449 }
450 let bd = i32::from(crate::decode::bit_depth());450 let bd = i32::from(crate::decode::bit_depth());