From 7972b388200f5a5771e334f1b3c600d4a641b0dd Mon Sep 17 00:00:00 2001 From: tegwick Date: Tue, 28 Apr 2026 01:32:36 +0200 Subject: [PATCH] feat(build): tune GHC for haskelseed (8 CPU / 30 GiB) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - .ghci: -j1 → -j4 for parallel module compilation - scripts/compile-check: auto-detect high-RAM hosts (>16GB) and set GHCRTS="-A256m -M20g" to reduce GC pressure - devenv.nix: update comment only (GHCRTS still set at runtime) Co-Authored-By: Claude Sonnet 4.6 --- .ghci | 5 ++--- devenv.nix | 2 +- scripts/compile-check | 10 +++++++++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.ghci b/.ghci index a393946..794aeda 100644 --- a/.ghci +++ b/.ghci @@ -1,9 +1,8 @@ :set -XNoImplicitPrelude :def loadFromIHP \file -> (System.Environment.getEnv "IHP_LIB") >>= (\ihpLib -> readFile (ihpLib <> "/" <> file)) :loadFromIHP applicationGhciConfig --- Resource limit: override IHP's default -j (unlimited parallel) with -j1 --- on this constrained host (2 CPU / 3.8 GiB RAM). -:set -j1 +-- haskelseed (8 CPU / 30 GiB RAM): allow parallel module compilation. +:set -j4 -- Report errors from all modules in one pass (don't stop at first failure). -- Critical for batch error fixing — see IHUB-WP-0016 C4. :set -fkeep-going diff --git a/devenv.nix b/devenv.nix index 945e333..d1574cf 100644 --- a/devenv.nix +++ b/devenv.nix @@ -22,7 +22,7 @@ # ── Resource limits (constrained host: 2 CPU / ~3.8 GiB RAM) ───────────── # -A32m: smaller minor heap; -M2g: hard heap ceiling. # -N1 omitted: requires -threaded, which breaks IHP tools. - # GHC parallel module compilation is capped via -j1 in .ghci. + # GHC parallel module compilation is capped via -j4 in .ghci. env.GHCRTS = "-A32m -M2g"; # ── IHP environment variables ───────────────────────────────────────────── diff --git a/scripts/compile-check b/scripts/compile-check index 30fef11..326edd2 100755 --- a/scripts/compile-check +++ b/scripts/compile-check @@ -2,7 +2,7 @@ # scripts/compile-check — one-shot GHC compilation check. # # Does NOT start postgres or tailwind — just GHC. -# Relies on .ghci (sets -j1, -fkeep-going, loads IHP config). +# Relies on .ghci (sets -j4, -fkeep-going, loads IHP config). # # Usage: # scripts/compile-check # show errors in terminal + write log @@ -30,6 +30,14 @@ echo "[compile-check] Log: $LOGFILE" echo "[compile-check] Mode: ${MODE:-interactive}" echo "[compile-check] IHP_LIB: $IHP_LIB" +# Override GHC RTS for hosts with more RAM (e.g., haskelseed: 8 CPU / 30 GiB). +# devenv.nix sets -M2g for constrained hosts; override here if available RAM is higher. +TOTAL_RAM_MB=$(awk '/MemTotal/{print int($2/1024)}' /proc/meminfo 2>/dev/null || echo 0) +if [[ "$TOTAL_RAM_MB" -gt 16000 ]]; then + export GHCRTS="-A256m -M20g" + echo "[compile-check] Host RAM: ${TOTAL_RAM_MB}MB — using GHCRTS=$GHCRTS" +fi + # One-shot compile: load all modules via .ghci config then quit immediately. # -fkeep-going (set in .ghci) ensures all errors are reported, not just the first. # ghcid is not available in this environment; ghci one-shot gives the same error output.