job_queue: drop insert_unless_live, accept extra queue passes
mara chose to accept extra queued sweep passes over adding a new hive-jobq primitive (or a hive-c0re one-off) for "don't queue another of this kind". Every sweep caller now plain-inserts its node; the capacity-1 Dep::Resource per sweep kind (MatrixSweep/KnowledgeTree) still keeps two passes of the same kind from running concurrently, it just no longer collapses a tick that lands while one is live or queued into the existing one.
This commit is contained in:
parent
1d4c77d2c8
commit
313d582c01
6 changed files with 37 additions and 90 deletions
|
|
@ -226,23 +226,17 @@ async fn main() -> Result<()> {
|
|||
}
|
||||
}
|
||||
|
||||
/// One periodic sweep tick. It folds into a pass already queued or running
|
||||
/// instead of stacking another behind it, since that pass does the same work.
|
||||
/// One periodic sweep tick. Queues unconditionally; the node's own
|
||||
/// capacity-1 resource dep (`Resource::MatrixSweep` / `KnowledgeTree`) is
|
||||
/// what keeps two passes of the same kind from running together, so a tick
|
||||
/// landing while one is live just queues one more pass behind it.
|
||||
fn submit_periodic_sweep(
|
||||
coord: &Coordinator,
|
||||
kind: &job_queue::NodeKind,
|
||||
declare: impl FnOnce(&job_queue::JobBuilder) -> job_queue::Handle<'_>,
|
||||
) {
|
||||
let live = [job_queue::State::Pending, job_queue::State::Running];
|
||||
match coord.job_queue.insert_unless_live(kind, &live, declare) {
|
||||
Ok(Some(_)) => {}
|
||||
Ok(None) => tracing::debug!(
|
||||
kind = <&str>::from(kind),
|
||||
"periodic sweep: one already queued or running; folded into it"
|
||||
),
|
||||
Err(e) => {
|
||||
tracing::warn!(kind = <&str>::from(kind), error = ?e, "periodic sweep: submit failed");
|
||||
}
|
||||
if let Err(e) = coord.job_queue.insert_job(|b| vec![declare(b).guid()]) {
|
||||
tracing::warn!(kind = <&str>::from(kind), error = ?e, "periodic sweep: submit failed");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue