sched: any change to a node's kept builds drops every driver's expected compiles, and the next pass works them out again for all 92,000 queued asks: 9.3 s of weighing against 0.3 s, 79% of the scheduler's thread #76

Open
opened 2026-11-14 22:05:50 +00:00 by xemmerling · 0 comments
Owner

Read on production (fec2e2f2) at 22:05Z 11-14. Data for the planner's owner; I patch nothing in sched.

What is seen

A scheduling pass is one of two kinds, and nothing in between. From the server's own warnings "a scheduling pass took long" over 25 minutes to 22:02Z (184 passes; Prometheus counts 183 passes in all, so this is every pass):

weighing in the pass passes mean weighing mean whole pass asks weighed
under 1 s 58 0.285 s 1.86 s 92,084
1 to 6 s 0
6 s and more 126 9.27 s 10.9 s 92,103

Both kinds weigh the same 92,000 asks; resolves, retold, predict and view are the same in both (3.6 against 3.1 resolves, 0.81 against 0.78 s predict). Only the cost per ask differs, 3 µs against 100 µs. Weighing took 1,178 of those 1,500 seconds: 79% of the scheduler's thread.

The slow kind comes in runs, back to back every 11 to 12 seconds (runs of 17, 17, 18, 13 in the last half hour), the fast kind likewise (runs of 22, 12, 11). Earlier notes of mine looked for a driver of the MEAN pass (people's starts, queue length) and found none above a correlation of 0.33. The mean is the mix of the two kinds.

What the code says

sched/state.rs on_event: on Input::Report(_, Report::Snapshots(_)), Input::Gone, Input::Forget or Input::Restore it runs self.told.get_mut().expected.clear(), "What a driver compiles on a node moves with the node's kept builds, and with the nodes." State::expected then works every driver's expected compiles out again (compiling and compiles::expected over its graph) the next time decide asks, which the next pass does for every queued ask.

The worker's report_loop sends a Report::Snapshots whenever any build snapshot changed since its last batch (a batch goes about once a second: t_report_batches_total reads 0.95 a second), and server/nodes/http.rs hands the scheduler Snapshots::all whenever a change applied. So any change to any session's kept build on the node drops every driver's expectation.

Why I think that is the cause, and what I did not observe

No log line or counter says when a snapshots report reaches the scheduler, so the link is inferred. It fits one figure twice:

  • After a fast pass (1.86 s) the next was slow in 28 of 106 cases, 26%. For changes arriving at random that is one change every 6 seconds.
  • At that rate a slow pass (10.9 s) is followed by another slow one with probability 1 − e^(−10.9/6) = 84%. Observed: 117 of 145, 81%.

So the scheduler has two states. Once a pass is slow, a change arrives within it four times in five and the next pass is slow too. It leaves the slow state only when eleven seconds pass without a change. That predicts 89% of the time inside slow passes at this rate; the watch read 89% of the thread inside passes.

The worker's own events (jobs launched and ended, compile slots ended) in the three seconds before a pass do not separate the kinds (2.8 against 2.2 jobs ended, 24 against 19 slots ended).

What it costs

  • A disk grow is answered inside a pass and the worker's ask gives up after 5 s: 162 asks timed out against 156 grants between 20:00Z and 21:50Z, and two jobs ended disk_full (issue #43, tonight's two sections).
  • People's jobs wait for the next pass: pickup p50 2 to 9 s, p95 10 to 12 s all evening, the length of a slow pass.
  • Ten-minute means of weighing since the 20:49Z restart: 0.4 s, 1.2, 1.9, 3.1, 7.4, 2.3, 2.8, 2.9, 3.0, 8.1, 5.6, 5.6, 8.7. After a restart it takes about twenty minutes to reach the two-state regime.

Whether it holds back starts I have not shown: cores sampled busy were 125 to 152 of 159 in the same windows.

The cost is the queue's length

One full weighing is about 0.1 ms an ask, so 9.3 s at 92,000 asks, and the queue is 592 open head runs. Two things would bound it, named here only as what the figures point at: dropping the expectations of the sessions whose kept build changed and no others (kept_for reads nodes[node].kept[ask.party]), or working an expectation out only for the asks a pass can reach.

Related: #43 (grows answered late), #53 (the predict phase, 0.8 s a pass, unchanged by this).

2026-11-14 22:37Z: the trigger, read in code: using a kept build counts as a change

  • store/made.rs hold_all sets a layer's last_used_ms to now when it is held, and Drop for Hold sets it again at release. A cargo driver holds its session's kept build from its start to its end (store/snapshots.rs pick: layers.hold_all(&[b.id, touched_id])).
  • SnapshotView carries last_used_ms (store/snapshots.rs view_of: last_used_ms: l.last_used(&b.id)), and Snapshots::changes compares whole views (before.get(id) != Some(v)). So every hold and every release of a kept build is a change, sent with the worker's next batch, about a second later.
  • sched/state.rs, Report::Snapshots(all): per owner the scheduler keeps the build with the greatest last_used_ms as that session's kept build, its state, units and trust. A driver's expectation is made of that build's state and units. A report that leaves every owner's chosen build with the same state, units and trust changes nothing an expectation is made of, and on_event clears them all the same.

