Skip to content

Commit 0984824

Browse files
authored
chore: enable fair sched for codspeed (#12798)
1 parent 15d4750 commit 0984824

File tree

2 files changed

+121
-1
lines changed

2 files changed

+121
-1
lines changed
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
name: 'CodSpeed Performance Analysis'
2+
description: 'Continuous benchmarking and performance checks'
3+
branding:
4+
color: orange
5+
icon: activity
6+
7+
author: 'Arthur Pastel'
8+
inputs:
9+
run:
10+
description: 'The command to run the benchmarks'
11+
required: true
12+
13+
mode:
14+
description: |
15+
The mode to run the benchmarks in. The following modes are available:
16+
- `simulation`: Run the benchmarks with CPU simulation measurements.
17+
- `walltime`: Run the benchmarks with walltime measurement.
18+
- `memory`: Run the benchmarks with allocation measurements.
19+
- `instrumentation`: (Deprecated) Legacy name for `simulation`. Please use `simulation` instead.
20+
21+
We strongly recommend starting with the `simulation` mode.
22+
23+
Using the `walltime` mode on traditional VMs/Hosted Runners might lead to inconsistent data. For the best results, we recommend using CodSpeed Hosted Macro Runners, which are fine-tuned for performance measurement consistency.
24+
Check out the [Walltime Instrument Documentation](https://docs.codspeed.io/instruments/walltime/) for more details.
25+
required: true
26+
27+
token:
28+
description: |
29+
CodSpeed upload token. Only required for private repositories.
30+
required: false
31+
32+
working-directory:
33+
description: |
34+
The directory where the `run` command will be executed.
35+
Warning: if you use defaults.working-directory, you must still set this parameter.
36+
required: false
37+
38+
upload-url:
39+
description: 'The upload endpoint (for on-premise deployments)'
40+
required: false
41+
42+
runner-version:
43+
description: "The version of the runner to use. Use 'latest' to automatically fetch the latest release version from GitHub, or specify a version like '3.5.0' or 'v3.5.0'."
44+
required: false
45+
46+
instruments:
47+
description: |
48+
Comma separated list of instruments to enable. The following instruments are available:
49+
- `mongodb`: MongoDB instrumentation, requires the MongoDB instrument to be enabled for the organization in CodSpeed
50+
required: false
51+
52+
mongo-uri-env-name:
53+
description: |
54+
The name of the environment variable containing the MongoDB URI. Requires the `mongodb` instrument to be activated in `instruments`.
55+
If the instrumentation is enabled and this value is not set, the user will need to dynamically provide the MongoDB URI to the CodSpeed runner.
56+
required: false
57+
58+
cache-instruments:
59+
description: |
60+
Enable caching of instrument installations (like valgrind or perf) to speed up subsequent workflow runs. Set to 'false' to disable caching.
61+
required: false
62+
default: 'true'
63+
64+
instruments-cache-dir:
65+
description: |
66+
The directory to use for caching installations of instruments (like valgrind or perf). Defaults to `$HOME/.cache/codspeed-action`.
67+
required: false
68+
default: '~/.cache/codspeed-action'
69+
70+
allow-empty:
71+
description: |
72+
Allow the action to complete successfully even if no benchmarks were found or run. Set to 'true' to enable this behavior.
73+
required: false
74+
default: 'false'
75+
76+
runs:
77+
using: 'composite'
78+
steps:
79+
- shell: bash
80+
run: |
81+
# Validate required inputs
82+
# (custom message for smoother v4 migration)
83+
if [ -z "${{ inputs.mode }}" ]; then
84+
echo "::error title=Missing required input 'mode'::The 'mode' input is required as of CodSpeed Action v4. Please explicitly set 'mode' to 'simulation' or 'walltime'. Before, this variable was automatically set to instrumentation on every runner except for CodSpeed macro runners where it was set to walltime by default. See https://codspeed.io/docs/instruments for details."
85+
exit 1
86+
fi
87+
88+
# We can use official runner if it supports config valgrind flags in the future: https://github.com/CodSpeedHQ/runner/pull/92
89+
cargo install --git https://github.com/CPunisher/runner.git --rev 9c1ca5aa4742b8524843c0ac3e417c6ecb91b1bd codspeed-runner
90+
91+
# Get the runner arguments
92+
RUNNER_ARGS=""
93+
if [ -n "${{ inputs.token }}" ]; then
94+
RUNNER_ARGS="$RUNNER_ARGS --token ${{ inputs.token }}"
95+
fi
96+
if [ -n "${{ inputs.working-directory }}" ]; then
97+
RUNNER_ARGS="$RUNNER_ARGS --working-directory=${{ inputs.working-directory }}"
98+
fi
99+
if [ -n "${{ inputs.upload-url }}" ]; then
100+
RUNNER_ARGS="$RUNNER_ARGS --upload-url=${{ inputs.upload-url }}"
101+
fi
102+
if [ -n "${{ inputs.mode }}" ]; then
103+
RUNNER_ARGS="$RUNNER_ARGS --mode=${{ inputs.mode }}"
104+
fi
105+
if [ -n "${{ inputs.instruments }}" ]; then
106+
RUNNER_ARGS="$RUNNER_ARGS --instruments=${{ inputs.instruments }}"
107+
fi
108+
if [ -n "${{ inputs.mongo-uri-env-name }}" ]; then
109+
RUNNER_ARGS="$RUNNER_ARGS --mongo-uri-env-name=${{ inputs.mongo-uri-env-name }}"
110+
fi
111+
if [ "${{ inputs.cache-instruments }}" = "true" ] && [ -n "${{ inputs.instruments-cache-dir }}" ]; then
112+
RUNNER_ARGS="$RUNNER_ARGS --setup-cache-dir=${{ inputs.instruments-cache-dir }}"
113+
fi
114+
if [ "${{ inputs.allow-empty }}" = "true" ]; then
115+
RUNNER_ARGS="$RUNNER_ARGS --allow-empty"
116+
fi
117+
118+
# Run the benchmarks
119+
# Enable fair sched to make benchmark more stable, see: https://github.com/CodSpeedHQ/runner/pull/91
120+
env VALGRIND_FLAGS='--fair-sched=yes' codspeed run $RUNNER_ARGS -- '${{ inputs.run }}'

.github/workflows/reusable-build-bench.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ jobs:
7777
run: pnpm run build:js
7878

7979
- name: Run benchmark
80-
uses: CodSpeedHQ/action@0700edb451d0e9f2426f99bd6977027e550fb2a6 # https://github.com/CodSpeedHQ/action/releases/tag/v4.7.0
80+
uses: ./.github/actions/codspeed
8181
timeout-minutes: 30
8282
env:
8383
RAYON_NUM_THREADS: 1

0 commit comments

Comments
 (0)