Skip to content

Commit c84cee8

Browse files
committed
feat: add platform-specific AOT precompiled benchmarking
Use actual precompiled .cwasm AOT files instead of embedded sections: - Build platform-specific AOT targets (linux_x64, darwin_arm64) - Use .cwasm precompiled files with --allow-precompiled flag - Compare regular WASM vs AOT precompiled performance - Calculate and report speedup metrics The .cwasm files contain native code precompiled by wasmtime for the specific platform, providing true AOT execution speed vs interpreted WASM runtime. Note: Precompiled files are wasmtime-version-specific and must match the runtime version used in CI.
1 parent 69eca0d commit c84cee8

File tree

1 file changed

+67
-1
lines changed

1 file changed

+67
-1
lines changed

.github/workflows/performance.yml

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,16 @@ jobs:
7676
7777
- name: Build All Components
7878
run: |
79-
# Build TinyGo component (all aliases point to file_ops_component)
79+
# Build TinyGo component (regular version)
8080
bazel build //tinygo:file_ops_component
8181
82+
# Build platform-specific AOT precompiled component
83+
if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then
84+
bazel build //tinygo:file_ops_aot_linux_x64
85+
elif [[ "${{ matrix.os }}" == "macos-latest" ]]; then
86+
bazel build //tinygo:file_ops_aot_darwin_arm64
87+
fi
88+
8289
# Note: Rust implementation is not yet available
8390
# Future: Add Rust component builds when implemented
8491
@@ -139,6 +146,65 @@ jobs:
139146
echo "⚠️ wasmtime not available, skipping runtime benchmarks" >> perf_results.md
140147
fi
141148
149+
- name: Benchmark TinyGo AOT Implementation
150+
if: github.event.inputs.benchmark_type == 'all' || github.event.inputs.benchmark_type == 'tinygo-only' || github.event.inputs.benchmark_type == ''
151+
run: |
152+
echo "" >> perf_results.md
153+
echo "## TinyGo AOT Performance Benchmarks" >> perf_results.md
154+
echo "| Operation | Time (ms) | Memory (MB) | Notes |" >> perf_results.md
155+
echo "|-----------|-----------|-------------|-------|" >> perf_results.md
156+
157+
# Determine AOT file path based on platform
158+
if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then
159+
AOT_FILE="bazel-bin/tinygo/file_ops_aot_linux_x64.cwasm"
160+
elif [[ "${{ matrix.os }}" == "macos-latest" ]]; then
161+
AOT_FILE="bazel-bin/tinygo/file_ops_aot_darwin_arm64.cwasm"
162+
else
163+
echo "⚠️ Unsupported platform for AOT benchmarks" >> perf_results.md
164+
exit 0
165+
fi
166+
167+
# WebAssembly AOT runtime benchmark
168+
if command -v wasmtime &> /dev/null; then
169+
# Test the AOT precompiled component first
170+
echo "Testing AOT precompiled component execution..."
171+
if wasmtime run --allow-precompiled --dir=. "$AOT_FILE" copy_file --src perf_test_data/small.txt --dest perf_test_data/wasm_aot_copy.txt; then
172+
echo "✅ AOT component test passed, running benchmarks..."
173+
174+
# Run benchmark comparing regular vs AOT
175+
echo "### AOT vs Regular Comparison" >> perf_results.md
176+
177+
# Benchmark AOT precompiled component
178+
hyperfine --export-json tinygo_aot_benchmark.json \
179+
--warmup 3 \
180+
--show-output \
181+
"wasmtime run --allow-precompiled --dir=. $AOT_FILE copy_file --src perf_test_data/small.txt --dest perf_test_data/wasm_aot_copy.txt" \
182+
|| echo "⚠️ AOT benchmark failed but continuing" >> perf_results.md
183+
184+
# Extract and compare results
185+
if [ -f tinygo_wasm_benchmark.json ] && [ -f tinygo_aot_benchmark.json ]; then
186+
REGULAR_TIME=$(jq -r '.results[0].mean' tinygo_wasm_benchmark.json 2>/dev/null || echo "N/A")
187+
AOT_TIME=$(jq -r '.results[0].mean' tinygo_aot_benchmark.json 2>/dev/null || echo "N/A")
188+
189+
echo "- **Regular WASM**: ${REGULAR_TIME}s" >> perf_results.md
190+
echo "- **AOT WASM**: ${AOT_TIME}s" >> perf_results.md
191+
192+
# Calculate speedup if both values are available
193+
if [[ "$REGULAR_TIME" != "N/A" ]] && [[ "$AOT_TIME" != "N/A" ]]; then
194+
SPEEDUP=$(echo "scale=2; $REGULAR_TIME / $AOT_TIME" | bc)
195+
echo "- **Speedup**: ${SPEEDUP}x faster with AOT" >> perf_results.md
196+
fi
197+
fi
198+
199+
echo "" >> perf_results.md
200+
echo "✅ TinyGo AOT component benchmarks completed" >> perf_results.md
201+
else
202+
echo "⚠️ AOT component test failed, skipping benchmarks" >> perf_results.md
203+
fi
204+
else
205+
echo "⚠️ wasmtime not available, skipping AOT benchmarks" >> perf_results.md
206+
fi
207+
142208
- name: Benchmark Rust Implementation
143209
if: (github.event.inputs.benchmark_type == 'all' || github.event.inputs.benchmark_type == 'rust-only' || github.event.inputs.benchmark_type == '') && hashFiles('rust/**') != ''
144210
run: |

0 commit comments

Comments
 (0)