The rates fit. In the last full hour of the worker's log (21:08Z to 22:08Z) 203 drivers were launched, so about 0.11 holds and releases a second. New kept builds appeared in /var/lib/t/snapshots once every 12 seconds in a five-minute probe (28 in 339 s), 0.08 a second. Together 0.19 a second, against the 0.16 a second the two kinds of pass imply above.

So what the figures point at is narrower than my first note: after a snapshots report is applied, clear the expectations of the owners whose chosen build's state, units or trust differ, and no others. Most reports would then clear nothing.

2026-11-14 22:45Z: observed, not only inferred: a pass that follows a change of the kept builds is the slow kind

A read-only probe read the node's /var/lib/t/snapshots four times a second from 22:30Z to 22:43Z (newest entry, entry count, directory time) and noted each change: 46 in thirteen minutes, nearly all a newly kept build. Set beside the 74 passes of the last five and a half minutes of it, each pass asked whether the directory changed since the pass before it began:

passes with a change on disk since the pass before began
slow, weighing 6 s or more 20 12
fast, weighing under 1 s 54 1

Of 13 passes that followed a change on disk, 12 were slow. Of 61 that followed none, 53 were fast. The eight slow passes with no change on disk fit the part the disk does not show: a build's last-use time, stamped in memory when a driver takes or lets go of it.

2026-11-14 22:48Z: what it does not cost, so its weight is not overstated

Minute by minute from 21:10Z to 22:48Z (Prometheus), sorted by the share of the minute spent weighing:

minutes how many passes a minute cores sampled busy minutes under 143 cores jobs started a minute
25% or less weighing 2 28.0 155.8 0 2.7
between 41 14.5 146.2 13 47.6
70% or more weighing 56 7.2 144.6 24 47.5

The scheduler was in the fast regime for two minutes of ninety-eight, so the evening holds no baseline to measure it against. Between the mixed and the slow minutes the node kept 1.6 more cores busy and started as many jobs. The ten minutes after the 20:49Z restart, when passes were fast, had 144 to 158 cores busy, the same level. So I can show no loss of the node's work to the slow passes. What they cost is what the first note lists: grows answered after the worker gave up, and people's jobs waiting a pass.

