udem-dlteam / pnut

🥜 A Self-Compiling C Transpiler Targeting Human-Readable POSIX Shell
https://pnut.sh
BSD 2-Clause "Simplified" License
378 stars 9 forks source link

Faster CI #67

Closed laurenthuberdeau closed 4 weeks ago

laurenthuberdeau commented 4 weeks ago

Context

In a perfect world, CI would be instant and we could integrate it into our workflow. Shells are maybe too slow for this, but we can at least use the "fast" compilation options when bootstrapping pnut to reduce the time it takes. Concretely, it enables the OPTIMIZE_CONSTANT_PARAM and SH_SAVE_VARS_WITH_SET options that speed up the compiler by 40-50%.

We may think this somewhat reduces the utility of CI since it no longer tests the pnut we'll ship, but everything but the bootstrap uses these options and local variables are fairly stable at this point that I'm comfortable losing this little of safety for much faster CI.

laurenthuberdeau commented 4 weeks ago

Results:

bootstrap-pnut-exe (bash, i386_linux):    5m 45s  -> 3m 13s
bootstrap-pnut-exe (bash, x86_64_linux):  6m 0s   -> 3m 21s
bootstrap-pnut-exe (bash, x86_64_mac):    4m 23s  -> 2m 26s
bootstrap-pnut-exe (dash, i386_linux):    11m 17s -> 6m 55s
bootstrap-pnut-exe (dash, x86_64_linux):  9m 38s  -> 9m 39s
bootstrap-pnut-exe (dash, x86_64_mac):    5m 8s   -> 6m 18s
bootstrap-pnut-exe (ksh, i386_linux):     2m 44s  -> 1m 33s
bootstrap-pnut-exe (ksh, x86_64_linux):   2m 46s  -> 1m 31s
bootstrap-pnut-exe (ksh, x86_64_mac):     1m 49s  -> 1m 0s
bootstrap-pnut-sh (bash):                 2m 15s  -> 1m 20s
bootstrap-pnut-sh (dash):                 2m 21s  -> 1m 48s
bootstrap-pnut-sh (ksh):                  1m 12s  -> 43s
bootstrap-pnut-sh (mksh):                 12m 55s -> 13m 55s <--- New longuest, takes a bit longer :(
bootstrap-pnut-sh (yash):                 2m 15s  -> 1m 14s
bootstrap-pnut-sh (zsh):                  29m 2s  -> 11m 19s <--- Previous longuest, 2.6x faster!
tests-exe (i386_linux, ubuntu-latest):    4s      -> 4s
tests-exe (x86_64_linux, ubuntu-latest):  4s      -> 4s
tests-exe (x86_64_mac, macos-latest):     8s      -> 9s
tests-shell (bash):                       15s     -> 14s
tests-shell (dash):                       13s     -> 19s
tests-shell (ksh):                        16s     -> 21s
tests-shell (mksh):                       17s     -> 18s
tests-shell (yash):                       18s     -> 15s
tests-shell (zsh):                        26s     -> 17s