From 88d7d19bb860f075b5f01121d3f8610546758379 Mon Sep 17 00:00:00 2001 From: Patrick Thomson Date: Tue, 22 May 2018 17:18:03 -0400 Subject: [PATCH 1/3] Make builds run at -O0 by default, except for CI/deploy. It's always been easy to forget the `--fast` flag. With the introduction of `semanticd`, forgetting that carries a significant speed hit, as GHC optimizes the resulting executable very thoroughly, which entails a significant uptick in time spent building. For our collective sanity's sake, this patch makes `stack build` operate without optimizations. CI and deploy jobs pass `--flag semantic:release` to `stack`, which specifies the `-O2` level of optimizations. Timing `stack clean && stack build` (which rebuilds the tree-sitter packages) went from 6m17s to 3m04s on my machine. When building just `semantic` by itself, standard builds take 1m06s, whereas builds with `--flag semantic:release` take 4m12s. (GHC does a lot of optimizations!) --- semantic.cabal | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/semantic.cabal b/semantic.cabal index 0c50d79c3..577177472 100644 --- a/semantic.cabal +++ b/semantic.cabal @@ -11,6 +11,10 @@ build-type: Simple -- extra-source-files: cabal-version: >=1.10 +flag release + description: Build with optimizations on (for CI or deployment builds) + default: False + library hs-source-dirs: src exposed-modules: @@ -221,13 +225,19 @@ library , StandaloneDeriving , StrictData , TypeApplications - ghc-options: -Wall -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints -fno-warn-name-shadowing -O -j + if flag(release) + ghc-options: -Wall -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints -fno-warn-name-shadowing -O2 -j + else + ghc-options: -Wall -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints -fno-warn-name-shadowing -O0 -j ghc-prof-options: -fprof-auto executable semantic hs-source-dirs: app main-is: Main.hs - ghc-options: -threaded -rtsopts "-with-rtsopts=-N -A4m -n2m" -static -j -O + if flag(release) + ghc-options: -threaded -rtsopts "-with-rtsopts=-N -A4m -n2m" -static -j -O2 -j + else + ghc-options: -threaded -rtsopts "-with-rtsopts=-N -A4m -n2m" -static -j -O0 -j cc-options: -DU_STATIC_IMPLEMENTATION=1 cpp-options: -DU_STATIC_IMPLEMENTATION=1 build-depends: base @@ -327,7 +337,7 @@ benchmark evaluation hs-source-dirs: bench type: exitcode-stdio-1.0 main-is: Main.hs - ghc-options: -threaded -rtsopts "-with-rtsopts=-N -A4m -n2m -T" -static -j -O + ghc-options: -threaded -rtsopts "-with-rtsopts=-N -A4m -n2m -T" -static -j -O2 cc-options: -DU_STATIC_IMPLEMENTATION=1 cpp-options: -DU_STATIC_IMPLEMENTATION=1 default-language: Haskell2010 From c1d3a041ccf4b4080051ac21e678b4233118b810 Mon Sep 17 00:00:00 2001 From: Patrick Thomson Date: Tue, 22 May 2018 17:37:54 -0400 Subject: [PATCH 2/3] set -Werror when building release --- semantic.cabal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/semantic.cabal b/semantic.cabal index 577177472..bb9af8be8 100644 --- a/semantic.cabal +++ b/semantic.cabal @@ -226,7 +226,7 @@ library , StrictData , TypeApplications if flag(release) - ghc-options: -Wall -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints -fno-warn-name-shadowing -O2 -j + ghc-options: -Wall -Werror -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints -fno-warn-name-shadowing -O2 -j else ghc-options: -Wall -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints -fno-warn-name-shadowing -O0 -j ghc-prof-options: -fprof-auto From 1f26db7a5ebdffb2893d2e58a9684629f1923e62 Mon Sep 17 00:00:00 2001 From: Patrick Thomson Date: Tue, 22 May 2018 17:48:07 -0400 Subject: [PATCH 3/3] -O2 is ridiculously slow, let's hold off for now --- semantic.cabal | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/semantic.cabal b/semantic.cabal index bb9af8be8..8138ae153 100644 --- a/semantic.cabal +++ b/semantic.cabal @@ -226,7 +226,7 @@ library , StrictData , TypeApplications if flag(release) - ghc-options: -Wall -Werror -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints -fno-warn-name-shadowing -O2 -j + ghc-options: -Wall -Werror -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints -fno-warn-name-shadowing -O1 -j else ghc-options: -Wall -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints -fno-warn-name-shadowing -O0 -j ghc-prof-options: -fprof-auto @@ -235,7 +235,7 @@ executable semantic hs-source-dirs: app main-is: Main.hs if flag(release) - ghc-options: -threaded -rtsopts "-with-rtsopts=-N -A4m -n2m" -static -j -O2 -j + ghc-options: -threaded -rtsopts "-with-rtsopts=-N -A4m -n2m" -static -j -O1 -j else ghc-options: -threaded -rtsopts "-with-rtsopts=-N -A4m -n2m" -static -j -O0 -j cc-options: -DU_STATIC_IMPLEMENTATION=1 @@ -337,7 +337,7 @@ benchmark evaluation hs-source-dirs: bench type: exitcode-stdio-1.0 main-is: Main.hs - ghc-options: -threaded -rtsopts "-with-rtsopts=-N -A4m -n2m -T" -static -j -O2 + ghc-options: -threaded -rtsopts "-with-rtsopts=-N -A4m -n2m -T" -static -j -O1 cc-options: -DU_STATIC_IMPLEMENTATION=1 cpp-options: -DU_STATIC_IMPLEMENTATION=1 default-language: Haskell2010