Skip to content

bench: record.py --cpu pins the whole build to one core, not just the measurement #3252

Closed

Description

@zackees

What

rust/tools/benchmarks/record.py --cpu N calls os.sched_setaffinity(0, {N}) on itself (:276-279) before it starts soldr cargo bench (:284, :294). Every child inherits that one-CPU affinity, so whenever the bench needs a rebuild, the whole Rust and C build runs on a single core. cargo sees available_parallelism() == 1, and the cc crate gets NUM_JOBS=1.

soldr warns about this in every such run: this build will use 10 concurrent compiles (from default), not the 1 you asked for. For example, the 2026-10-31 runs for #3187, #3197 and #3212 showed it, and a 3-repeat run took 5-7 min of mostly building. The pinned process can also start a fresh soldr daemon that inherits the pin (forge-ci/soldr#4000), so the slowdown can leak into later, unpinned builds.

--cpu 7 is the documented way to record (record.py:4, and the baselines in docs/rust-port/benchmarks/), so every recording pays this.

Proposed change

  1. Build unpinned first: soldr cargo bench -p obs-c-oracle --bench port_comparison --no-run (or let the existing --test smoke run without the pin).
  2. Apply the affinity only to the measurement runs: subprocess.run(..., preexec_fn=lambda: os.sched_setaffinity(0, {cpu})), or taskset -c N on the measurement command. Leave the parent process unpinned.
  3. Keep recording affinity in the report from the measurement child, not the parent.

Acceptance criteria

  • With --cpu, the build runs at full parallelism and only the Criterion runs are pinned.
  • ci/test_benchmark_record.py covers it. RED: the bench command runs while the parent is already pinned. GREEN: the parent stays unpinned and the pin goes to the measurement subprocess.

Parent: #3249

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions