8000 Background services in the background: idle groups, mq-deadline, the efficiency cores (ADR 0066 step 5) by NateIsern · Pull Request #537 · OxyHQ/OxyOS · GitHub
[go: up one dir, main page]

Skip to content

Background services in the background: idle groups, mq-deadline, the efficiency cores (ADR 0066 step 5) - #537

Open
NateIsern wants to merge 2 commits into
mainfrom
perf/background-services
Open

NateIsern wants to merge 2 commits into
mainfrom
perf/background-services

Conversation

@NateIsern
Copy link
Copy Markdown
Member

ADR 0066, decision 6 (step 5): background work really in the background.

  • oxyos-backupd.service: CPUWeight=idle (the group's cpu.idle) and IOWeight=10, beside its idle scheduling and I/O classes. A thread's idle class orders it only inside its own control group; the backup's group sat in system.slice, which weighs as much as the person's user.slice, so on a saturated machine a backup took as much as everything the person ran.
  • oxyos-installd / oxyos-app-fetch: utility class, CPUWeight=20, IOWeight=20, nice 10; the compiler's transient unit the same (a sibling of the service's, it inherits nothing). The root sandbox test now checks the compiler's nice and its group's weight.
  • 60-oxyos-io-scheduler.rules: solid-state NVMe and SATA drives use mq-deadline, which honours the real-time / best-effort / idle classes; none (the kernel's choice for NVMe) ignores them.
  • oxyos-efficiency-cores (a systemd generator, system and user managers): on a hybrid processor the backup service and each user's background.slice run on the efficiency cores (AllowedCPUs; Intel cpu_atom, or the CPUs of least cpu_capacity on big.LITTLE); nothing on a processor of one kind. ThinkPad: 8–15.
  • user@.service.d/50-oxyos-delegate.conf: users' managers are delegated cpuset and io too (for background.slice's cores and the applications' disk weights).
  • Deploy: every one of these installed (system-files, checked against the image by system-files.py), the drives given their scheduler at once (a udev change event) and checked, the backup service's group checked idle. A signed-in person's user manager takes its new controllers and cores at their next login.

io.cost (the only controller weighing groups on mq-deadline, and buffered writeback) is not turned on: it needs a per-drive cost model and latency targets, or it can hold a fast drive below its throughput; IOWeight is declared for when it is.

ADR 0059 decision 2 and ADR 0030 decision 5 amended; docs/developing.mdx says what the deploy installs. Benchmark numbers (S0/S5, A/B interleaved on seldon and the ThinkPad) follow in a comment and in ADR 0066's step 5 once #509 lands.

🤖 Generated with Claude Code

@NateIsern
Copy link
Copy Markdown
Member Author

Saturation benchmark, S0 and S5 (perf.py saturation, PR #538), A = main's units (bench's tree), B = this branch (bench's tree + this PR, the image's generators applied to the fixture's backup unit as systemd would), interleaved A B A B, --runs 3 each, medians over the A runs and over the B runs. Input to present (device time), ms.

ThinkPad (perf-device.sh rules: seat0 idle, Intel render node only, the whole run at nice 19 / CPUWeight 1; 16 CPUs; elevator none in both, the udev rule's mq-deadline comes with the deploy). Four pairs. B's backup was given cpu.idle 1, io.weight default 10, cpuset.cpus 8-15 (the E-cores, from the generator).

S5 A p50 / p95 / p99 B p50 / p95 / p99 compositor wait µs a run A → B session CPU pressure % A → B
drag (late frames 0 both) 5.0 / 104.9 / 117.3 4.95 / 10.3 / 15.3 70 → 9 1.85 → 0.74
typing 9.65 / 21.3 / 24.4 8.6 / 12.5 / 14.4 93 → 48 2.27 → 1.04
pointer 6.0 / 18.9 / 33.7 6.65 / 14.6 / 365 † 105 → 35 2.2 → 1.08
scroll 8.75 / 36.3 / 44.5 † 9.95 / 360 / 488 † 102 → 27 3.12 → 0.70

S0 (unloaded) is the same in A and B: drag p95 5.25 / 5.35, typing 7.75 / 7.7, pointer 5.95 / 6.05, scroll 7.95 / 8.1.
The loads still progress, and no slower: backup 0.10 → 0.15 runs/s (5.3 → 3.2 cores: now on the E-cores alone), index 799 → 827 files/s (scroll runs; 218 → 877 in typing's).

† A host bug, not this change (bench found it): in most scroll runs and some pointer runs of both A and B (and at S0) the host logs the GPU path stops (no GPU buffer was released within a second): drawing on the CPU — one frame waits ~1 s and the window draws on the CPU after. Runs where that second-long frame falls inside the measured window give p95/p99 ≈ 700–950 ms; they fall in A and B alike (S0 scroll: A 695.9 in one run, B 701.1 in one). Scroll's p95 here says nothing about this PR; drag and typing never hit it.

seldon (8 CPUs 8-11,24-27; A with none, B with mq-deadline switched for its runs and restored to none after; 2 pairs): inconclusive. The machine's own load moved between 40 and 250 during the runs, and S0 itself differed between A and B by more than any S5 effect (S0 typing p95 4.7 vs 8.05, compositor wait 5 vs 72 µs), so no A/B difference there can be attributed. No E-cores (Ryzen 9950X), so only cpu.idle and the elevator differed.

The sandbox test as root (CI's --ignored one) passes on seldon: the compiler's unit runs at nice 10 with cpu.weight 20.

NateIsern and others added 2 commits November 10, 2026 08:13
…efficiency cores

ADR 0066, decision 6. The backup service's threads were in the scheduler's idle class, which orders
them only among the threads of their own control group; that group sat in system.slice, which
weighs as much as the person's user.slice, so on a saturated machine a backup took as much as
everything the person ran. And its reads' idle class did nothing on an NVMe drive, whose scheduler
the kernel leaves at `none`, which ignores I/O priority.

- oxyos-backupd.service: CPUWeight=idle (cpu.idle: the group itself yields to its siblings) and
  IOWeight=10, beside its idle scheduling and I/O classes.
- oxyos-installd and oxyos-app-fetch: the utility class, CPUWeight=20, IOWeight=20, nice 10; and
  the compiler's transient unit the same (a sibling of the service's, it inherits nothing). The
  sandbox test run as root now checks the compiler's nice and its group's weight.
- 60-oxyos-io-scheduler.rules: solid-state NVMe and SATA drives use mq-deadline, which honours the
  real-time, best-effort and idle classes (since Linux 5.14) at a small cost per request.
- oxyos-efficiency-cores, a systemd generator for the system's manager and each user's: on a hybrid
  processor (Intel's cpu_atom beside cpu_core; elsewhere the CPUs of least cpu_capacity) it holds
  the backup service and a user's background.slice to the efficiency cores (AllowedCPUs), as a Mac
  runs its background class on its efficiency cluster; on a processor of one kind it writes nothing.
- user@.service.d/50-oxyos-delegate.conf: users' managers are delegated cpuset and io too, so
  background.slice can be held to those cores and applications' scopes given disk weights.
- The deploy installs all of it (tools/deploy/system-files, checked against the image's udev rules,
  generators and drop-ins by system-files.py), gives the drives their scheduler at once (a change
  event) and checks it, and checks the backup service's group is idle. A signed-in person's manager
  takes its new controllers and cores at their next login.

io.cost, the only controller that weighs groups on a drive with mq-deadline (and buffered
writeback), is not turned on: it needs a cost model and latency targets measured for each drive, or
it can hold a fast drive below what it does. IOWeight is declared for when it is.

ADR 0059 (decision 2) and ADR 0030 (decision 5) amended; docs/developing.mdx says what the deploy
installs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@NateIsern
NateIsern force-pushed the perf/background-services branch from 82bbb3e to 3f55ac6 Compare November 10, 2026 06:14
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.

1 participant

0