Skip to content

Commit 2d07d4b

Browse files
authored
Merge pull request #390 from Yhg1s/cpu_affinity
Add support for explicit per-runner CPU affinity
2 parents 04c4316 + c3a12b1 commit 2d07d4b

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

Diff for: bench_runner/scripts/run_benchmarks.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def run_benchmarks(
6666
benchmarks: str,
6767
/,
6868
test_mode: bool = False,
69-
extra_args: Iterable[str] | None = None,
69+
extra_args: list[str] | None = None,
7070
) -> None:
7171
if benchmarks.strip() == "":
7272
benchmarks = "all"
@@ -82,6 +82,9 @@ def run_benchmarks(
8282
if extra_args is None:
8383
extra_args = []
8484

85+
if affinity := os.environ.get("CPU_AFFINITY"):
86+
extra_args.append(f"--affinity={affinity}")
87+
8588
args = [
8689
sys.executable,
8790
"-m",

Diff for: bench_runner/templates/_benchmark.src.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ jobs:
221221
- name: Tune system
222222
if: ${{ steps.should_run.outputs.should_run != 'false' }}
223223
run: |
224-
sudo LD_LIBRARY_PATH=$LD_LIBRARY_PATH venv/bin/python -m pyperf system ${{ inputs.perf && 'reset' || 'tune' }}
224+
sudo LD_LIBRARY_PATH=$LD_LIBRARY_PATH venv/bin/python -m pyperf system ${{ inputs.perf && 'reset' || 'tune ${CPU_AFFINITY:+--affinity="$CPU_AFFINITY"}' }}
225225
- name: Tune for (Linux) perf
226226
if: ${{ steps.should_run.outputs.should_run != 'false' && inputs.perf }}
227227
run: |
@@ -232,6 +232,10 @@ jobs:
232232
run: |
233233
rm -rf ~/.debug/*
234234
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 }}
235+
- name: Untune system
236+
if: ${{ steps.should_run.outputs.should_run != 'false' }}
237+
run: |
238+
sudo LD_LIBRARY_PATH=$LD_LIBRARY_PATH venv/bin/python -m pyperf system reset
235239
# Pull again, since another job may have committed results in the meantime
236240
- name: Pull benchmarking
237241
if: ${{ steps.should_run.outputs.should_run != 'false' && !inputs.perf }}

0 commit comments

Comments
 (0)