Skip to content

Leave host tuning in place until the host reboots - #1153

Merged
epompeii merged 1 commit into
u/ep/runner/file-size-orderfrom
u/ep/runner/tuning-no-revert
Oct 9, 2026
Merged

epompeii merged 1 commit into
u/ep/runner/file-size-orderfrom
u/ep/runner/tuning-no-revert

Conversation

@epompeii

@epompeii epompeii commented Oct 9, 2026

Copy link
Copy Markdown
Member

What

Make the runner apply its host tuning and never revert it.

  • The save and restore machinery is removed: each setting's saved original, the restore when the guard drops, and the removal of the bencher cgroup on exit. apply_cpu_scoped loses its guard parameter.
  • apply_cpu_scoped passes / to a private apply_cpu_scoped_at, which takes the filesystem root, so a test can run the CPU-scoped tuning on a fake host. The partition's cgroup root is <root>/sys/fs/cgroup, and the IRQ and workqueue steering already took the root.
  • TuningGuard holds only the C-state constraint, which the kernel releases when the process exits. It is #[must_use], so a call that drops it at once fails clippy with -D warnings.
  • The host tuning lock stays: it still keeps a second runner from retuning the host under the first one's Jobs.
  • The reference docs, in all 9 languages, say that tuning persists until the host reboots, that a shared host should be rebooted after the runner is removed, and that the flags keep a host default only on a host the runner has not tuned since it last booted. The --help texts say what each flag skips, such as Do not disable ASLR, rather than what it keeps.
  • host_tuning asserts that every setting it exercises still holds its target after the runner exits, that the cpuset partition still reads the level the runner reports, and, whenever the runner reports the C-state hold, that /dev/cpu_dma_latency reads 0 while the runner runs. Its harness then restores every setting from its own snapshot, each CPU's governor and the turbo switches included, and removes the bencher cgroup, which undoes the partition. TEST.md says the same.
  • The unit tests of the restore are removed, and so is apply_returns_guard, which, run as root before the scenarios, would tune that host for good.
  • The 2 tests that pinned the CPU-scoped gates through the saved values become 2 tests on a fake host tree: the_opt_outs_leave_the_partition_and_the_steering_masks_alone and a_single_cpu_skips_cpu_scoped_tuning.

Why

The guard saved each original value and restored it on drop, but a self-update exec, SIGKILL, and OOM all skip the drop, and the process that follows then saved the tuned values as its originals. A restore that holds only on a clean exit cannot be relied on, and one that saves tuned values restores nothing.

Every setting is a runtime-only write, so a reboot undoes all of it. That gives one rule an operator can count on: the tuning lasts until the host reboots.

Verification

  • host_tuning with the previous runner fails, Host tuning did not persist after the runner exited, with 7 settings back at their originals. With this runner it passes 20 of 20.
  • A runner that drops the guard at once fails host_tuning 20 of 20: The runner reported holding C-states, but /dev/cpu_dma_latency never read 0 while it ran. That spelling, and let _ =, also fail clippy at both call sites, on Linux and macOS.
  • 4 restart tests on a fake sysfs tree, seeded the way the kernel prints, pin what a restart writes. In a_restart_leaves_an_already_set_value_unwritten, a_restart_leaves_a_steered_irq_unwritten, and a_restart_finds_the_partition_in_place, a value already in place stays unwritten; in a_partition_left_invalid_is_applied_again, a partition the kernel left invalid is written again. Each passes on the previous code too. Mutations that drop an equality check, compare without trimming, or skip the partition mode when it already reads isolated each fail exactly one of them.
  • The 2 gate tests run the CPU-scoped tuning under a fake host root that holds an untuned cgroup root, IRQ masks, and the workqueue cpumask, and require every path and file in it to stay unchanged. the_opt_outs_leave_the_partition_and_the_steering_masks_alone runs --no-cpuset-partition and --no-irq-steering on an 8-core layout; a_single_cpu_skips_cpu_scoped_tuning runs the default config on a 1-core layout. They run unprivileged and touch no real /sys or /proc.
    • Dropping either opt-out from its gate fails the first test, and dropping the isolation check from either gate fails the second, each 20 of 20 as an ordinary user and as root, while the other test stays green.
    • The gates predate this change, so these tests guard them rather than going red on the previous code.
  • The harness restores the governor and turbo: with stand-in cpufreq files in a private mount namespace, it put boost and 2 CPUs' governors back after the scenario in 3 of 3 runs, where a harness without them left all 3 tuned in 2 of 2.
  • In a 16 vCPU lab VM, runner up tuned the host and was killed with SIGKILL, and the host stayed tuned. A restart logged already for every sysctl, both THP files, and SMT, and changed no value. A reboot brought the host back to its fresh-boot state.
  • With one runner up running, a second started with --thp madvise printed Tuning: skipped (another bencher runner is active on this host), and THP stayed at never.
  • The runner unit tests pass as an ordinary user and as root, the scenario suite passes as root with the host's state the same before and after it, and clippy passes with -D warnings for Linux x86_64, Linux aarch64, and macOS.

@epompeii
epompeii added this pull request to stack #1115 October 9, 2026 04:34
@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

