-
Notifications
You must be signed in to change notification settings - Fork 139
Trying some more benchmarking noise reduction things #6901
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -110,9 +110,12 @@ jobs: | |
| uv run --all-packages pytest --benchmark-disable -n auto test/ | ||
| working-directory: vortex-python/ | ||
|
|
||
| - name: Setup benchmark environment | ||
| run: sudo bash scripts/setup-benchmark.sh | ||
|
|
||
| - name: Pytest Benchmarks - Vortex | ||
| run: | | ||
| uv run --all-packages pytest --benchmark-only benchmark/ | ||
| bash ../scripts/bench-taskset.sh uv run --all-packages pytest --benchmark-only benchmark/ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Generally not loving relative paths in scripts but 🤷 |
||
| working-directory: vortex-python/ | ||
|
|
||
| - name: Doctest - PyVortex | ||
|
|
@@ -743,7 +746,7 @@ jobs: | |
| - name: Run benchmarks | ||
| uses: CodSpeedHQ/action@281164b0f014a4e7badd2c02cecad9b595b70537 | ||
| with: | ||
| run: cargo codspeed run | ||
| run: bash scripts/bench-taskset.sh cargo codspeed run | ||
| token: ${{ secrets.CODSPEED_TOKEN }} | ||
| mode: "simulation" | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # SPDX-FileCopyrightText: Copyright the Vortex contributors | ||
|
|
||
| set -Eeu -o pipefail | ||
|
|
||
| if [[ $# -eq 0 ]]; then | ||
| echo "Usage: $0 <command> [args...]" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [[ -f /tmp/vortex-benchmark.env ]]; then | ||
| # shellcheck disable=SC1091 | ||
| source /tmp/vortex-benchmark.env | ||
| fi | ||
|
|
||
|
|
||
|
|
||
| if [[ -z "${BENCH_CPUS:-}" ]]; then | ||
| cpu_count="$(nproc)" | ||
| BENCH_CPUS="2-$((cpu_count - 1))" | ||
| fi | ||
|
|
||
| if command -v numactl >/dev/null 2>&1; then | ||
| exec numactl --physcpubind="$BENCH_CPUS" --localalloc "$@" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you elaborate / add a comment why we replace the process here and for |
||
| fi | ||
|
|
||
| exec taskset -c "$BENCH_CPUS" "$@" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,17 +10,24 @@ if [ "$EUID" -ne 0 ]; then | |
| exit 0 | ||
| fi | ||
|
|
||
| # Turn off frequency scaling | ||
| for gov in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do | ||
| echo performance > "$gov" 2>/dev/null || true | ||
| done | ||
| # Disable turbo boost so benchmark runs stay at a more stable clock rate. | ||
| [[ -w /sys/devices/system/cpu/intel_pstate/no_turbo ]] && echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo || true | ||
AdamGS marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| [[ -w /sys/devices/system/cpu/cpufreq/boost ]] && echo 0 > /sys/devices/system/cpu/cpufreq/boost || true | ||
|
|
||
| # Really discourage swapping to disk | ||
| sysctl vm.swappiness=0 | ||
| swapoff -a || true | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We ignore a lot of errors in this script via |
||
|
|
||
| # Might be worse if a single application uses the OS | ||
| # https://www.intel.com/content/www/us/en/developer/articles/technical/measuring-impact-of-numa-migrations-on-performance.html | ||
| sysctl -w kernel.numa_balancing=0 | ||
|
|
||
| # Disable ASLR - https://docs.kernel.org/admin-guide/sysctl/kernel.html#randomize-va-space | ||
| sysctl kernel.randomize_va_space=0 | ||
|
|
||
| # This is a desktop optimization, making sure its disabled | ||
| sysctl -w kernel.sched_autogroup_enabled=0 | ||
|
|
||
| # Reduce kernel logging to minimum | ||
| dmesg -n 1 | ||
|
|
||
|
|
@@ -33,3 +40,37 @@ systemctl mask ModemManager | |
|
|
||
| # For apparmor specifically, also teardown loaded profiles | ||
| aa-teardown | ||
|
|
||
| # Reduce background activity (Ubuntu-specific) | ||
| for unit in \ | ||
| irqbalance \ | ||
| apt-daily.service \ | ||
| apt-daily-upgrade.service \ | ||
| apt-daily.timer \ | ||
| apt-daily-upgrade.timer \ | ||
| motd-news.service \ | ||
| motd-news.timer \ | ||
| apport | ||
| do | ||
| systemctl disable --now "$unit" 2>/dev/null | ||
| done | ||
| systemctl mask irqbalance 2>/dev/null | ||
|
|
||
| CPU_COUNT="$(nproc)" | ||
| HOUSEKEEPING_CPUS="0-1" | ||
| BENCH_CPUS="2-$((CPU_COUNT - 1))" | ||
|
|
||
| # Pin all IRQs to housekeeping CPUs | ||
| for f in /proc/irq/[0-9]*/smp_affinity_list; do | ||
| if [[ -w "$f" ]]; then | ||
| # Some IRQs are kernel-managed and reject writes with EPERM even as root. | ||
| echo "$HOUSEKEEPING_CPUS" > "$f" 2>/dev/null || true | ||
| fi | ||
| done | ||
|
|
||
| # Persist CPU affinity ranges for non-root benchmark steps in CI. | ||
| cat > /tmp/vortex-benchmark.env <<EOF | ||
| HOUSEKEEPING_CPUS=$HOUSEKEEPING_CPUS | ||
| BENCH_CPUS=$BENCH_CPUS | ||
| EOF | ||
| chmod 0644 /tmp/vortex-benchmark.env | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated to this PR, should we consider using the cargo runner env, like we do for CUDA sanitizers?