Custom GHCi driver is painfully slow
Summary
I'm inclined to write a custom ghci
that has support for a custom DSL. I used https://gitlab.haskell.org/ghc/ghc/-/tree/ghc-9.6.2-release/ghc as a starting point.
However, a custom build of the ghc
main driver behaves painfully slow when loading libraries. This is even the case without any modifications to the source.
Not sure what I'm doing wrong here. Any help is greatly appreciated.
Steps to reproduce
$ wget https://downloads.haskell.org/~ghc/9.6.2/ghc-9.6.2-src.tar.xz
$ tar xvf ghc-9.6.2-src.tar.xz
$ cd ghc-9.6.2/ghc/
$ mv ghc-bin.cabal.in ghc-bin.cabal
$ sed -i 's/@ProjectVersion@/9.6.2/' ghc-bin.cabal
$ sed -i 's/@ProjectVersionMunged@/9.6.2/' ghc-bin.cabal
$ cabal configure --enable-optimization -finternal-interpreter
$ cabal build
$ time $(cabal list-bin ghc) -B$(ghc --print-libdir) -e '' -package ghc -v3
...
Loading unit ghc-9.6.2 ... <-- !!! THIS IS SLOW !!!
...
real 0m9.459s
user 0m9.185s
sys 0m0.247s
$ time ghc -e '' -package ghc -v3
real 0m0.060s
user 0m0.045s
sys 0m0.015s
Note that:
- From what I tried, only
--interactive
/-e
seems to be slow. Normal compilation is swift. -
-v3
reveals that loading packages / libraries seems to be slow.
Expected behavior
The custom driver and ghc
should behave similar, performance wise.
Environment
- GHC version used: 9.6.2
- Operating System: Linux
- System Architecture: x86-64