summaryrefslogtreecommitdiffstats
path: root/src/pipeline/dispatch.rs
diff options
context:
space:
mode:
authoraur-build <aur-build@localhost>2026-11-19 17:33:17 +0000
committeraur-build <aur-build@localhost>2026-11-19 17:33:17 +0000
commit4304b0f336ddba7b4ec6780795059ff2066d105b (patch)
tree10edea744a1c2bf3fc363b4dc7f64abac8b1a0d3 /src/pipeline/dispatch.rs
parente757979f1a2afdbe7146066345bb9acd19d3b151 (diff)
downloadaur-build-4304b0f336ddba7b4ec6780795059ff2066d105b.tar.gz
aur-build-4304b0f336ddba7b4ec6780795059ff2066d105b.zip
comments: keep only what the code cannot show
Stripped every comment that described what an item does, documented its arguments or fields, or cited the design docs (§n, I-n, m-n, decision n). 2247 comments down to 83. What survives: the section dividers that segment the large modules, the secret-handling warnings, the agent wire-frame directions, and the few notes without which the code they attach to reads as redundant, reorderable, or unsound.
Diffstat (limited to 'src/pipeline/dispatch.rs')
-rw-r--r--src/pipeline/dispatch.rs25
1 files changed, 0 insertions, 25 deletions
diff --git a/src/pipeline/dispatch.rs b/src/pipeline/dispatch.rs
index d9891c2..88f300e 100644
--- a/src/pipeline/dispatch.rs
+++ b/src/pipeline/dispatch.rs
@@ -8,21 +8,15 @@ use crate::config::Config;
use crate::db::{self, builds, Db};
use crate::pipeline::{self, Outcome};
-/// Handle on a running pool. Dropping without `shutdown` leaves the threads
-/// running; call `shutdown` to join them cleanly.
pub struct Pool {
stop: Arc<AtomicBool>,
handles: Vec<JoinHandle<()>>,
}
impl Pool {
- /// Start the dispatcher and `max_concurrent_builds` workers.
pub fn spawn(cfg: Arc<Config>, db: Db) -> Pool {
let stop = Arc::new(AtomicBool::new(false));
let workers = cfg.max_concurrent_builds.max(1);
- // Bounded at the worker count: the dispatcher must not run ahead and
- // lease builds that no worker has picked up yet, because a leased build
- // whose worker never starts would sit until its lease expires.
let (tx, rx) = bounded::<String>(workers);
let mut handles = Vec::new();
@@ -53,9 +47,6 @@ impl Pool {
Pool { stop, handles }
}
- /// Ask the threads to stop and wait for them. A build that is mid-step will
- /// finish that step, fail its lease, and be requeued by the next process's
- /// reaper — which is the designed behaviour, not a bug to wait out.
pub fn shutdown(self) {
self.stop.store(true, Ordering::SeqCst);
for h in self.handles {
@@ -65,8 +56,6 @@ impl Pool {
}
fn dispatcher(cfg: Arc<Config>, db: Db, stop: Arc<AtomicBool>, tx: Sender<String>) {
- // The reaper runs first on every loop, including the first, so "recover from
- // a crash" and "notice an expired lease" are the same code path.
while !stop.load(Ordering::SeqCst) {
dispatch_once(&cfg, &db, &tx);
let mut slept = 0u64;
@@ -77,8 +66,6 @@ fn dispatcher(cfg: Arc<Config>, db: Db, stop: Arc<AtomicBool>, tx: Sender<String
}
}
-/// One dispatcher pass. Returns the ids handed to workers. Public so a test can
-/// drive one pass deterministically instead of racing a thread.
pub fn dispatch_once(cfg: &Config, db: &Db, tx: &Sender<String>) -> Vec<String> {
let reaped = builds::reap_expired(db).unwrap_or(0);
if reaped > 0 {
@@ -91,7 +78,6 @@ pub fn dispatch_once(cfg: &Config, db: &Db, tx: &Sender<String>) -> Vec<String>
)
.ok();
}
- // Blocked builds become eligible again when the blocking package arrives.
let _ = builds::requeue_blocked(db);
let _ = builds::cancel_superseded(db);
@@ -103,17 +89,12 @@ pub fn dispatch_once(cfg: &Config, db: &Db, tx: &Sender<String>) -> Vec<String>
let ids = builds::claim_batch(db, &owner, room, cfg.lease_secs).unwrap_or_default();
for id in &ids {
if tx.send(id.clone()).is_err() {
- // No worker to take it: give the lease back rather than let it
- // expire with nobody holding it.
let _ = builds::requeue_transient(db, id);
}
}
ids
}
-/// How many builds may be admitted right now (§8.2 backpressure). A build that
-/// cannot fit on disk stays queued rather than filling the filesystem halfway
-/// through a compile.
pub fn admissible(cfg: &Config, db: &Db) -> usize {
let in_flight = builds::in_flight(db).unwrap_or(0) as usize;
let slots = cfg.max_concurrent_builds.saturating_sub(in_flight);
@@ -127,7 +108,6 @@ pub fn admissible(cfg: &Config, db: &Db) -> usize {
slots
}
-/// Megabytes free on the filesystem holding `path`.
pub fn free_disk_mb(path: &std::path::Path) -> u64 {
use std::ffi::CString;
let c = match CString::new(path.as_os_str().to_string_lossy().as_bytes()) {
@@ -137,8 +117,6 @@ pub fn free_disk_mb(path: &std::path::Path) -> u64 {
let mut stat: libc::statvfs = unsafe { std::mem::zeroed() };
let rc = unsafe { libc::statvfs(c.as_ptr(), &mut stat) };
if rc != 0 {
- // If we cannot find out, do not block the queue over a measurement
- // problem; the pipeline's own disk guard is the backstop.
return u64::MAX;
}
let bsize = stat.f_frsize as u64;
@@ -155,9 +133,6 @@ fn worker(cfg: Arc<Config>, db: Db, rx: crossbeam_channel::Receiver<String>, sto
let attempt = builds::get(&db, &id).ok().flatten().map(|b| b.attempt).unwrap_or(1);
match pipeline::run(&cfg, &db, &id) {
Ok(Outcome::Failed { transient, .. }) => {
- // §8.4: transient failures retry with a bounded number of
- // attempts; a deterministic failure does not, because it would
- // produce the same answer.
if transient && attempt < cfg.max_transient_attempts {
let _ = builds::requeue_transient(&db, &id);
db::audit_system(