From 24934ba180ebeff6c499c5b41b7ace8df4736f87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Wed, 9 Sep 2026 20:52:45 +0300 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20perf(app):=20a=20wheel=20n?= =?UTF-8?q?otch=20on=20the=20budget=20opens=20no=20encoder?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The export moment's seat probe was keyed on the whole export settings, bitrate included, so every notch of the wheel invalidated it and opened a real VA-API encoder to ask the seat again — ten opens for ten notches, 5–32 ms of GPU work each, beside the player's own decoder. The bitrate decides none of that answer, so the probe is asked and keyed without it: one probe when the moment opens, none while the wheel turns. --- crates/app/src/export_ui.rs | 15 +++++++++++++++ crates/app/src/player/export.rs | 7 +------ crates/app/src/tests/cards.rs | 29 +++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 6 deletions(-) diff --git a/crates/app/src/export_ui.rs b/crates/app/src/export_ui.rs index d8e7158..e1d64e2 100644 --- a/crates/app/src/export_ui.rs +++ b/crates/app/src/export_ui.rs @@ -663,6 +663,21 @@ pub(crate) fn export_settings( } } +/// The same settings with the budget taken out -- what the seat probe is asked +/// and keyed on ([`crate::Player::cache_export_seat`]). A bitrate does not +/// decide whether this machine has a VA-API seat or whether the picture's +/// packets can be copied; leaving it in the key meant every wheel notch on the +/// budget row invalidated the answer and opened a real VA-API encoder to ask it +/// again -- measured at ten opens for ten notches, 5-32 ms of GPU work each, +/// against the player's own decoder, which is the "freezes a little" this row +/// was reported for. +pub(crate) fn probe_settings(format: Format, audio_kbps: u32, seat: EncoderSeat) -> ExportSettings { + ExportSettings { + bitrate: None, + ..export_settings(0, format, audio_kbps, seat) + } +} + /// The budget's bounds, the engine's own (`engine::export`'s `MIN_BITRATE` /// and `MAX_EXPLICIT_BITRATE`): a number outside them would be written as a /// different one, so the lever and the field clamp to exactly these. diff --git a/crates/app/src/player/export.rs b/crates/app/src/player/export.rs index 5a771da..e18ff05 100644 --- a/crates/app/src/player/export.rs +++ b/crates/app/src/player/export.rs @@ -351,12 +351,7 @@ impl Player { let Some(session) = &self.session else { return; }; - let settings = export_settings( - self.budget_bps(), - self.format, - self.audio_kbps, - self.encoder_seat(), - ); + let settings = probe_settings(self.format, self.audio_kbps, self.encoder_seat()); if !self.export_open { return; } diff --git a/crates/app/src/tests/cards.rs b/crates/app/src/tests/cards.rs index e23a5cd..19acff6 100644 --- a/crates/app/src/tests/cards.rs +++ b/crates/app/src/tests/cards.rs @@ -2006,3 +2006,32 @@ fn toggle_proxy_wakes_the_asked_phase_it_stops() { "a stop asked during Asked no longer sets the flag the header read polls" ); } + +/// A wheel notch on the budget must not re-ask the seat probe. The probe opens +/// a real VA-API encoder (ten opens for ten notches before this, 5-32 ms of GPU +/// work each, against the player's own decoder) and its answer -- GPU seat or +/// software, copy or encode -- does not depend on the bitrate at all. So the +/// settings it is keyed on carry no budget, and the budget still reaches the +/// export itself, which is the one place it changes a file. +#[test] +fn the_seat_probe_is_not_keyed_on_the_budget() { + let seat = EncoderSeat::default(); + let asked = crate::probe_settings(Format::Mp4, DEFAULT_AUDIO_KBPS, seat); + assert_eq!(asked.bitrate, None, "no budget is in the probe's question"); + // What still *is* a new question: the format the file is written in. + assert_ne!( + asked, + crate::probe_settings(Format::Av1, DEFAULT_AUDIO_KBPS, seat), + "a format change must re-probe" + ); + let cache = fn_body("cache_export_seat"); + assert!( + cache.contains("probe_settings(") && !cache.contains("budget_bps()"), + "the seat cache is keyed on the budget again" + ); + // ...and the number the wheel moves is still what the export is given. + assert!( + fn_body("start_export").contains("self.budget_bps()"), + "the export no longer writes at the budget on the row" + ); +}