Read on production (fec2e2f2) at 22:05Z 11-14. Data for the planner's owner; I patch nothing in `sched`. ## What is seen A scheduling pass is one of two kinds, and nothing in between. From the server's own warnings "a scheduling pass took long" over 25 minutes to 22:02Z (184 passes; Prometheus counts 183 passes in all, so this is every pass): | weighing in the pass | passes | mean weighing | mean whole pass | asks weighed | |---|---|---|---|---| | under 1 s | 58 | 0.285 s | 1.86 s | 92,084 | | 1 to 6 s | 0 | | | | | 6 s and more | 126 | 9.27 s | 10.9 s | 92,103 | Both kinds weigh the same 92,000 asks; resolves, retold, predict and view are the same in both (3.6 against 3.1 resolves, 0.81 against 0.78 s predict). Only the cost per ask differs, 3 µs against 100 µs. Weighing took 1,178 of those 1,500 seconds: 79% of the scheduler's thread. The slow kind comes in runs, back to back every 11 to 12 seconds (runs of 17, 17, 18, 13 in the last half hour), the fast kind likewise (runs of 22, 12, 11). Earlier notes of mine looked for a driver of the MEAN pass (people's starts, queue length) and found none above a correlation of 0.33. The mean is the mix of the two kinds. ## What the code says `sched/state.rs` `on_event`: on `Input::Report(_, Report::Snapshots(_))`, `Input::Gone`, `Input::Forget` or `Input::Restore` it runs `self.told.get_mut().expected.clear()`, "What a driver compiles on a node moves with the node's kept builds, and with the nodes." `State::expected` then works every driver's expected compiles out again (`compiling` and `compiles::expected` over its graph) the next time `decide` asks, which the next pass does for every queued ask. The worker's `report_loop` sends a `Report::Snapshots` whenever any build snapshot changed since its last batch (a batch goes about once a second: `t_report_batches_total` reads 0.95 a second), and `server/nodes/http.rs` hands the scheduler `Snapshots::all` whenever a change applied. So any change to any session's kept build on the node drops every driver's expectation. ## Why I think that is the cause, and what I did not observe No log line or counter says when a snapshots report reaches the scheduler, so the link is inferred. It fits one figure twice: - After a fast pass (1.86 s) the next was slow in 28 of 106 cases, 26%. For changes arriving at random that is one change every 6 seconds. - At that rate a slow pass (10.9 s) is followed by another slow one with probability 1 − e^(−10.9/6) = 84%. Observed: 117 of 145, 81%. So the scheduler has two states. Once a pass is slow, a change arrives within it four times in five and the next pass is slow too. It leaves the slow state only when eleven seconds pass without a change. That predicts 89% of the time inside slow passes at this rate; the watch read 89% of the thread inside passes. The worker's own events (jobs launched and ended, compile slots ended) in the three seconds before a pass do not separate the kinds (2.8 against 2.2 jobs ended, 24 against 19 slots ended). ## What it costs - A disk grow is answered inside a pass and the worker's ask gives up after 5 s: 162 asks timed out against 156 grants between 20:00Z and 21:50Z, and two jobs ended `disk_full` (issue #43, tonight's two sections). - People's jobs wait for the next pass: pickup p50 2 to 9 s, p95 10 to 12 s all evening, the length of a slow pass. - Ten-minute means of weighing since the 20:49Z restart: 0.4 s, 1.2, 1.9, 3.1, 7.4, 2.3, 2.8, 2.9, 3.0, 8.1, 5.6, 5.6, 8.7. After a restart it takes about twenty minutes to reach the two-state regime. Whether it holds back starts I have not shown: cores sampled busy were 125 to 152 of 159 in the same windows. ## The cost is the queue's length One full weighing is about 0.1 ms an ask, so 9.3 s at 92,000 asks, and the queue is 592 open head runs. Two things would bound it, named here only as what the figures point at: dropping the expectations of the sessions whose kept build changed and no others (`kept_for` reads `nodes[node].kept[ask.party]`), or working an expectation out only for the asks a pass can reach. Related: #43 (grows answered late), #53 (the predict phase, 0.8 s a pass, unchanged by this). ## 2026-11-14 22:37Z: the trigger, read in code: using a kept build counts as a change - `store/made.rs` `hold_all` sets a layer's `last_used_ms` to now when it is held, and `Drop for Hold` sets it again at release. A cargo driver holds its session's kept build from its start to its end (`store/snapshots.rs` `pick`: `layers.hold_all(&[b.id, touched_id])`). - `SnapshotView` carries `last_used_ms` (`store/snapshots.rs` `view_of`: `last_used_ms: l.last_used(&b.id)`), and `Snapshots::changes` compares whole views (`before.get(id) != Some(v)`). So every hold and every release of a kept build is a change, sent with the worker's next batch, about a second later. - `sched/state.rs`, `Report::Snapshots(all)`: per owner the scheduler keeps the build with the greatest `last_used_ms` as that session's kept build, its state, units and trust. A driver's expectation is made of that build's state and units. A report that leaves every owner's chosen build with the same state, units and trust changes nothing an expectation is made of, and `on_event` clears them all the same. The rates fit. In the last full hour of the worker's log (21:08Z to 22:08Z) 203 drivers were launched, so about 0.11 holds and releases a second. New kept builds appeared in `/var/lib/t/snapshots` once every 12 seconds in a five-minute probe (28 in 339 s), 0.08 a second. Together 0.19 a second, against the 0.16 a second the two kinds of pass imply above. So what the figures point at is narrower than my first note: after a snapshots report is applied, clear the expectations of the owners whose chosen build's state, units or trust differ, and no others. Most reports would then clear nothing. ## 2026-11-14 22:45Z: observed, not only inferred: a pass that follows a change of the kept builds is the slow kind A read-only probe read the node's `/var/lib/t/snapshots` four times a second from 22:30Z to 22:43Z (newest entry, entry count, directory time) and noted each change: 46 in thirteen minutes, nearly all a newly kept build. Set beside the 74 passes of the last five and a half minutes of it, each pass asked whether the directory changed since the pass before it began: | | passes | with a change on disk since the pass before began | |---|---|---| | slow, weighing 6 s or more | 20 | 12 | | fast, weighing under 1 s | 54 | 1 | Of 13 passes that followed a change on disk, 12 were slow. Of 61 that followed none, 53 were fast. The eight slow passes with no change on disk fit the part the disk does not show: a build's last-use time, stamped in memory when a driver takes or lets go of it. ## 2026-11-14 22:48Z: what it does not cost, so its weight is not overstated Minute by minute from 21:10Z to 22:48Z (Prometheus), sorted by the share of the minute spent weighing: | minutes | how many | passes a minute | cores sampled busy | minutes under 143 cores | jobs started a minute | |---|---|---|---|---|---| | 25% or less weighing | 2 | 28.0 | 155.8 | 0 | 2.7 | | between | 41 | 14.5 | 146.2 | 13 | 47.6 | | 70% or more weighing | 56 | 7.2 | 144.6 | 24 | 47.5 | The scheduler was in the fast regime for two minutes of ninety-eight, so the evening holds no baseline to measure it against. Between the mixed and the slow minutes the node kept 1.6 more cores busy and started as many jobs. The ten minutes after the 20:49Z restart, when passes were fast, had 144 to 158 cores busy, the same level. So I can show no loss of the node's work to the slow passes. What they cost is what the first note lists: grows answered after the worker gave up, and people's jobs waiting a pass.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
tilo/t#76
No description provided.