Skip to content

feat(host-load): Linux load is measured against a cgroup v2 limit - #565

Merged
V3RON merged 8 commits into
task/531from
task/532
Oct 14, 2026
Merged

V3RON merged 8 commits into
task/531from
task/532

Conversation

@V3RON

@V3RON V3RON commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Closes #532

Status

Implement: done Review: round 2, 2 test fixes unreviewed Hardware: n/a Gate: waiting for the stack

Done when

  • Every test above is green, on Linux CI. Each row of the inputs table is one of their cases (CI; table rows probed by audit and review).

Assumptions

  • Assumption: nowMicros is a required input of LinuxHostLoadProbeOptions — the spec says the factory passes it, so there is no Date.now() fallback.
  • Assumption: busy % under a CPU limit is usage ÷ (elapsed × the limit's cores), so 6.1 s over 10 s on 2 cores is 30.5% (decided in delivery, pending the maintainer; see the ## Decision taken comment).
  • Assumption: in the accepted cpu.max table case the limit's folder also has cpu.stat (decided in delivery, pending the maintainer).

Review

Spec review: 2 blocking, 2 fixed, 1 notes. Code review: 7 blocking, 7 fixed, 0 notes. Claims review: 0 blocking, 0 fixed, 1 notes.
Rounds: 2. Tokens: 6.6M.

Rejected:

  • code: duplicate of a spec finding on optional nowMicros, kept once
  • spec: the same test written twice at host-load.test.ts:671 and :753 — breaks no behaviour

Written by an agent.

@V3RON

V3RON commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

Decision taken

Question. The spec's sampler test line says busy % under a CPU limit is "usage over elapsed time × the limit's cores", and its test expects 61% for 6.1 s of usage over 10 s on a 2-core limit. The feature defines busy % as the share of CPU time available. Also, one table test seeded a CPU limit with no cpu.stat and expected cores, which the "leave CPU out when cpu.stat is missing" line contradicts.

Options.

  1. Busy % = usage ÷ (elapsed × cores) = 30.5%. A user on a 2-core container sees CPU 31% busy (2 cores, limit) for 6.1 s over 10 s. (taken)
  2. Busy % = usage ÷ elapsed = 61%, which can exceed 100% of what the limit allows. A user would see a figure that is not a share of the limit.

For the table test: seed cpu.stat on the limit's folder (taken), or drop the missing-cpu.stat rule (would show cores with no CPU reading).

Why. Option 1 matches the feature's "busy %" definition and the figure stays 0–100%. It is the one closest to the stated outcome.

Reverting. Change the divisor in src/ports/host-load.ts and the expected value in src/host-load/sampler.test.ts; one line each.

Written by an agent.

@V3RON

V3RON commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

Review notes

Not blocking, not verified. Each is one reviewer's claim.

  • spec: src/ports/host-load.ts:259 if the winning limit's folder changes between reads with the same core count, busy compares usage_usec from two cgroups for one reading.

Written by an agent.

@V3RON
V3RON merged commit a79e0a0 into main Oct 14, 2026
35 of 45 checks passed
@V3RON
V3RON deleted the task/532 branch October 14, 2026 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Linux load is measured against a cgroup v2 CPU or memory limit and marked limit

1 participant