Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GHC 8.6.5 takes minutes to compile Agda's Parser.hs #317

Closed
andreasabel opened this issue Sep 30, 2024 · 4 comments
Closed

GHC 8.6.5 takes minutes to compile Agda's Parser.hs #317

andreasabel opened this issue Sep 30, 2024 · 4 comments

Comments

@andreasabel
Copy link
Member

andreasabel commented Sep 30, 2024

It is known that the .hs files generated by happy 2.0 can be 25% larger than the ones generated by happy 1.20. This is e.g. the case for Agda's Parser.hs generated from https://github.com/agda/agda/blob/7ea5bfa3d6bd374a2f4a0c40534a515b399787a9/src/full/Agda/Syntax/Parser/Parser.y .

However, we are also seeing a compile-time deterioration for some GHCs, e.g. 8.6.5.

Anecdotally, GHC 8.6.5 pauses for several minutes on my machine when type-checking the happy-2.0 generated Parser.hs. (Type-checking this is usually instantaneous.)

$ ./tc.sh -w ghc-8.6.5
Build profile: -w ghc-8.6.5 -O1
In order, the following will be built (use -v for more details):
 - Agda-2.8.0 (lib:Agda, exe:agda, exe:agda-mode) (first run)
...
[ 67 of 434] Compiling Agda.Utils.Monad ( src/full/Agda/Utils/Monad.hs, nothing )
[ 68 of 434] Compiling Agda.Utils.ListT ( src/full/Agda/Utils/ListT.hs, nothing ) [Agda.Utils.Monad changed]
[ 69 of 434] Compiling Agda.Utils.FileName ( src/full/Agda/Utils/FileName.hs, nothing ) [Agda.Utils.Monad changed]
[ 85 of 434] Compiling Agda.Utils.Benchmark ( src/full/Agda/Utils/Benchmark.hs, nothing ) [Agda.Utils.Monad changed]
[122 of 434] Compiling Agda.TypeChecking.Free.Lazy ( src/full/Agda/TypeChecking/Free/Lazy.hs, nothing ) [Agda.Utils.Monad changed]
[148 of 434] Compiling Agda.Syntax.Parser.Helpers ( src/full/Agda/Syntax/Parser/Helpers.hs, nothing ) [Agda.Utils.Monad changed]
[149 of 434] Compiling Agda.Syntax.Parser.Parser ( dist-no-code/build/x86_64-osx/ghc-8.6.5/Agda-2.8.0/build/Agda/Syntax/Parser/Parser.hs, nothing ) [Agda.Utils.Monad changed]
(5 min wait here)
```
@andreasabel
Copy link
Member Author

I think I was too quick to blame 2.0 here. It is also slow with 1.20.1.1. Seems to be a GHC problem that was likely fixed in 8.8:

Similar issue:

@andreasabel andreasabel closed this as not planned Won't fix, can't repro, duplicate, stale Sep 30, 2024
@andreasabel andreasabel changed the title Regression in 2.0: GHC 8.6.5 takes now minutes to compile Agda's Parser.hs GHC 8.6.5 takes minutes to compile Agda's Parser.hs Sep 30, 2024
@sgraf812
Copy link
Collaborator

Yes, that's the issue I had in mind as well. Good thing it's not entirely on 2.0

Out of curiousity: You say

It is known that the .hs files generated by happy 2.0 can be 25% larger than the ones generated by happy 1.20.

That seems surprising to me, because it's not like we changed the generation of the automaton. Do you mean .hs file size of .o file size? Could you perhaps look at a diff and give a qualitative assessment which parts have become larger?

andreasabel added a commit to agda/agda that referenced this issue Sep 30, 2024
Reason: GHC 8.6 is still slow building the happy-generated Parser.hs,
GHC 8.8 does not have this problem.

See haskell/happy#317
@andreasabel
Copy link
Member Author

So for -acg the generated .hs increased from 830K to 1050K, and for no options from 590K to 940K. I attach these products if you want to dig deeper.
Parser.zip

@sgraf812
Copy link
Collaborator

sgraf812 commented Sep 30, 2024

Thanks. I now recall why the parser is larger. It's the result of #266 (silly me) and I don't think we should go back.

Ironically, the biggest array in there is still happyExpList, which ends up as a dead binding because Agda doesn't use the expected token list feature. I have plans for getting rid of this array in #271 which will hopefully land with #272/#283 (which are essentially the same patch).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants