Skip to content

Commit 13c31a0

Browse files
authored
Merge branch 'main' into spec/main
2 parents 23179c3 + 19133a6 commit 13c31a0

294 files changed

Lines changed: 8620 additions & 4164 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/benchmark-pr.yml

Lines changed: 60 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ concurrency:
3030
cancel-in-progress: true
3131

3232
env:
33-
PROGRAM: executor/programs/asm/fib_iterative_2M.s
34-
ELF: executor/program_artifacts/asm/fib_iterative_2M.elf
33+
PROGRAM: executor/programs/asm/fib_iterative_8M.s
34+
ELF: executor/program_artifacts/asm/fib_iterative_8M.elf
3535
BENCH_RUNS_PR: 3
36-
BENCH_RUNS_BASELINE: 5
37-
GROWTH_PROGRAMS: "fib_iterative_250k fib_iterative_500k fib_iterative_1M fib_iterative_2M"
38-
GROWTH_STEPS: "250000 500000 1000000 2000000"
36+
BENCH_RUNS_BASELINE: 3
37+
GROWTH_PROGRAMS: "fib_iterative_1M fib_iterative_2M fib_iterative_4M fib_iterative_8M"
38+
GROWTH_STEPS: "1000000 2000000 4000000 8000000"
3939

4040
jobs:
4141
benchmark:
@@ -79,6 +79,13 @@ jobs:
7979
- name: Compile benchmark ELFs
8080
run: |
8181
mkdir -p executor/program_artifacts/asm
82+
# Compile main benchmark ELF
83+
MAIN_SRC="$PROGRAM"
84+
MAIN_OUT="$ELF"
85+
if [ ! -f "$MAIN_OUT" ] && [ -f "$MAIN_SRC" ]; then
86+
clang --target=riscv64 -march=rv64im -fuse-ld=lld -nostdlib -Wl,-e,main \
87+
"$MAIN_SRC" -o "$MAIN_OUT"
88+
fi
8289
for prog in $GROWTH_PROGRAMS; do
8390
SRC="executor/programs/asm/${prog}.s"
8491
OUT="executor/program_artifacts/asm/${prog}.elf"
@@ -100,6 +107,16 @@ jobs:
100107
COMMENT_BODY: ${{ github.event.comment.body }}
101108
EVENT_NAME: ${{ github.event_name }}
102109
run: |
110+
# Growth benchmarks: run on /bench-growth, push to main, or workflow_dispatch
111+
# Skip on plain /bench to keep it fast
112+
if [ "$EVENT_NAME" = "issue_comment" ] && echo "$COMMENT_BODY" | grep -q '^/bench-growth'; then
113+
echo "run_growth=true" >> "$GITHUB_OUTPUT"
114+
elif [ "$EVENT_NAME" = "push" ] || [ "$EVENT_NAME" = "workflow_dispatch" ]; then
115+
echo "run_growth=true" >> "$GITHUB_OUTPUT"
116+
else
117+
echo "run_growth=false" >> "$GITHUB_OUTPUT"
118+
fi
119+
103120
if [ "$EVENT_NAME" = "issue_comment" ]; then
104121
CUSTOM_N=$(echo "$COMMENT_BODY" | sed -n 's|^/bench[[:space:]]*\([0-9]\+\).*|\1|p')
105122
RUNS=${CUSTOM_N:-$BENCH_RUNS_PR}
@@ -116,13 +133,34 @@ jobs:
116133
fi
117134
118135
echo "runs=$RUNS" >> "$GITHUB_OUTPUT"
119-
echo "Using $RUNS benchmark iterations"
136+
137+
# Parse TABLE_PARALLELISM:
138+
# /bench-growth always uses k=1 (for reproducible comparisons)
139+
# /bench accepts k=N parameter
140+
TABLE_K=""
141+
if [ "$EVENT_NAME" = "issue_comment" ] && echo "$COMMENT_BODY" | grep -q '^/bench-growth'; then
142+
TABLE_K="1"
143+
elif [ "$EVENT_NAME" = "issue_comment" ]; then
144+
TABLE_K=$(echo "$COMMENT_BODY" | grep -o 'k=[0-9]*' | head -1 | cut -d= -f2)
145+
fi
146+
echo "table_parallelism=${TABLE_K:-}" >> "$GITHUB_OUTPUT"
147+
148+
if [ -n "$TABLE_K" ]; then
149+
echo "Using $RUNS iterations, TABLE_PARALLELISM=$TABLE_K"
150+
else
151+
echo "Using $RUNS iterations, TABLE_PARALLELISM=default"
152+
fi
120153
121154
- name: Benchmark PR
122155
id: pr
123156
env:
124157
RUNS: ${{ steps.config.outputs.runs }}
158+
TABLE_PARALLELISM: ${{ steps.config.outputs.table_parallelism }}
125159
run: |
160+
if [ -n "$TABLE_PARALLELISM" ]; then
161+
export TABLE_PARALLELISM
162+
echo "TABLE_PARALLELISM=$TABLE_PARALLELISM"
163+
fi
126164
TIMES=""
127165
HEAPS=""
128166
for i in $(seq 1 $RUNS); do
@@ -184,6 +222,7 @@ jobs:
184222
185223
- name: Memory growth (PR)
186224
id: pr-growth
225+
if: steps.config.outputs.run_growth == 'true'
187226
env:
188227
TABLE_PARALLELISM: "1"
189228
run: |
@@ -304,7 +343,13 @@ jobs:
304343
env:
305344
GH_TOKEN: ${{ github.token }}
306345
RUNS: ${{ steps.config.outputs.runs }}
346+
RUN_GROWTH: ${{ steps.config.outputs.run_growth }}
347+
TABLE_PARALLELISM: ${{ steps.config.outputs.table_parallelism }}
307348
run: |
349+
if [ -n "$TABLE_PARALLELISM" ]; then
350+
export TABLE_PARALLELISM
351+
echo "TABLE_PARALLELISM=$TABLE_PARALLELISM"
352+
fi
308353
# Save current HEAD
309354
PR_SHA=$(git rev-parse HEAD)
310355
@@ -365,6 +410,10 @@ jobs:
365410
echo "runs=$RUNS" >> "$GITHUB_OUTPUT"
366411
367412
# --- Growth benchmarks (TABLE_PARALLELISM=1, 2 samples each) ---
413+
# Only run if /bench-growth, push, or workflow_dispatch
414+
if [ "$RUN_GROWTH" != "true" ]; then
415+
echo "Skipping growth benchmarks (use /bench-growth to enable)"
416+
else
368417
PROGRAMS=($GROWTH_PROGRAMS)
369418
STEPS_ARR=($GROWTH_STEPS)
370419
GROWTH_HEAPS=""
@@ -423,6 +472,7 @@ jobs:
423472
echo "growth_times=$GROWTH_TIMES" >> "$GITHUB_OUTPUT"
424473
echo "growth_slope_mb=$SLOPE" >> "$GITHUB_OUTPUT"
425474
echo "growth_r2=$R2" >> "$GITHUB_OUTPUT"
475+
fi # end run_growth check
426476
427477
# Restore PR checkout
428478
git checkout "$PR_SHA"
@@ -620,7 +670,7 @@ jobs:
620670
621671
// --- Section 1: Primary benchmark ---
622672
const nLabel = parseInt(runs) > 1 ? ` (median of ${runs})` : '';
623-
let body = `## Benchmark — fib_iterative_2M${nLabel}\n\n`;
673+
let body = `## Benchmark — fib_iterative_8M${nLabel}\n\n`;
624674
body += `<sub>Table parallelism: 32 (auto = cores / 3)</sub>\n\n`;
625675
body += `| Metric | main | PR | Δ |\n`;
626676
body += `|--------|------|----|---|\n`;
@@ -675,8 +725,8 @@ jobs:
675725
if (prGrowthHeaps) {
676726
const prHeaps = prGrowthHeaps.split('/');
677727
const baseHeaps = baseGrowthHeaps ? baseGrowthHeaps.split('/') : null;
678-
const labels = ['250k', '500k', '1M', '2M'];
679-
const programs = ['fib_iterative_250k', 'fib_iterative_500k', 'fib_iterative_1M', 'fib_iterative_2M'];
728+
const labels = ['1M', '2M', '4M', '8M'];
729+
const programs = ['fib_iterative_1M', 'fib_iterative_2M', 'fib_iterative_4M', 'fib_iterative_8M'];
680730
681731
body += `\n## Memory Growth\n\n`;
682732
body += `<sub>Measured with \`TABLE_PARALLELISM=1\` (sequential) · best of 2 samples per point</sub>\n\n`;
@@ -741,6 +791,7 @@ jobs:
741791
// Find existing comment (check both old and new markers for transition)
742792
const existing = comments.find(c =>
743793
c.user.type === 'Bot' && (
794+
c.body.includes('Benchmark — fib_iterative_8M') ||
744795
c.body.includes('Benchmark — fib_iterative_2M') ||
745796
c.body.includes('Benchmark — fib_iterative_372k')
746797
)

.github/workflows/hyperfine.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ name: Hyperfine Benchmark
33
on:
44
pull_request:
55
branches: ["**"]
6-
paths-ignore: ["spec/**"]
6+
paths:
7+
- 'executor/src/**'
8+
- 'executor/Cargo.toml'
79

810
concurrency:
911
group: ${{ github.workflow }}-${{ github.ref }}
@@ -33,7 +35,7 @@ jobs:
3335
id: cache
3436
with:
3537
path: ${{ matrix.branch }}_programs/*.elf
36-
key: benchmarks-${{ matrix.branch }}-${{ hashFiles( 'executor/programs/bench/*' ) }}
38+
key: benchmarks-${{ matrix.branch }}-${{ hashFiles( 'executor/programs/bench/**', 'syscalls/src/**' ) }}
3739
restore-keys: benchmarks-${{ matrix.branch }}-
3840

3941
- name: Setup Rust Environment
@@ -49,7 +51,7 @@ jobs:
4951
5052
- name: Export benchmark hashes
5153
id: export-hashes
52-
run: echo "benchmark-hashes-${{ matrix.branch }}=${{ hashFiles( 'executor/programs/bench/*' ) }}" >> "$GITHUB_OUTPUT"
54+
run: echo "benchmark-hashes-${{ matrix.branch }}=${{ hashFiles( 'executor/programs/bench/**', 'syscalls/src/**' ) }}" >> "$GITHUB_OUTPUT"
5355

5456
build-binaries:
5557
strategy:

0 commit comments

Comments
 (0)