unisonweb / unison

A friendly programming language from the future
https://unison-lang.org
Other
5.81k stars 271 forks source link

Standardize optimization flags #5424

Closed ChrisPenner closed 1 week ago

ChrisPenner commented 4 weeks ago

Overview

Our package optimization flags are all over the place, meaning we're not actually optimizing where we want to in production releases.

We build with:

          stack build :unison \
            --flag unison-parser-typechecker:optimized \
            --local-bin-path ucm-bin \
            --copy-bins

in our bundle-ucm.yaml which is pretty weird for a few reasons.

We only set the optimized flag for the parser-typechecker, which already defaults to true We don't manually do the same for the runtime (which also defaults to true) We're missing a bunch of other packages that DO have optimized flags

Here's the breakdown:

unison-pretty-printer: O2
unison-parser-typechecker: O2
unison-cli: Has an optimized flag, but it defaults to disabled and isn't enabled anywhere
unison-cli-integration: Has an optimized flag, but it defaults to disabled and isn't enabled anywhere
unison-cli-main: Has an optimized flag, but it defaults to disabled and isn't enabled anywhere
unison-core1: Has an optimized flag, but it defaults to disabled and isn't enabled anywhere
unison-hash: manually set to -O0
unison-hashing: manually set to -O0 

All the rest don't have -O flags at all, which according to the GHC manual is equivalent to -O0 which isn't great...

IMO our current setup makes it pretty hard to understand how anything is building, but it's hard to come up with a perfect solution.

Adding to the annoyance is that it's not perfectly clear which ghc-options are overridden by what; but the source suggests that the lib settings come after stack's "locals" and cli-options come last.

This changes things so we only set explicit flags in the runtime, then we can set the overall speed with --fast or --ghc-options='-O2' where needed.

This adds the aforementioned O2 in the bundle-ucm CI task.