From e757979f1a2afdbe7146066345bb9acd19d3b151 Mon Sep 17 00:00:00 2001 From: aur-build Date: Thu, 19 Nov 2026 17:09:59 +0000 Subject: comments: say why, not what MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Every module-level `//!` header is gone, and the comments that remained either re-explained the line below them or had grown into paragraphs. Density went from one comment line per 6.7 lines of code to one per 10. 827 insertions against 2194 deletions across 86 files. What survived: the invariants (I1-I12), the design cross-references into DESIGN.md, and the notes recording a bug that was found and fixed — those are the comments that carry weight, because they answer a question the code cannot answer about itself. What did not: restating a function signature in prose, and narration of the statement underneath. --- src/pipeline/dispatch.rs | 39 ++++++++------------------------------- 1 file changed, 8 insertions(+), 31 deletions(-) (limited to 'src/pipeline/dispatch.rs') diff --git a/src/pipeline/dispatch.rs b/src/pipeline/dispatch.rs index 62052fd..d9891c2 100644 --- a/src/pipeline/dispatch.rs +++ b/src/pipeline/dispatch.rs @@ -1,21 +1,3 @@ -//! The dispatcher actor, the worker pool and the reaper (§8.2). -//! -//! Shape: one dispatcher thread, N worker threads, one crossbeam channel -//! between them. The dispatcher's loop is -//! -//! ```text -//! reaper: expired leases -> queued, in-flight step -> interrupted -//! cancel: superseded in-flight builds -> cancel_requested -//! claim: BEGIN IMMEDIATE { SELECT queued LIMIT admissible; UPDATE leased } -//! send: build_tx.send(id) for each -//! ``` -//! -//! Nothing lives only in a worker's memory. If the process is killed, the lease -//! expires and the next dispatcher pass puts the build back; the step -//! checkpoint decides where it resumes (I5). That is the whole crash-recovery -//! story, and it is why there is no separate "recover on startup" routine — the -//! reaper pass *is* the recovery, and it runs first in every loop. - use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; use std::thread::JoinHandle; @@ -83,9 +65,8 @@ impl Pool { } fn dispatcher(cfg: Arc, db: Db, stop: Arc, tx: Sender) { - // The reaper pass runs first on every loop, including the very first one, so - // "recover from a crash" and "notice an expired lease" are the same code - // path. There is no special startup recovery to get wrong. + // 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; @@ -112,7 +93,6 @@ pub fn dispatch_once(cfg: &Config, db: &Db, tx: &Sender) -> Vec } // Blocked builds become eligible again when the blocking package arrives. let _ = builds::requeue_blocked(db); - // A newer approval makes an in-flight build pointless (§8.2). let _ = builds::cancel_superseded(db); let room = admissible(cfg, db); @@ -131,10 +111,9 @@ pub fn dispatch_once(cfg: &Config, db: &Db, tx: &Sender) -> Vec ids } -/// How many builds may be admitted right now (§8.2 backpressure): -/// `min(max_concurrent - in_flight, disk headroom)`. A build that cannot fit on -/// disk is not admitted — it stays queued rather than filling the filesystem -/// halfway through a compile. +/// 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); @@ -176,11 +155,9 @@ fn worker(cfg: Arc, db: Db, rx: crossbeam_channel::Receiver, 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 (network, mirror 5xx) retry with a - // bounded number of attempts. A deterministic build failure - // does NOT retry — the release stays approved_but_unbuilt and - // the UI says "index still serving v1". Retrying that would burn - // a chroot to produce the same failure. + // §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( -- cgit v1.2.3