Skip to content

Add support for explicit per-runner CPU affinity #390

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion bench_runner/scripts/run_benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def run_benchmarks(
benchmarks: str,
/,
test_mode: bool = False,
extra_args: Iterable[str] | None = None,
extra_args: list[str] | None = None,
) -> None:
if benchmarks.strip() == "":
benchmarks = "all"
Expand All @@ -82,6 +82,9 @@ def run_benchmarks(
if extra_args is None:
extra_args = []

if affinity := os.environ.get("CPU_AFFINITY"):
extra_args.append(f"--affinity={affinity}")

args = [
sys.executable,
"-m",
Expand Down
6 changes: 5 additions & 1 deletion bench_runner/templates/_benchmark.src.yml
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ jobs:
- name: Tune system
if: ${{ steps.should_run.outputs.should_run != 'false' }}
run: |
sudo LD_LIBRARY_PATH=$LD_LIBRARY_PATH venv/bin/python -m pyperf system ${{ inputs.perf && 'reset' || 'tune' }}
sudo LD_LIBRARY_PATH=$LD_LIBRARY_PATH venv/bin/python -m pyperf system ${{ inputs.perf && 'reset' || 'tune ${CPU_AFFINITY:+--affinity="$CPU_AFFINITY"}' }}
- name: Tune for (Linux) perf
if: ${{ steps.should_run.outputs.should_run != 'false' && inputs.perf }}
run: |
Expand All @@ -232,6 +232,10 @@ jobs:
run: |
rm -rf ~/.debug/*
venv/bin/python -m bench_runner run_benchmarks ${{ inputs.perf && 'perf' || 'benchmark' }} cpython/python ${{ inputs.fork }} ${{ inputs.ref }} ${{ inputs.benchmarks || 'all' }} ${{ env.flags }} --run_id ${{ github.run_id }}
- name: Untune system
if: ${{ steps.should_run.outputs.should_run != 'false' }}
run: |
sudo LD_LIBRARY_PATH=$LD_LIBRARY_PATH venv/bin/python -m pyperf system reset
# Pull again, since another job may have committed results in the meantime
- name: Pull benchmarking
if: ${{ steps.should_run.outputs.should_run != 'false' && !inputs.perf }}
Expand Down