ProjectBencher
Branchu/ep/runner/tuning-no-revert
Testbedintel-v1
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
microseconds (µs)
(Result Δ%)
Upper Boundary
microseconds (µs)
(Limit %)
Adapter::Json📈 view plot
🚷 view threshold
5.17 µs
(-1.02%)Baseline: 5.23 µs
5.46 µs
(94.65%)
Adapter::Magic (JSON)📈 view plot
🚷 view threshold
5.02 µs
(-0.34%)Baseline: 5.04 µs
5.23 µs
(96.02%)
Adapter::Magic (Rust)📈 view plot
🚷 view threshold
24.11 µs
(-8.15%)Baseline: 26.25 µs
32.60 µs
(73.97%)
Adapter::Rust📈 view plot
🚷 view threshold
4.47 µs
(-3.69%)Baseline: 4.64 µs
5.18 µs
(86.32%)
Adapter::RustBench📈 view plot
🚷 view threshold
4.47 µs
(-3.47%)Baseline: 4.63 µs
5.17 µs
(86.44%)
🐰 View full continuous benchmarking report in Bencher

@epompeii
epompeii marked this pull request as ready for review October 9, 2026 05:03
The tuning guard saved each original value and restored it on drop, but
a self-update exec, SIGKILL, and OOM all skip the drop, and the process
that follows then saved the tuned values as its originals. The runner
now applies its tuning and never reverts it. The reference docs say that
it persists until the host reboots, and that the flags keep a host
default only on a host the runner has not tuned since it booted; their
help says what each flag skips rather than what it keeps.

The C-state hold stays, since the kernel releases it when the process
exits. So does the host tuning lock, which still keeps a second runner
from retuning the host under the first one's Jobs. The guard that holds
the C-state constraint is now `#[must_use]`, so a call that drops it at
once fails clippy under `-D warnings`. The host_tuning scenario now asserts that the
tuning outlives the runner and that the C-state hold reads 0 while the
runner runs, and its harness undoes the tuning, each CPU's governor and
the turbo switches included.
@epompeii
epompeii marked this pull request as draft October 9, 2026 09:18
@epompeii
epompeii force-pushed the u/ep/runner/tuning-no-revert branch from 1c8f5f1 to e4b1dac Compare October 9, 2026 09:18
@epompeii
epompeii marked this pull request as ready for review October 9, 2026 14:22
@epompeii
epompeii merged commit 7276597 into devel Oct 9, 2026
54 of 55 checks passed
@epompeii
epompeii deleted the u/ep/runner/tuning-no-revert branch October 9, 2026 14:53
epompeii added a commit that referenced this pull request Oct 12, 2026
## Problem

`Lint / Zizmor Online` fails on every pull request (for example run
37884500334 on #1153) with one medium finding, exit 13:

```
warning[ref-version-mismatch]: action's hash pin has mismatched or missing version comment
  --> ./.github/workflows/update_sandbox.yml:18:81
18 |       - uses: dtolnay/rust-toolchain@7e38f4b # v1
   |                                                                                 ^^ points to commit e2a55d2ffb04
```

The upstream `v1` tag of `dtolnay/rust-toolchain` moved to
`e2a55d2ffb04f378e9626c28d38b36d230d1e12f` on 2026-10-09 when
dtolnay/rust-toolchain#187 merged. The job is `continue-on-error: true`,
so it does not block a merge, but it is red on every open pull request.

## Change

Repin `update_sandbox.yml` to the commit `v1` points at today and keep
the `# v1` comment. This follows #987, #1045, and #1088, which tracked
`v1` for this same pin, and `v1` is the only tag upstream publishes. The
hash was resolved from the GitHub refs API.

## Upstream range

`7e38f4b4...e2a55d2f` is three commits, all in `action.yml`, fixing the
command injection reported in dtolnay/rust-toolchain#179:

- Every input and the parsed toolchain move out of inline `${{ }}`
expressions in `run:` scripts and into `env:` variables, quoted at each
use.
- The parsed `toolchain` output is written with a heredoc delimiter
instead of `key=value`.
- The separate step that built `--target`, `--component`, and
`--allow-downgrade` strings is folded into the install step as a bash
array.

This call site passes only `toolchain: stable`, no targets or
components, so it was never exposed, and it still runs `rustup toolchain
install stable --profile minimal --no-self-update --force-non-host`
followed by `rustup default stable --force-non-host`. No other workflow
or composite action uses this action.

## Other moving refs

Every other pin whose comment names a moving ref still matches it today:
`rui314/setup-mold@10ca16bf # v1` (14 sites),
`dawidd6/action-download-artifact@b6e2e706 # v21` (2 sites), and
`superfly/flyctl-actions/setup-flyctl@ed8efb33 # master` (3 sites, the
current `master` head). Nothing else needs a change.

## Verification

zizmor 1.25.2, the version CI pins, from the same digest-pinned image
`zizmor-action` runs
(`ghcr.io/zizmorcore/zizmor:1.25.2@sha256:14ea7f5c...`), with the
action's arguments (`--persona=regular --format=github`, plus
`--no-online-audits` for the offline job):

| Tree | Offline | Online |
| --- | --- | --- |
| `devel` | exit 0 | exit 13, `1 medium` (the finding above) |
| this branch | exit 0 | exit 0, `No findings to report` |

CI on this pull request is the final check.
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