diff --git a/rust/src/liveorder.rs b/rust/src/liveorder.rs index 57b94ad07..29b6382ab 100644 --- a/rust/src/liveorder.rs +++ b/rust/src/liveorder.rs @@ -25,7 +25,7 @@ //! is saved with the queue. use std::collections::HashMap; -use std::sync::atomic::{AtomicBool, Ordering}; +use std::sync::atomic::{AtomicBool, AtomicU64, Ordering}; use std::sync::{Arc, LazyLock, Mutex}; use std::time::{Duration, Instant}; @@ -119,11 +119,76 @@ impl Urgent { } } +/// Default lead (option `UnpackPacingLag`, 1536 MB) past which a download is paced to its +/// direct unpack. const UNPACK_LAG_SOFT: u64 = 1536 << 20; -const UNPACK_LAG_HARD: u64 = 3072 << 20; -/// Maximum lead allowed for far-ahead `Bulk` volumes while direct unpack is waiting on a -/// slow front volume, keeping lookahead volumes hot in page cache without multi-GB cold spills. -const UNPACK_WAIT_LAG_CAP: u64 = 2048 << 20; +/// Default hard lead: twice the soft one. +#[cfg(test)] +const UNPACK_LAG_HARD: u64 = 2 * UNPACK_LAG_SOFT; +/// Default lead allowed for far-ahead `Bulk` volumes while direct unpack is waiting on a +/// slow front volume (soft lead + 512 MB), keeping lookahead volumes hot in page cache +/// without multi-GB cold spills. +#[cfg(test)] +const UNPACK_WAIT_LAG_CAP: u64 = UNPACK_LAG_SOFT + UNPACK_WAIT_EXTRA; +const UNPACK_WAIT_EXTRA: u64 = 512 << 20; +/// Bounds of option `UnpackPacingLag`, in MB. +pub const UNPACK_PACING_LAG_MIN_MB: i64 = 256; +pub const UNPACK_PACING_LAG_MAX_MB: i64 = 1 << 20; +/// How long a paced download stays unpaced after the queue last gave its connections to +/// another download (`note_unpack_yield`): its articles in flight finish at line rate and +/// free their slots instead of sleeping in them. +const UNPACK_YIELD_HOLD: Duration = Duration::from_secs(2); + +/// Option `UnpackPacing` (yes: pace a download to its direct unpack once it leads by more +/// than `UnpackPacingLag`; no: never pace). +static PACING_ENABLED: AtomicBool = AtomicBool::new(true); +/// Option `UnpackPacingLag` in bytes. +static PACING_LAG_SOFT: AtomicU64 = AtomicU64::new(UNPACK_LAG_SOFT); + +/// Applies options `UnpackPacing` and `UnpackPacingLag` (MB, clamped to +/// `UNPACK_PACING_LAG_MIN_MB..=UNPACK_PACING_LAG_MAX_MB`); called on boot and on every +/// hot reload. +pub fn configure_unpack_pacing(enabled: bool, lag_mb: i64) { + PACING_ENABLED.store(enabled, Ordering::Release); + PACING_LAG_SOFT.store(pacing_lag_bytes(lag_mb), Ordering::Release); + let map = lock(&ORDERS); + sync_pacing_active(&map); +} + +/// `UnpackPacingLag` (MB) in bytes, clamped to its bounds. +pub fn pacing_lag_bytes(lag_mb: i64) -> u64 { + (lag_mb.clamp(UNPACK_PACING_LAG_MIN_MB, UNPACK_PACING_LAG_MAX_MB) as u64) << 20 +} + +#[cfg(test)] +thread_local! { + /// Per-test-thread `UnpackPacing=no`, so a test of the off switch leaves the others alone. + static TEST_PACING_OFF: std::cell::Cell = const { std::cell::Cell::new(false) }; +} + +/// Whether pacing is switched on (`UnpackPacing`). +fn pacing_enabled() -> bool { + #[cfg(test)] + if TEST_PACING_OFF.with(std::cell::Cell::get) { + return false; + } + PACING_ENABLED.load(Ordering::Acquire) +} + +/// The soft lead (`UnpackPacingLag`). +fn lag_soft() -> u64 { + PACING_LAG_SOFT.load(Ordering::Acquire) +} + +/// The hard lead: twice the soft one. +fn lag_hard() -> u64 { + lag_soft().saturating_mul(2) +} + +/// The waiting bulk cap: the soft lead plus 512 MB. +fn wait_lag_cap() -> u64 { + lag_soft().saturating_add(UNPACK_WAIT_EXTRA) +} const UNPACK_STALE_PROGRESS: Duration = Duration::from_secs(2); const UNPACK_MIN_SAMPLE_BYTES: u64 = 32 << 20; const UNPACK_UPDATE_SAMPLE_BYTES: u64 = 8 << 20; @@ -145,13 +210,14 @@ const UNPACK_DEBT_MAX_ACTIVE: i32 = 8; /// tapers smoothly from `1.0` at `UNPACK_LAG_SOFT` down to `0.50` at `UNPACK_LAG_HARD`, /// then brakes to `0.25` beyond `UNPACK_LAG_HARD` so backlog drains reliably. fn pace_scale_for_lag(lag: u64) -> f64 { - if lag <= UNPACK_LAG_SOFT { + let (soft, hard) = (lag_soft(), lag_hard()); + if lag <= soft { return 1.0; } - if lag > UNPACK_LAG_HARD { + if lag > hard { return 0.25; } - let frac = (lag - UNPACK_LAG_SOFT) as f64 / (UNPACK_LAG_HARD - UNPACK_LAG_SOFT) as f64; + let frac = (lag - soft) as f64 / (hard - soft).max(1) as f64; 1.0 - 0.50 * frac } @@ -166,6 +232,8 @@ struct UnpackPace { sample_bytes: u64, sample_start: Instant, bucket_until: Option, + /// Until when the queue hands this download's connections to another download. + yield_until: Option, } impl UnpackPace { @@ -181,6 +249,7 @@ impl UnpackPace { sample_bytes: 0, sample_start: Instant::now(), bucket_until: None, + yield_until: None, } } @@ -209,13 +278,19 @@ impl UnpackPace { } fn is_active(&self) -> bool { - if self.has_holds { + if self.has_holds || !pacing_enabled() { return false; } if self.waiting { - return self.lag() > UNPACK_WAIT_LAG_CAP; + return self.lag() > wait_lag_cap(); } - self.lag() > UNPACK_LAG_SOFT && (self.unpack_bps > 0.0 || self.is_stalled()) + self.lag() > lag_soft() && (self.unpack_bps > 0.0 || self.is_stalled()) + } + + /// True while the queue gives this download's connections to another one + /// (`note_unpack_yield`): its articles are not slept on then. + fn is_yielding(&self) -> bool { + self.yield_until.is_some_and(|t| t > Instant::now()) } fn target_bps(&self) -> Option { @@ -239,7 +314,7 @@ impl UnpackPace { if self.is_stalled() { return Some(UNPACK_STALL_MAX_ACTIVE); } - if self.lag() > UNPACK_LAG_HARD { + if self.lag() > lag_hard() { return Some(UNPACK_HARD_MAX_ACTIVE); } if self @@ -341,13 +416,15 @@ static PACING_ACTIVE: AtomicBool = AtomicBool::new(false); static ANY_HEDGES: AtomicBool = AtomicBool::new(false); fn sync_pacing_active(map: &HashMap) { - let active = map.values().any(|o| { - !o.has_holds - && o.pace.as_ref().is_some_and(|p| { - (!p.waiting && p.lag() > UNPACK_LAG_SOFT) - || (p.waiting && p.lag() > UNPACK_WAIT_LAG_CAP) - }) - }); + // The global switch only (not a test thread's override): this is a shared fast-path hint. + let (soft, cap) = (lag_soft(), wait_lag_cap()); + let active = PACING_ENABLED.load(Ordering::Acquire) + && map.values().any(|o| { + !o.has_holds + && o.pace.as_ref().is_some_and(|p| { + (!p.waiting && p.lag() > soft) || (p.waiting && p.lag() > cap) + }) + }); PACING_ACTIVE.store(active, Ordering::Release); } @@ -555,7 +632,7 @@ pub fn set_unpack_waiting(nzb_id: i32, waiting: bool) { pace.bucket_until = None; } pace.waiting = waiting; - if waiting && pace.lag() <= UNPACK_WAIT_LAG_CAP { + if waiting && pace.lag() <= wait_lag_cap() { pace.bucket_until = None; } sync_pacing_active(&map); @@ -575,7 +652,7 @@ pub fn note_unpacked(nzb_id: i32, bytes: u64) { return; }; pace.unpacked = pace.unpacked.saturating_add(bytes); - if pace.lag() <= UNPACK_LAG_SOFT { + if pace.lag() <= lag_soft() { pace.bucket_until = None; } pace.last_progress = Some(now); @@ -614,7 +691,7 @@ pub fn note_adopted(nzb_id: i32, bytes: u64) { }; if let Some(pace) = order.pace.as_mut() { pace.unpacked = pace.unpacked.saturating_add(bytes); - if pace.lag() <= UNPACK_LAG_SOFT { + if pace.lag() <= lag_soft() { pace.bucket_until = None; } } @@ -638,7 +715,7 @@ pub fn note_packed_read(nzb_id: i32, bytes: u64) { }; pace.packed_read = pace.packed_read.saturating_add(bytes); pace.last_progress = Some(now); - if pace.lag() <= UNPACK_LAG_SOFT { + if pace.lag() <= lag_soft() { pace.bucket_until = None; } order.sync_unpack_rank_from_bytes(); @@ -697,6 +774,89 @@ pub fn is_unpack_pacing(nzb_id: i32) -> bool { .is_some_and(UnpackPace::is_active) } +/// The queue handed a connection to another download while `nzb_id` is paced to its direct +/// unpack: for `UNPACK_YIELD_HOLD` its articles in flight are not slept on, so their slots go +/// to the other download instead of idling at unpack speed. Without another download to +/// serve the queue stops calling this and pacing resumes. +pub fn note_unpack_yield(nzb_id: i32) { + if !PACING_ACTIVE.load(Ordering::Acquire) { + return; + } + if let Some(pace) = lock(&ORDERS).get_mut(&nzb_id).and_then(|o| o.pace.as_mut()) { + pace.yield_until = Some(Instant::now() + UNPACK_YIELD_HOLD); + pace.bucket_until = None; + } +} + +/// Nothing else in the queue can use the connections: `nzb_id` is paced again at once +/// rather than when its yield hold lapses. +pub fn clear_unpack_yield(nzb_id: i32) { + if !PACING_ACTIVE.load(Ordering::Acquire) { + return; + } + if let Some(pace) = lock(&ORDERS).get_mut(&nzb_id).and_then(|o| o.pace.as_mut()) { + pace.yield_until = None; + } +} + +/// Whether `nzb_id` currently yields its connections to another download. +#[cfg_attr(not(test), allow(dead_code))] +pub fn is_unpack_yielding(nzb_id: i32) -> bool { + if !PACING_ACTIVE.load(Ordering::Acquire) { + return false; + } + lock(&ORDERS) + .get(&nzb_id) + .and_then(|o| o.pace.as_ref()) + .is_some_and(|p| p.is_active() && p.is_yielding()) +} + +/// Tests: `nzb_id` paced to an unpack running at `unpack_bps` with the download `lag` ahead. +#[cfg(test)] +pub fn test_force_paced(nzb_id: i32, unpack_bps: f64, lag: u64) { + let mut map = lock(&ORDERS); + let order = map.entry(nzb_id).or_default(); + let mut pace = UnpackPace::new(lag, order.has_holds); + pace.unpack_bps = unpack_bps; + pace.last_progress = Some(Instant::now()); + order.pace = Some(pace); + ANY.store(true, Ordering::Release); + sync_pacing_active(&map); +} + +/// Tests: `UnpackPacing=no` (`true`) for the calling thread only. +#[cfg(test)] +pub fn test_set_pacing_off(off: bool) { + TEST_PACING_OFF.with(|c| c.set(off)); +} + +/// What the status shows for a download paced to its direct unpack. +#[derive(Clone, Copy, Debug, PartialEq)] +pub struct UnpackPaceStatus { + /// The rate its download is held to (bytes per second). + pub rate_bps: f64, + /// The queue gives its connections to another download meanwhile. + pub yielding: bool, +} + +/// `Some` while `nzb_id`'s download is paced to its direct unpack (not while unpack only +/// waits for network data): the RPC status and the WebUI show "paced to unpack (X MB/s)" +/// so a lower speed is not read as a slow downloader. +pub fn unpack_pace_status(nzb_id: i32) -> Option { + if !PACING_ACTIVE.load(Ordering::Acquire) { + return None; + } + let map = lock(&ORDERS); + let pace = map.get(&nzb_id)?.pace.as_ref()?; + if pace.waiting { + return None; + } + Some(UnpackPaceStatus { + rate_bps: pace.target_bps()?, + yielding: pace.is_yielding(), + }) +} + /// Caps concurrent non-urgent ahead-of-unpack archive article dispatches when unpack pacing is /// heavily engaged (disk stall, lag past `UNPACK_LAG_HARD`, or shared bucket debt backed up), /// preventing 50–100 concurrent connections from bursting past `target_bps` at each wait quantum. @@ -724,8 +884,14 @@ pub fn unpack_pace_delay(nzb_id: i32, filename: &[u8], wire_bytes: usize) -> Dur let (target_bps, waiting) = match order.pace.as_mut() { Some(pace) => { let bps = pace.target_bps(); - if bps.is_none() && (pace.waiting || pace.lag() <= UNPACK_LAG_SOFT) { + if bps.is_none() && (pace.waiting || pace.lag() <= lag_soft()) { + pace.bucket_until = None; + } + // Another download has the connections: finish this one's articles in flight at + // line rate so their slots free up, rather than sleeping in them. + if bps.is_some() && pace.is_yielding() { pace.bucket_until = None; + return Duration::ZERO; } let Some(bps) = bps else { return Duration::ZERO; @@ -773,6 +939,9 @@ pub struct QueueOrderSnapshot { pub has_urgent: bool, pub is_unpack_pacing: bool, pub unpack_waiting: bool, + /// Pacing holds some of this download's volumes back (paced, or waiting with bulk past + /// the cap): the queue gives other downloads those connections first. + pub pace_active: bool, } /// Reads `nzb_id`'s live extraction order and pacing state in a single `ORDERS` lock without @@ -787,13 +956,14 @@ pub fn queue_snapshot(nzb_id: i32) -> Option { return None; } let unpack_waiting = order.pace.as_ref().is_some_and(|p| p.waiting); - let (is_unpack_pacing, unpack_pace_cap) = if PACING_ACTIVE.load(Ordering::Acquire) { + let (is_unpack_pacing, unpack_pace_cap, pace_active) = if PACING_ACTIVE.load(Ordering::Acquire) + { match order.pace.as_ref() { - Some(pace) if pace.is_active() => (!pace.waiting, pace.max_active()), - _ => (false, None), + Some(pace) if pace.is_active() => (!pace.waiting, pace.max_active(), true), + _ => (false, None, false), } } else { - (false, None) + (false, None, false) }; Some(QueueOrderSnapshot { ranks: order.ranks.clone(), @@ -804,6 +974,7 @@ pub fn queue_snapshot(nzb_id: i32) -> Option { has_urgent: !order.urgent.is_empty(), is_unpack_pacing, unpack_waiting, + pace_active, }) } @@ -1874,4 +2045,91 @@ mod tests { assert!(PACING_ACTIVE.load(Ordering::Acquire)); clear(id); } + + /// Sets up `id` paced to an unpack running at ~48 MiB/s with the download 1.7 GB ahead. + fn paced_download(id: i32) { + set_order(id, &[b"Q.part01.rar".to_vec(), b"Q.part02.rar".to_vec()]); + begin_unpack_pacing(id, 0); + note_unpacked(id, 1); + { + let mut map = lock(&ORDERS); + let pace = map.get_mut(&id).unwrap().pace.as_mut().unwrap(); + pace.sample_start = Instant::now() - Duration::from_secs(1); + } + note_unpacked(id, 48 << 20); + note_downloaded(id, b"/dl/Q.part01.rar", (48 << 20) + (1700 << 20)); + set_unpack_rank(id, Some(0)); + } + + #[test] + fn single_paced_download_still_sleeps_and_reports_its_rate() { + let _guard = lock(&PACING_TEST_LOCK); + let id = -7_320_201; + paced_download(id); + assert!(is_unpack_pacing(id)); + // Nothing else in the queue: the volume ahead of unpack is slept on as before. + assert!(unpack_pace_delay(id, b"/dl/Q.part02.rar", 8 << 20) > Duration::from_millis(50)); + let st = unpack_pace_status(id).expect("paced download reports its status"); + assert!(!st.yielding); + // ~48 MiB/s scaled for the lead (between half and all of it). + assert!( + st.rate_bps > 20.0 * 1048576.0 && st.rate_bps <= 49.0 * 1048576.0, + "rate {}", + st.rate_bps + ); + clear(id); + assert_eq!(unpack_pace_status(id), None); + } + + #[test] + fn yielding_download_frees_its_slots_instead_of_sleeping() { + let _guard = lock(&PACING_TEST_LOCK); + let id = -7_320_202; + paced_download(id); + note_unpack_yield(id); + assert!(is_unpack_yielding(id)); + assert_eq!( + unpack_pace_delay(id, b"/dl/Q.part02.rar", 8 << 20), + Duration::ZERO, + "another download has the connections: no sleep while holding a slot" + ); + assert!(unpack_pace_status(id).is_some_and(|s| s.yielding)); + // The hold runs out when the queue stops passing it over: pacing resumes. + { + let mut map = lock(&ORDERS); + let pace = map.get_mut(&id).unwrap().pace.as_mut().unwrap(); + pace.yield_until = Some(Instant::now() - Duration::from_millis(1)); + } + assert!(!is_unpack_yielding(id)); + assert!(unpack_pace_delay(id, b"/dl/Q.part02.rar", 8 << 20) > Duration::from_millis(50)); + clear(id); + } + + #[test] + fn unpack_pacing_off_never_paces() { + let _guard = lock(&PACING_TEST_LOCK); + let id = -7_320_203; + paced_download(id); + TEST_PACING_OFF.with(|c| c.set(true)); + let off = ( + is_unpack_pacing(id), + unpack_pace_delay(id, b"/dl/Q.part02.rar", 8 << 20), + unpack_pace_max_active(id), + unpack_pace_status(id), + queue_snapshot(id).map(|s| (s.pace_active, s.unpack_pace_cap)), + ); + TEST_PACING_OFF.with(|c| c.set(false)); + assert_eq!(off, (false, Duration::ZERO, None, None, Some((false, None)))); + assert!(is_unpack_pacing(id), "back on: paced again"); + clear(id); + } + + #[test] + fn unpack_pacing_lag_option_is_clamped_megabytes() { + assert_eq!(pacing_lag_bytes(1536), UNPACK_LAG_SOFT); + assert_eq!(pacing_lag_bytes(0), 256 << 20); + assert_eq!(pacing_lag_bytes(-5), 256 << 20); + assert_eq!(pacing_lag_bytes(i64::MAX), (1u64 << 20) << 20); + assert_eq!(pacing_lag_bytes(8192), 8192 << 20); + } } diff --git a/rust/src/options.rs b/rust/src/options.rs index 18c2f8e76..7654c9b97 100644 --- a/rust/src/options.rs +++ b/rust/src/options.rs @@ -1804,7 +1804,7 @@ pub(crate) fn known_enum_names(option: &str) -> Option<&'static [&'static CStr]> /// Emits all default option `(name, value)` pairs for `Options::InitDefaults`. pub fn init_defaults_with(disable_curses: bool, mut set_opt: impl FnMut(&CStr, &CStr)) { let output_mode = if disable_curses { c"color" } else { c"curses" }; - let defaults: [(&CStr, &CStr); 136] = [ + let defaults: [(&CStr, &CStr); 138] = [ (c"MainDir", c"~/downloads"), (c"WebDir", c""), (c"ConfigTemplate", c""), @@ -1918,6 +1918,8 @@ pub fn init_defaults_with(disable_curses: bool, mut set_opt: impl FnMut(&CStr, & (c"DirectUnpack", c"yes"), (c"FeedThreads", c"0"), (c"UnpackSlots", c"0"), + (c"UnpackPacing", c"yes"), + (c"UnpackPacingLag", c"1536"), (c"UseTempUnpackDir", c"yes"), (c"UnpackCleanupDisk", c"yes"), (c"UnrarCmd", c""), @@ -2220,6 +2222,10 @@ pub struct NzbgetRsParsedOptions { pub feed_threads: i32, /// Extractions that run at once (`unpackslots::capacity_for`): 0 is one, n is n (at most 64). pub unpack_slots: i32, + /// Option `UnpackPacing`: pace a download to its direct unpack (`liveorder`). + pub unpack_pacing: bool, + /// Option `UnpackPacingLag` (MB): the lead past which pacing starts. + pub unpack_pacing_lag: i32, } impl NzbgetRsParsedOptions { @@ -2751,6 +2757,11 @@ pub fn init_scalar_options_host( .clamp(0, crate::light_pool::LIGHT_MAX); s.feed_threads = host.parse_int_value(c"FeedThreads", 10).clamp(0, 64); s.unpack_slots = host.parse_int_value(c"UnpackSlots", 10).clamp(0, 64); + s.unpack_pacing = host.parse_bool_value(c"UnpackPacing"); + s.unpack_pacing_lag = host.parse_int_value(c"UnpackPacingLag", 10).clamp( + crate::liveorder::UNPACK_PACING_LAG_MIN_MB as i32, + crate::liveorder::UNPACK_PACING_LAG_MAX_MB as i32, + ); s.url_force = i32::from(host.parse_bool_value(c"UrlForce")); s.cert_check = i32::from(host.parse_bool_value(c"CertCheck")); s.reorder_files = i32::from(host.parse_bool_value(c"ReorderFiles")); @@ -4557,6 +4568,8 @@ pub(crate) fn set_active_options(opts: &std::sync::Arc) { if let Ok(mut g) = ACTIVE_OPTIONS.write() { *g = Some(std::sync::Arc::downgrade(opts)); } + let sc = opts.scalars(); + crate::liveorder::configure_unpack_pacing(sc.unpack_pacing, i64::from(sc.unpack_pacing_lag)); } /// Monotonic counter incremented every time configuration is hot-reloaded or reset on boot. @@ -5784,6 +5797,10 @@ fn build_options( if let Ok(mut g) = ACTIVE_OPTIONS.write() { *g = Some(std::sync::Arc::downgrade(&arc)); } + crate::liveorder::configure_unpack_pacing( + arc.scalars.unpack_pacing, + i64::from(arc.scalars.unpack_pacing_lag), + ); // "detect" tests the intermediate folder's disk once per process, in the background. if arc.daemon_subsystems && !arc.no_disk_access && par_preset() == crate::parpreset::DETECT { crate::parpreset::start_probe( diff --git a/rust/src/queuecoord.rs b/rust/src/queuecoord.rs index 559ac3c24..af2c048cf 100644 --- a/rust/src/queuecoord.rs +++ b/rust/src/queuecoord.rs @@ -100,9 +100,25 @@ struct LiveOrder { has_urgent: bool, is_unpack_pacing: bool, unpack_waiting: bool, + /// Pacing holds this download's volumes ahead of unpack back (see `liveorder`). + pace_active: bool, } impl LiveOrder { + /// Whether the volume named `filename` stays exempt from unpack pacing: the volume + /// unpack is reading, or (while unpack waits for network data) one in the window. + fn pace_exempt(&self, filename: &[u8]) -> Option { + let r = self.ranks.of(filename)?; + Some( + self.unpack_rank == Some(r) + || (self.unpack_waiting + && (self + .unpack_rank + .is_some_and(|f| crate::liveorder::in_window(r, f)) + || self.window_rank(filename).is_some())), + ) + } + /// The rank of the file named `filename` when it is a volume within the window. fn window_rank(&self, filename: &[u8]) -> Option { let rank = self.ranks.of(filename)?; @@ -247,6 +263,7 @@ fn cached_live_order<'c>( has_urgent: snap.has_urgent, is_unpack_pacing: snap.is_unpack_pacing, unpack_waiting: snap.unpack_waiting, + pace_active: snap.pace_active, } }); cache.push((nzb_id, order)); @@ -4543,6 +4560,32 @@ impl NzbgetRsQueueCoordinator { ) -> Option<( crate::queuesubsys_host::FileSnap, crate::queuesubsys_host::ArticleSnap, + )> { + let mut yielded: Vec<(i32, NzbRef)> = Vec::new(); + let picked = self.pick_next_article(host, opts, dq_ptr, &mut yielded); + // Another download took a connection a paced download passed over: that one's + // articles in flight stop sleeping at unpack speed for a while (`liveorder`). + if let Some((f, _)) = &picked { + for &(id, ptr) in &yielded { + if ptr != f.nzb_ptr { + crate::liveorder::note_unpack_yield(id); + } + } + } + picked + } + + /// `get_next_article`'s pick; `yielded` gets the downloads paced to their direct unpack + /// whose volumes it passed over for another download's. + fn pick_next_article( + &self, + host: &crate::queuesubsys_host::QueueSubsysHost, + opts: &crate::queuesubsys_host::GlobalOptsSnap, + dq_ptr: usize, + yielded: &mut Vec<(i32, NzbRef)>, + ) -> Option<( + crate::queuesubsys_host::FileSnap, + crate::queuesubsys_host::ArticleSnap, )> { let mut checked_files: Vec = Vec::new(); let cur_date = opts.cur_time; @@ -4568,6 +4611,10 @@ impl NzbgetRsQueueCoordinator { let mut copies_by_key: Option = None; // Downloads the InterDir budget holds this call: the pick goes round without them. let mut budget_held: Vec = Vec::new(); + // A download paced to its direct unpack gives its connections to the rest of the queue + // (its volumes ahead of unpack are passed over) while another download can use them. + // When nothing else can, the pick goes round once more with pacing as before. + let mut yield_paced = true; loop { let mut best_file: Option<( @@ -4627,14 +4674,9 @@ impl NzbgetRsQueueCoordinator { } let propagation_delay = opts.propagation_delay; let order = cached_live_order(&mut orders, host, nzb_ptr, nzb.id); - let (unpack_pace_cap, unpack_rank, has_urgent, unpack_waiting) = match order { - Some(o) => ( - o.unpack_pace_cap, - o.unpack_rank, - o.has_urgent, - o.unpack_waiting, - ), - None => (None, None, false, false), + let (unpack_pace_cap, has_urgent, pace_active) = match order { + Some(o) => (o.unpack_pace_cap, o.has_urgent, o.pace_active), + None => (None, false, false), }; // A par2 file with articles to fetch seen earlier in the list: the window // does not go ahead of it (live PAR reads it early). @@ -4656,25 +4698,24 @@ impl NzbgetRsQueueCoordinator { // dispatches for archive volumes ahead of unpack while leaving par2, // extra-priority, urgent, the volume unpack is actually reading (and // lookahead window volumes while unpack is waiting) unthrottled. + // While another download can use the connections, a paced + // download's volumes ahead of unpack are passed over entirely. if !has_urgent && !par_file && !f.extra_priority - && unpack_pace_cap.is_some_and(|cap| nzb.active_downloads >= cap) + && ((yield_paced && pace_active) + || unpack_pace_cap + .is_some_and(|cap| nzb.active_downloads >= cap)) + && order.as_ref().and_then(|o| o.pace_exempt(&f.filename)) + == Some(false) { - let vol_rank = order.as_ref().and_then(|o| o.ranks.of(&f.filename)); - let exempt = vol_rank.is_some_and(|r| { - unpack_rank == Some(r) - || (unpack_waiting - && (unpack_rank - .is_some_and(|f| crate::liveorder::in_window(r, f)) - || order - .as_ref() - .and_then(|o| o.window_rank(&f.filename)) - .is_some())) - }); - if vol_rank.is_some() && !exempt { - continue; + if yield_paced + && pace_active + && !yielded.iter().any(|&(id, _)| id == nzb.id) + { + yielded.push((nzb.id, nzb.ptr)); } + continue; } // A volume of a set extracted live, within the window: taken in // extraction order before the download's other files (a par2 @@ -4710,6 +4751,15 @@ impl NzbgetRsQueueCoordinator { } let Some((mut nzb, mut file, _)) = best_file else { + // Nothing else can use the connections: pace the passed-over downloads as + // before (their articles go out and sleep at unpack speed). + if yield_paced && !yielded.is_empty() { + yield_paced = false; + for (id, _) in yielded.drain(..) { + crate::liveorder::clear_unpack_yield(id); + } + continue; + } if let Some((pw_nzb, pw_file)) = prop_wait_file { let prev_logged = self .propagation_wait_logged_id @@ -11757,6 +11807,143 @@ mod tests { assert!(super::should_probe_first_article(true, false, b"Show.vol-02.PAR2")); } + /// Adds a download of two 2-article RAR volumes named `.partNN.rar` to the queue. + #[cfg(unix)] + fn add_two_volume_download( + host: &crate::queuesubsys_host::QueueSubsysHost, + base: &str, + ) -> (crate::queuesubsys_host::NzbRef, i32, Vec) { + use crate::qnzb::{self, ParsedFile}; + use crate::qqueue; + use crate::queuesubsys_host::NzbRef; + use std::ffi::CString; + + let (hn, nzb_addr) = qqueue::new_nzb_handle(); + let nzb = NzbRef::from_addr(nzb_addr); + qqueue::with_current_locked(|dq| unsafe { + qqueue::queue_add_handle(dq, hn); + }); + let nzb_id = host.nzb_snap(nzb, false).id; + let parts = [1i32, 2i32]; + let sizes = [700_000i64, 700_000i64]; + let mut files = Vec::new(); + for vol in 1..=2 { + let name = CString::new(format!("{base}.part0{vol}.rar")).unwrap(); + let m1 = CString::new(format!("<{base}{vol}a@example>")).unwrap(); + let m2 = CString::new(format!("<{base}{vol}b@example>")).unwrap(); + let msg_ids = [m1.as_ptr(), m2.as_ptr()]; + files.push(qnzb::add_parsed_file( + nzb, + &ParsedFile { + id: 0, + subject: name.as_ptr(), + filename: name.as_ptr(), + time: 0, + size: 1_400_000, + remaining_size: 1_400_000, + missed_size: 0, + total_articles: 2, + missed_articles: 0, + par_file: false, + groups: &[], + article_parts: &parts, + article_sizes: &sizes, + article_msg_ids: &msg_ids, + }, + )); + } + (nzb, nzb_id, files) + } + + #[cfg(unix)] + #[test] + fn paced_download_gives_its_connections_to_the_next_queued_download() { + use crate::qqueue; + use crate::queuesubsys_host::QueueSubsysHost; + + let _s = qqueue::tests::serial(); + qqueue::daemon_queue_init(); + let opts_guard = crate::options::test_options(&[c"WriteLog=none", c"LogBuffer=100"]); + let host = QueueSubsysHost::active(); + let qc = super::NzbgetRsQueueCoordinator::new(); + let pick = |qc: &super::NzbgetRsQueueCoordinator| { + host.with_locked_queue(|dq_ptr| { + let opts = host.opts(); + qc.get_next_article(&host, &opts, dq_ptr) + .map(|(f, _)| f.nzb_ptr) + }) + }; + + let (nzb_a, id_a, files_a) = add_two_volume_download(&host, "PacedA"); + crate::liveorder::set_order( + id_a, + &[b"PacedA.part01.rar".to_vec(), b"PacedA.part02.rar".to_vec()], + ); + // Unpack at 45 MB/s, the download 1.7 GB ahead of it: paced. Unpack reads part01. + crate::liveorder::test_force_paced(id_a, 45.0 * 1048576.0, 1700 << 20); + assert!(crate::liveorder::is_unpack_pacing(id_a)); + // The articles of part01 (the volume unpack reads, never passed over) are in flight. + let set_vol1 = |status: i32| { + for i in 0..2 { + let art = host.article_at(files_a[0], i).ptr; + host.article_edit(art, crate::qarticle::ArticleEdit::Status(status)); + } + }; + set_vol1(crate::qarticle::AI_RUNNING); + + // 1. Alone in the queue, the paced download still gets articles of the volume ahead + // (paced as before: they sleep at unpack speed). + assert_eq!(pick(&qc), Some(nzb_a)); + assert_eq!(crate::liveorder::unpack_rank(id_a), Some(0)); + assert!(!crate::liveorder::is_unpack_yielding(id_a)); + assert!( + crate::liveorder::unpack_pace_delay(id_a, b"PacedA.part02.rar", 8 << 20) + > std::time::Duration::from_millis(50) + ); + + // 2. A second queued download gets the connections; the paced one's articles in + // flight stop sleeping in their slots. + let (nzb_b, _id_b, files_b) = add_two_volume_download(&host, "NextB"); + assert_eq!(pick(&qc), Some(nzb_b)); + assert!(crate::liveorder::is_unpack_yielding(id_a)); + assert_eq!( + crate::liveorder::unpack_pace_delay(id_a, b"PacedA.part02.rar", 8 << 20), + std::time::Duration::ZERO + ); + assert!(crate::liveorder::unpack_pace_status(id_a).is_some_and(|s| s.yielding)); + + // 2b. The other download's work runs out: the paced download is paced again at once. + for i in 0..2 { + for f in &files_b { + let art = host.article_at(*f, i).ptr; + host.article_edit(art, crate::qarticle::ArticleEdit::Status(crate::qarticle::AI_RUNNING)); + } + } + assert_eq!(pick(&qc), Some(nzb_a)); + assert!(!crate::liveorder::is_unpack_yielding(id_a)); + for i in 0..2 { + for f in &files_b { + let art = host.article_at(*f, i).ptr; + host.article_edit(art, crate::qarticle::ArticleEdit::Status(crate::qarticle::AI_UNDEFINED)); + } + } + assert_eq!(pick(&qc), Some(nzb_b)); + + // 3. The volume unpack is reading still goes to the paced download first. + set_vol1(crate::qarticle::AI_UNDEFINED); + assert_eq!(pick(&qc), Some(nzb_a)); + set_vol1(crate::qarticle::AI_RUNNING); + + // 4. UnpackPacing=no: queue order again, nothing passed over. + crate::liveorder::test_set_pacing_off(true); + let off_pick = pick(&qc); + crate::liveorder::test_set_pacing_off(false); + assert_eq!(off_pick, Some(nzb_a)); + + crate::liveorder::clear(id_a); + drop(opts_guard); + } + #[cfg(unix)] #[test] fn waiting_stragglers_are_hedged_after_floor_and_guarded_against_races() { diff --git a/rust/src/xmlrpc_format.rs b/rust/src/xmlrpc_format.rs index 20d4e805e..6ded50ee9 100644 --- a/rust/src/xmlrpc_format.rs +++ b/rust/src/xmlrpc_format.rs @@ -1540,8 +1540,14 @@ fn write_group_item_start( .unwrap_or("QUEUED"); let direct_unpack_str = table_get(&DIRECT_UNPACK_STATUS_NAMES, g.direct_unpack_status, "NONE"); let unpack_state_str = crate::unpack_progress::UnpackState::from_code(g.unpack_state).as_str(); - - out.reserve(768); + // Download held to its direct unpack's speed (`UnpackPacing`): shown as "paced to unpack + // (X MB/s)" so a lower speed is not read as a slow downloader. + let pace = crate::liveorder::unpack_pace_status(g.nzb_id); + let paced_str = bool_str(json, pace.is_some()); + let pace_rate = pace.map_or(0, |p| p.rate_bps.clamp(0.0, f64::from(i32::MAX)) as i32); + let pace_yield_str = bool_str(json, pace.is_some_and(|p| p.yielding)); + + out.reserve(864); if json { if index > 0 { out.extend_from_slice(b",\n"); @@ -1569,7 +1575,10 @@ fn write_group_item_start( \"UnpackDoneLo\" : {},\n\ \"UnpackDoneHi\" : {},\n\ \"UnpackTotalLo\" : {},\n\ - \"UnpackTotalHi\" : {},\n", + \"UnpackTotalHi\" : {},\n\ + \"UnpackPaced\" : {},\n\ + \"UnpackPaceRate\" : {},\n\ + \"UnpackPaceYield\" : {},\n", g.nzb_id, g.nzb_id, rem_lo, @@ -1590,7 +1599,10 @@ fn write_group_item_start( unpack_done_lo, unpack_done_hi, unpack_total_lo, - unpack_total_hi + unpack_total_hi, + paced_str, + pace_rate, + pace_yield_str ); } else { let _ = write!( @@ -1616,7 +1628,10 @@ fn write_group_item_start( UnpackDoneLo{}\n\ UnpackDoneHi{}\n\ UnpackTotalLo{}\n\ - UnpackTotalHi{}\n", + UnpackTotalHi{}\n\ + UnpackPaced{}\n\ + UnpackPaceRate{}\n\ + UnpackPaceYield{}\n", g.nzb_id, g.nzb_id, rem_lo, @@ -1637,7 +1652,10 @@ fn write_group_item_start( unpack_done_lo, unpack_done_hi, unpack_total_lo, - unpack_total_hi + unpack_total_hi, + paced_str, + pace_rate, + pace_yield_str ); } } diff --git a/rustyget.conf b/rustyget.conf index 0636bc670..8807010a5 100644 --- a/rustyget.conf +++ b/rustyget.conf @@ -2062,6 +2062,34 @@ FeedThreads=0 # (see ). UnpackSlots=0 +# Pace a download to its direct unpack when it gets far ahead (yes, no). +# +# When direct unpack falls more than behind the download +# (a slow or nearly full disk, say), the download is held to the speed the +# unpack keeps up, so the intermediate folder does not fill with volumes +# waiting to be extracted. Only that download is held: while another +# download in the queue can use the connections, they go to it, and the +# held download only gets the volume its unpack is reading. With nothing +# else to download, the held download's articles wait at unpack speed. +# Downloads and the web interface show "paced to unpack (X MB/s)" while +# this happens. +# +# yes - pace a download that leads its unpack by more than +# . The default. +# no - never pace: every download runs at full speed and the unpack +# catches up afterwards (as NZBGet does). Needs room in +# for the volumes waiting to be extracted. +UnpackPacing=yes + +# How far the download may get ahead of direct unpack before pacing +# starts, in megabytes (256-1048576). +# +# Past twice this lead the download is slowed further, and to at most four +# connections, until the unpack catches up. A larger value keeps the +# download at full speed for longer and needs that much more room in +# . Used only with on. +UnpackPacingLag=1536 + # Use a temporary _unpack directory during unpacking (yes, no). # # Enabled - Files are unpacked to a temporary subdirectory and then moved to the destination. diff --git a/site/content/api.md b/site/content/api.md index c326b743f..8af6304ae 100644 --- a/site/content/api.md +++ b/site/content/api.md @@ -115,6 +115,14 @@ The result: | `DupeRecoveredHoles` | Holes filled from decompressed donors. | | `LiveRepairing` | `true` while live repair runs. | +`listgroups` items also have these: + +| Field | Meaning | +|---|---| +| `UnpackPaced` | `true` while the download is held to its direct unpack's speed (option `UnpackPacing`). The web interface shows "paced to unpack (X MB/s)". | +| `UnpackPaceRate` | The speed it is held to, in bytes per second (0 when not paced). | +| `UnpackPaceYield` | `true` while the held download's connections go to another download in the queue. | + The `listgroups` status and the `postqueue` stage can be `STREAM_REPAIRING`. RustyGet also stores its findings as NZB parameters, which the API returns in `Parameters`: diff --git a/site/content/settings-processing.md b/site/content/settings-processing.md index 075a5ecf7..0ef3f4b5a 100644 --- a/site/content/settings-processing.md +++ b/site/content/settings-processing.md @@ -35,7 +35,7 @@ Key options: [`ParCheck`](options.md#parcheck), [`ParRepair`](options.md#parrepa ## Unpack -Turn `Unpack` on when you want archive extraction. RustyGet extracts RAR, 7-Zip, ZIP, and tar archives itself, so it needs no external tools. `DirectUnpack` extracts RAR archives while articles arrive and pauses at a damaged volume until it's repaired; `UseTempUnpackDir` controls temporary extraction folders. `FeedThreads` sets how many threads decode a 7-Zip LZMA2 archive during live extraction. `UnpackSlots` sets how many extractions run at once (one by default, so each release finishes as soon as it can); an extraction waiting for a volume gives its slot back, and a downloading download goes before finished, paused or held ones. A finished download that waited long moves up, and a paused or held download's extraction gives way between volumes. +Turn `Unpack` on when you want archive extraction. RustyGet extracts RAR, 7-Zip, ZIP, and tar archives itself, so it needs no external tools. `DirectUnpack` extracts RAR archives while articles arrive and pauses at a damaged volume until it's repaired; `UseTempUnpackDir` controls temporary extraction folders. `FeedThreads` sets how many threads decode a 7-Zip LZMA2 archive during live extraction. `UnpackSlots` sets how many extractions run at once (one by default, so each release finishes as soon as it can); an extraction waiting for a volume gives its slot back, and a downloading download goes before finished, paused or held ones. A finished download that waited long moves up, and a paused or held download's extraction gives way between volumes. `UnpackPacing` holds a download to its direct unpack's speed once the download leads by more than `UnpackPacingLag` (1536 MB by default); while another download in the queue can use the connections it gets them instead, and Downloads shows "paced to unpack (X MB/s)" on the held one. Turn it off to download at full speed and let the unpack catch up afterwards, if `InterDir` has room. `UnpackCleanupDisk` removes archive files after successful extraction. Choose it according to what you want the completed folder to retain. `UnpackIgnoreExt` lists nonstandard RAR extensions, such as `.cbr`, that should keep their names during RAR renaming. It also suppresses the failure for finding only nonstandard RAR archives with those extensions. Recognized `.rar` and `.7z` archives still follow normal extraction. `UnpackPassFile` supplies a password-list file when needed. @@ -43,7 +43,7 @@ A category can override the global unpack setting. Nested archives are unpacked Every unpack is checked before each file or folder is created. Unpacked names are made ASCII: accents are dropped, other characters become `_`, and upper and lower case are kept. `../` and absolute paths are refused. Names and paths must fit the file systems of both the unpack folder and the final folder. A download may unpack at most `UnpackMaxFiles` files (default 100), `UnpackMaxFolders` folders (default 10) and `UnpackMaxDepth` levels of folders (default 2; `Release/Sample/sample.mkv` is 2 deep). The volumes of an archive inside an archive are unpacked further and, when `UnpackCleanupDisk` deletes them, do not count; only what comes out does. A download over a limit stops unpacking and fails post-processing, with a message that names the limit and the file. No par repair is tried. Set a limit to 0 to turn it off. -Key options: [`Unpack`](options.md#unpack), [`DirectUnpack`](options.md#directunpack), [`UseTempUnpackDir`](options.md#usetempunpackdir), [`FeedThreads`](options.md#feedthreads), [`UnpackSlots`](options.md#unpackslots), [`UnpackCleanupDisk`](options.md#unpackcleanupdisk), [`UnpackIgnoreExt`](options.md#unpackignoreext), [`UnpackMaxFiles`](options.md#unpackmaxfiles), [`UnpackMaxDepth`](options.md#unpackmaxdepth), [`UnpackMaxFolders`](options.md#unpackmaxfolders). +Key options: [`Unpack`](options.md#unpack), [`DirectUnpack`](options.md#directunpack), [`UseTempUnpackDir`](options.md#usetempunpackdir), [`FeedThreads`](options.md#feedthreads), [`UnpackSlots`](options.md#unpackslots), [`UnpackPacing`](options.md#unpackpacing), [`UnpackPacingLag`](options.md#unpackpacinglag), [`UnpackCleanupDisk`](options.md#unpackcleanupdisk), [`UnpackIgnoreExt`](options.md#unpackignoreext), [`UnpackMaxFiles`](options.md#unpackmaxfiles), [`UnpackMaxDepth`](options.md#unpackmaxdepth), [`UnpackMaxFolders`](options.md#unpackmaxfolders).
Archive extraction and cleanup settings diff --git a/tests/webui/dual-progress.js b/tests/webui/dual-progress.js index b3c307e65..fa12f6d50 100644 --- a/tests/webui/dual-progress.js +++ b/tests/webui/dual-progress.js @@ -60,7 +60,9 @@ function dualProgressQueue(groups) { ...splitBytes('FileSize', 4800), ...splitBytes('RemainingSize', 1536), ...splitBytes('PausedSize', 0), ...splitBytes('DownloadedSize', 3264), DirectUnpackStatus: 'RUNNING', UnpackState: 'RUNNING', UnpackProgress: 620, - ...splitUnpack('UnpackDone', 2976), ...splitUnpack('UnpackTotal', 4800) + ...splitUnpack('UnpackDone', 2976), ...splitUnpack('UnpackTotal', 4800), + // held to its direct unpack's speed (UnpackPacing) while the next download gets the connections + UnpackPaced: true, UnpackPaceRate: 45 * MB, UnpackPaceYield: true }), // (b) Download at 100% while extraction finishes (UNPACKING) makeGroup(base, 102, 'Coastal.Chronicles.S03E04.1080p.BluRay.x264-EXMPL', { @@ -272,6 +274,18 @@ async function checkProgressContrast(page, selector) { assert(await ex.evaluate(e => e.classList.contains('is-extract-active'))); }); + await check('state (a): paced to unpack badge, bar note and tooltip (UnpackPacing)', async () => { + const r = rowFor(101); + const badge = r.locator('.dl-unpack-paced'); + assert.equal(await badge.count(), 1); + assert.equal((await badge.innerText()).trim(), 'paced to unpack (45.0 MB/s)'); + assert.match(await badge.getAttribute('title'), /next download in the queue gets the connections.*not slow/); + const dl = r.locator('.progress-lane-download'); + assert.match(await dl.innerText(), /paced to unpack \(45\.0 MB\/s\)/); + // nothing else is paced + assert.equal(await page.locator('#DownloadsTable .dl-unpack-paced').count(), 1); + }); + await check('state (b): download 100% while UNPACKING catches up', async () => { const r = rowFor(102); const dl = r.locator('.progress-lane-download'); diff --git a/webui/config.js b/webui/config.js index 55290fa63..0b0b8da2e 100644 --- a/webui/config.js +++ b/webui/config.js @@ -1784,7 +1784,7 @@ var Config = (new function($) ], UNPACK: [ { key: 'unpack', title: 'Unpack', options: ['Unpack', 'DirectUnpack', 'UnpackPassFile', 'UseTempUnpackDir', 'UnpackPauseQueue'], - advanced: ['UnpackSlots', 'FeedThreads', 'UnpackMaxFiles', 'UnpackMaxDepth', 'UnpackMaxFolders'] }, + advanced: ['UnpackSlots', 'FeedThreads', 'UnpackPacing', 'UnpackPacingLag', 'UnpackMaxFiles', 'UnpackMaxDepth', 'UnpackMaxFolders'] }, { key: 'cleanup', title: 'Cleanup', options: ['UnpackCleanupDisk', 'ExtCleanupDisk', 'UnpackIgnoreExt'] } ], PATHS: [ @@ -3364,6 +3364,8 @@ var Config = (new function($) { option: 'UseTempUnpackDir', when: { name: 'Unpack', values: ['yes'], orCategory: 'Unpack' } }, { option: 'UnpackPauseQueue', when: { name: 'Unpack', values: ['yes'], orCategory: 'Unpack' } }, { option: 'FeedThreads', when: { name: 'DirectUnpack', values: ['yes'] } }, + { option: 'UnpackPacing', when: { name: 'DirectUnpack', values: ['yes'] } }, + { option: 'UnpackPacingLag', when: { name: 'UnpackPacing', values: ['yes'] } }, { option: 'UnpackSlots', when: { name: 'Unpack', values: ['yes'], orCategory: 'Unpack' } }, { option: 'UnpackMaxFiles', when: { name: 'Unpack', values: ['yes'], orCategory: 'Unpack' } }, { option: 'UnpackMaxDepth', when: { name: 'Unpack', values: ['yes'], orCategory: 'Unpack' } }, diff --git a/webui/downloads.js b/webui/downloads.js index 771c6afc0..c01a2ab3e 100644 --- a/webui/downloads.js +++ b/webui/downloads.js @@ -851,9 +851,33 @@ var DownloadsUI = (new function($) I18n.translate('label_live_repair') + ''; } + var paced = DownloadsUI.unpackPacedText(group); + if (paced) + { + badge += ' ' + Util.textToHtml(paced) + ''; + } + return badge; } + // "paced to unpack (X MB/s)" while the daemon holds this download to its direct + // unpack's speed (option UnpackPacing), or '' when it does not. + this.unpackPacedText = function(group) + { + if (!group || !group.UnpackPaced) + { + return ''; + } + var rate = Number(group.UnpackPaceRate) || 0; + return I18n.translate('label_unpack_paced', Util.formatSpeed(rate)); + } + + this.unpackPacedHint = function(group) + { + return I18n.translate(group && group.UnpackPaceYield ? 'label_unpack_paced_yield_hint' : 'label_unpack_paced_hint'); + } + // Combine 32-bit Hi/Lo byte words safely (Util.joinInt64 uses `hi << 32`, // which is a 32-bit no-op in JS and drops the high word at >= 4 GiB). function joinBytes(hi, lo) @@ -1015,6 +1039,11 @@ var DownloadsUI = (new function($) { metaText = totalText + ' · ' + leftText; } + var pacedText = isUrl ? '' : DownloadsUI.unpackPacedText(group); + if (pacedText) + { + metaText = metaText ? metaText + ' · ' + pacedText : pacedText; + } var tooltip; if (isUrl) @@ -1035,6 +1064,11 @@ var DownloadsUI = (new function($) tooltip = I18n.translate('progress_download_queued_tooltip', String(percent), totalText || formatSizeBytes(fileBytes)); } + if (pacedText) + { + tooltip += ' · ' + pacedText + ': ' + DownloadsUI.unpackPacedHint(group); + } + return { label: I18n.translate('progress_download'), percent: percent, diff --git a/webui/locales.source.json b/webui/locales.source.json index c1de2d925..6d10272d4 100644 --- a/webui/locales.source.json +++ b/webui/locales.source.json @@ -2234,6 +2234,18 @@ "message": "Repairing missing bytes from duplicate collections", "description": "Tooltip for the 'Repair' status badge: byte-level stream repair (option DupeArticleFallback=live) is running for this collection while it still downloads." }, + "label_unpack_paced": { + "message": "paced to unpack ($1)", + "description": "Status badge and download-bar note while a download is held to the speed of its direct unpack (option UnpackPacing). $1 is the speed it is held to, for example '45 MB/s'. Keep it short." + }, + "label_unpack_paced_hint": { + "message": "Direct unpack is behind, so this download is held to the speed the unpack keeps up (option UnpackPacing). The downloader is not slow.", + "description": "Tooltip for the 'paced to unpack' badge. DO NOT translate the option name UnpackPacing." + }, + "label_unpack_paced_yield_hint": { + "message": "Direct unpack is behind, so this download waits for it while the next download in the queue gets the connections (option UnpackPacing). The downloader is not slow.", + "description": "Tooltip for the 'paced to unpack' badge while other downloads use the connections. DO NOT translate the option name UnpackPacing." + }, "help_feed_filter_title": { "message": "Help: Filter for RSS Feed", "description": "Help title. Title or heading" @@ -4418,6 +4430,14 @@ "message": "Extractions that run at once (0-64).\n\nDirect unpack, live extraction and the unpack of finished downloads share\nthese slots. Extractions share the destination disk, so running several at\nonce makes every release finish later; one at a time finishes each release\nas soon as it can. An extraction holds a slot only while it extracts: one\nwaiting for a volume (a paused or slow download's, say) gives its slot back.\nA download that is downloading goes first, then finished downloads, then\npaused downloads and copies a fleet holds.\n\n 0, 1 - one extraction at a time. The default (0).\n 2 or up - that many at once.\n\nA finished download or a paused one that waited long moves up. A paused or\nheld download's extraction gives its slot up between volumes for one that\ngoes first, and any direct unpack does for a finished download that waited\na minute; the unpack of a finished download is not interrupted. Direct\nunpack starts whatever allows post-processing to run; these\nslots bound it instead. Each extraction may use several threads of its own\n(see ).", "description": "Description for the option UnpackSlots DO NOT translate option names enclosed in angle brackets (e.g., )." }, + "config_desc_unpackpacing": { + "message": "Pace a download to its direct unpack when it gets far ahead.\n\nWhen direct unpack falls more than behind the download\n(a slow or nearly full disk, say), the download is held to the speed the\nunpack keeps up, so the intermediate folder does not fill with volumes\nwaiting to be extracted. Only that download is held: while another\ndownload in the queue can use the connections, they go to it, and the\nheld download only gets the volume its unpack is reading. With nothing\nelse to download, the held download's articles wait at unpack speed.\nDownloads and the web interface show \"paced to unpack (X MB/s)\" while\nthis happens.\n\n yes - pace a download that leads its unpack by more than\n . The default.\n no - never pace: every download runs at full speed and the unpack\n catches up afterwards (as NZBGet does). Needs room in \n for the volumes waiting to be extracted.", + "description": "Description for the option UnpackPacing DO NOT translate option names enclosed in angle brackets (e.g., ). DO NOT translate technical values enclosed in quotes. DO NOT translate configuration option values (no, yes) as they are fixed configuration values." + }, + "config_desc_unpackpacinglag": { + "message": "How far the download may get ahead of direct unpack before pacing\nstarts, in megabytes (256-1048576).\n\nPast twice this lead the download is slowed further, and to at most four\nconnections, until the unpack catches up. A larger value keeps the\ndownload at full speed for longer and needs that much more room in\n. Used only with on.", + "description": "Description for the option UnpackPacingLag DO NOT translate option names enclosed in angle brackets (e.g., )." + }, "config_desc_usetempunpackdir": { "message": "Use a temporary _unpack directory during unpacking.\n\n Enabled - Files are unpacked to a temporary subdirectory and then moved to the destination.\n This guarantees integrity and preventing partial files in the final location.\n Disabled - Files are unpacked directly into the destination directory.\n This allows for immediate access to files during the unpacking process.", "description": "Description for the option UseTempUnpackDir DO NOT translate configuration option values (Disabled, Enabled) as they are fixed configuration values." diff --git a/webui/style.css b/webui/style.css index 3c09e8de7..daa43a264 100644 --- a/webui/style.css +++ b/webui/style.css @@ -1000,6 +1000,11 @@ ul.dropdown-menu > li > a > i { text-transform: uppercase; } +/* "paced to unpack (45.0 MB/s)": a rate, kept in its own case */ +.label-status.dl-unpack-paced { + text-transform: none; +} + .label-inline { display: inline-block; margin-bottom: -4px;