Maybe the specialiser is somehow looping or generating a huge program. What I would do is to un-comment some of the `pprTrace` lines in GHC.Core.Opt.Specialise and try again to ss what's going on inside the specialiser. But that requires you to build GHC itself, and I don't know if you are set up to do that.
Simon On Tue, 4 Aug 2026 at 22:08, Justin Bailey via ghc-devs < [email protected]> wrote: > All, > > Looking for some guidance on narrowing down an issue I am seeing at > work. Some background: large monorepo, many packages; I'm on MacOS > Tahoe (26.6). > > I have a problematic module that causes GHC to allocate a HUGE amount > of memory under certain conditions. Compilation never finishes - > instead, the process is killed by the OS. > > * With -O1, GHC consumes a huge amount of memory (> 32GB) before > getting killed by the OS. > * Without -O1, but with all available -f flags that seemed to be > implied by -O1, GHC does NOT blow up and compilation succeeds. (List > of flags below.) > > The last output (with -ddump-phases) in the failing case is always > "*** Specialise [aaa.Tests.Service.Client.TestHelpers]:" followed by a > newline, then nothing else. > > I'm working to isolate the code that's causing the problem, to get to > a repro case, but in the meantime can anyone suggest why -O1 fails but > all the -f flags do not? > > Thank you! > > p.s. I'm happy to share logs but don't want to spam the list if those > aren't necessary. > > ********** > Here are all the flags I used in place of -O1: > > -fblock-layout-cfg > -fcall-arity > -fcase-folding > -fcase-merge > -fcore-constant-folding > -fcmm-control-flow > -fcmm-elim-common-blocks > -fcmm-sink > -fcmm-static-pred > -fcore-constant-folding > -fcpr-anal > -fcross-module-specialise > -fcse > -fenable-rewrite-rules > -fexitification > -ffloat-in > -ffull-laziness > -fignore-asserts > -finline-generics > -floopification > -fnum-constant-folding > -fsolve-constant-dicts > -fspecialise > -fstg-cse > -fstrictness > -funbox-small-strict-fields > -fworker-wrapper > > > ********** > > Here is the (possibly) relevant logs for compilation with -O1 that failed: > > *** Checking old interface for aaa.Tests.Service.Client.TestHelpers > (use -ddump-hi-diffs for more details): > [62 of 74] Compiling aaa.Tests.Service.Client.TestHelpers ( > test/aaa/Tests/Service/Client/TestHelpers.hs, > > /Users/xxx.yyy/Source/health-engine/well-he-aaa/worktrees/master/dist-newstyle/build/aarch64-osx/ghc-9.14.1/aaa-service-client-0.0.0/t/test/noopt/build/test/test-tmp/aaa/Tests/Service/Client/TestHelpers.o, > > /Users/xxx.yyy/Source/health-engine/well-he-aaa/worktrees/master/dist-newstyle/build/aarch64-osx/ghc-9.14.1/aaa-service-client-0.0.0/t/test/noopt/build/test/test-tmp/aaa/Tests/Service/Client/TestHelpers.dyn_o > ) > *** Parser [aaa.Tests.Service.Client.TestHelpers]: > !!! Parser [aaa.Tests.Service.Client.TestHelpers]: finished in 7.28 > milliseconds, allocated 2.470 megabytes > *** Renamer/typechecker [aaa.Tests.Service.Client.TestHelpers]: > *** ConsistencyCheck [aaa.Tests.Service.Client.TestHelpers]: > !!! ConsistencyCheck [aaa.Tests.Service.Client.TestHelpers]: finished > in 1763.61 milliseconds, allocated 750.592 megabytes > !!! Renamer/typechecker [aaa.Tests.Service.Client.TestHelpers]: > finished in 2449.36 milliseconds, allocated 962.845 megabytes > *** Desugar [aaa.Tests.Service.Client.TestHelpers]: > Result size of Desugar (before optimization) > = {terms: 713, types: 33,167, coercions: 15,521, joins: 0/171} > Result size of Desugar (after optimization) > = {terms: 551, types: 27,957, coercions: 15,828, joins: 0/93} > !!! Desugar [aaa.Tests.Service.Client.TestHelpers]: finished in 5.46 > milliseconds, allocated 2.524 megabytes > *** Simplifier [aaa.Tests.Service.Client.TestHelpers]: > Result size of Simplifier iteration=1 > = {terms: 2,677, types: 74,181, coercions: 37,908, joins: 0/155} > Result size of Simplifier iteration=2 > = {terms: 1,737, types: 52,195, coercions: 27,615, joins: 0/88} > Result size of Simplifier iteration=3 > = {terms: 1,673, types: 51,005, coercions: 19,466, joins: 0/80} > Result size of Simplifier iteration=4 > = {terms: 1,630, types: 50,531, coercions: 19,333, joins: 0/78} > Result size of Simplifier > = {terms: 1,630, types: 50,531, coercions: 19,333, joins: 0/78} > !!! Simplifier [aaa.Tests.Service.Client.TestHelpers]: finished in > 217.38 milliseconds, allocated 120.723 megabytes > *** Specialise [aaa.Tests.Service.Client.TestHelpers]: > > ********** > > Here are those same logs (up to specialisation) for a compilation that > succeeded (no -O1, only the -f flags): > > *** Checking old interface for aaa.Tests.Service.Client.TestHelpers > (use -ddump-hi-diffs for more details): > [62 of 74] Compiling aaa.Tests.Service.Client.TestHelpers ( > test/aaa/Tests/Service/Client/TestHelpers.hs, > > /Users/xxx.yyy/Source/health-engine/well-he-aaa/worktrees/master/dist-newstyle/build/aarch64-osx/ghc-9.14.1/aaa-service-client-0.0.0/t/test/noopt/build/test/test-tmp/aaa/Tests/Service/Client/TestHelpers.o, > > /Users/xxx.yyy/Source/health-engine/well-he-aaa/worktrees/master/dist-newstyle/build/aarch64-osx/ghc-9.14.1/aaa-service-client-0.0.0/t/test/noopt/build/test/test-tmp/aaa/Tests/Service/Client/TestHelpers.dyn_o > ) > *** Parser [aaa.Tests.Service.Client.TestHelpers]: > !!! Parser [aaa.Tests.Service.Client.TestHelpers]: finished in 5.70 > milliseconds, allocated 2.470 megabytes > *** Renamer/typechecker [aaa.Tests.Service.Client.TestHelpers]: > *** ConsistencyCheck [aaa.Tests.Service.Client.TestHelpers]: > !!! ConsistencyCheck [aaa.Tests.Service.Client.TestHelpers]: finished > in 1707.88 milliseconds, allocated 749.094 megabytes > !!! Renamer/typechecker [aaa.Tests.Service.Client.TestHelpers]: > finished in 2305.51 milliseconds, allocated 959.358 megabytes > *** Desugar [aaa.Tests.Service.Client.TestHelpers]: > Result size of Desugar (before optimization) > = {terms: 713, types: 33,167, coercions: 15,521, joins: 0/171} > Result size of Desugar (after optimization) > = {terms: 551, types: 27,957, coercions: 15,828, joins: 0/93} > !!! Desugar [aaa.Tests.Service.Client.TestHelpers]: finished in 4.66 > milliseconds, allocated 2.526 megabytes > *** Simplifier [aaa.Tests.Service.Client.TestHelpers]: > Result size of Simplifier iteration=1 > = {terms: 555, types: 27,953, coercions: 15,828, joins: 0/93} > Result size of Simplifier > = {terms: 555, types: 27,953, coercions: 15,828, joins: 0/93} > !!! Simplifier [aaa.Tests.Service.Client.TestHelpers]: finished in > 8.60 milliseconds, allocated 5.818 megabytes > *** Specialise [aaa.Tests.Service.Client.TestHelpers]: > Result size of Specialise > = {terms: 555, types: 27,953, coercions: 15,828, joins: 0/10} > !!! Specialise [aaa.Tests.Service.Client.TestHelpers]: finished in > 3.98 milliseconds, allocated 2.227 megabytes > _______________________________________________ > ghc-devs mailing list -- [email protected] > To unsubscribe send an email to [email protected] >
_______________________________________________ ghc-devs mailing list -- [email protected] To unsubscribe send an email to [email protected]
