|
76 | 76 |
|
77 | 77 | - name: Build All Components |
78 | 78 | run: | |
79 | | - # Build TinyGo component (all aliases point to file_ops_component) |
| 79 | + # Build TinyGo component (regular version) |
80 | 80 | bazel build //tinygo:file_ops_component |
81 | 81 |
|
| 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 | +
|
82 | 89 | # Note: Rust implementation is not yet available |
83 | 90 | # Future: Add Rust component builds when implemented |
84 | 91 |
|
@@ -139,6 +146,65 @@ jobs: |
139 | 146 | echo "⚠️ wasmtime not available, skipping runtime benchmarks" >> perf_results.md |
140 | 147 | fi |
141 | 148 |
|
| 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 | +
|
142 | 208 | - name: Benchmark Rust Implementation |
143 | 209 | if: (github.event.inputs.benchmark_type == 'all' || github.event.inputs.benchmark_type == 'rust-only' || github.event.inputs.benchmark_type == '') && hashFiles('rust/**') != '' |
144 | 210 | run: | |
|
0 commit comments