Commit 80894e3a
80894e3a7b34Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 2 files · ~2 modified
Description
Compile per-test C at -O1, not -O0 (~3x faster, the real win)
Profiling the windows-mingw test step (still ~14min after the prior tweaks) showed the cost is almost entirely gcc compiling the generated C, which #includes the 5554-line lib/sp_runtime.h (800+ static functions). Counter-intuitively, -O0 is ~3x SLOWER than -O1 for this: at -O0 gcc emits code for every referenced static fn from the header, while at -O1 it prunes unreferenced statics and runs DCE before the expensive codegen stages, emitting far less.
Measured per-test compile+link (gcc): -O0 0.75s vs -O1 0.25s. Full local suite wall: -O0 47s vs -O1 16s. 846 pass at -O1 on both gcc and clang.
So the prior commit's premise (-O0 cuts cc time; the step is spawn/latency bound) was wrong: it's CPU-bound on header compilation. Switch every test compile to OPT=-O1 (both CI test steps and the local check / gate-test targets) and drop the -j oversubscription back to nproc (no gain for CPU-bound work). The harmless wins from before -- plain gcc for the test compile, Defender off, one-shot compile+link -- stay.
Co-Authored-By: Claude Opus 4.8 (1M context) [email protected]
Details
- Commit
- 80894e3a7b34
- Parent
- e0b99da624c0
.github/workflows/ci.ymlmodifiedView file
run: make -j$(getconf _NPROCESSORS_ONLN) LTO=0 all - name: Run tests # OPT=-O0 cuts cc time per test (each .rb compiles its own # generated C with $(CFLAGS) -Werror). Type-checking still # happens; we just skip the optimizer. # -j$(...) overlaps the per-test cc invocations. run: make -j$(getconf _NPROCESSORS_ONLN) test OPT=-O0 # OPT=-O1, counter-intuitively, compiles each test ~3x FASTER than # -O0: the generated C pulls in lib/sp_runtime.h (800+ static fns), and # at -O1 gcc/clang prune unreferenced statics + DCE before the costly # codegen stages, emitting far less than -O0 does. -j overlaps the # per-test cc invocations. run: make -j$(getconf _NPROCESSORS_ONLN) test OPT=-O1 # Benchmark integration test. Compiles every benchmark/*.rb through # the full pipeline (cc -Werror) and diffs the output against CRuby. run: make -j$(nproc) LTO=0 all - name: Run tests # Oversubscribe -j (process-spawn/link-latency bound on Windows, not # CPU bound) and use plain gcc: each test's generated C is unique, so # the sccache wrapper only adds miss-overhead per compile here (the # build step above keeps sccache, where caching the runtime/prism # objects pays off). run: make -j$(( $(nproc) * 2 )) test OPT=-O0 CC=gcc # OPT=-O1 is the big lever here: each per-test cc compiles the # sp_runtime.h-heavy generated C ~3x faster than at -O0 (gcc prunes the # 800+ unreferenced static fns before codegen). Plain gcc (not the # sccache wrapper): the generated C is unique per test so sccache only # adds miss-overhead; the build step above keeps sccache where caching # the runtime/prism objects pays off. run: make -j$(nproc) test OPT=-O1 CC=gcc - name: sccache stats if: always()MakefilemodifiedView file
Loading diff…