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

"Setting up GHC" slowdown when going from GHC 9.0 to 9.4 #2710

Open
gergoerdi opened this issue Apr 14, 2024 · 9 comments
Open

"Setting up GHC" slowdown when going from GHC 9.0 to 9.4 #2710

gergoerdi opened this issue Apr 14, 2024 · 9 comments

Comments

@gergoerdi
Copy link
Contributor

I'm trying to upgrade Pong to use Clash 1.8 with a recent version of GHC. I've managed to upgrade to Clash 1.8/GHC 9.0, but then when I try to switch to GHC 9.4, I start getting problems in Clashilator.

I'll need to investigate some of them on my side first, but one thing I noticed is that with GHC 9.0, the "Setting up GHC" step takes <1s and on GHC 9.4 it takes almost a minute. You can try it on this temporary branch just running stack build --flag clash-pong:verilator:

clash-pong > GHC: Setting up GHC took: 57.114s
clash-pong > GHC: Compiling and loading modules took: 2.587s
clash-pong > Clash: Parsing and compiling primitives took 0.125s
clash-pong > GHC+Clash: Loading modules cumulatively took 1m0s
clash-pong > Clash: Compiling Pong.topEntity
clash-pong > Clash: Normalization took 0.287s
clash-pong > Clash: Netlist generation took 0.015s
clash-pong > Clash: Compiling Pong.topEntity took 0.414s
clash-pong > Clash: Total compilation took 1m0s

@martijnbastiaan
Copy link
Member

Perhaps same as #2684 ?

@martijnbastiaan
Copy link
Member

And maybe the same as martijnbastiaan/doctest-parallel#78..

@christiaanb
Copy link
Member

Is the executable dynamically linked?

@martijnbastiaan
Copy link
Member

@gergoerdi This is the same issue as doctest-parallel runs into. Downgrading to GHC 9.4.7 / LTS 21.21 "fixes" the issue.

@gergoerdi
Copy link
Contributor Author

Is the executable dynamically linked?

Stupid question but -- how do I tell?

@gergoerdi
Copy link
Contributor Author

Stupid question but -- how do I tell?

OK so with stack build --cabal-verbose --verbose I was able to find the setup program generated by Cabal, which is what is running Clash in-proc (using Clash.Main.defaultMainWithAction) and indeed it is dynamically linked. I have no idea how to control this, since this program is built by Cabal/Stack from Setup.hs.

@gergoerdi
Copy link
Contributor Author

@gergoerdi This is the same issue as doctest-parallel runs into. Downgrading to GHC 9.4.7 / LTS 21.21 "fixes" the issue.

FWIW I can confirm this.

@gergoerdi
Copy link
Contributor Author

Stupid question but -- how do I tell?

OK so with stack build --cabal-verbose --verbose I was able to find the setup program generated by Cabal, which is what is running Clash in-proc (using Clash.Main.defaultMainWithAction) and indeed it is dynamically linked. I have no idea how to control this, since this program is built by Cabal/Stack from Setup.hs.

According to more stack build --cabal-verbose --verbose, the setup program gets compiled with the following flags:

ghc-9.4.8
        --make
        -odir /home/cactus/prog/clash/pong/.stack-work/dist/x86_64-linux/ghc-9.4.8/setup
        -hidir /home/cactus/prog/clash/pong/.stack-work/dist/x86_64-linux/ghc-9.4.8/setup
        -i -i.
        -clear-package-db -global-package-db -package-db=/home/cactus/sdk/stack/snapshots/x86_64-linux/27724336f5cab67ecb9719f752c3eaa6ba6a8ae2f840f16180637123d005e264/9.4.8/pkgdb -package-db=/home/cactus/prog/clash/pong/.stack-work/install/x86_64-linux/27724336f5cab67ecb9719f752c3eaa6ba6a8ae2f840f16180637123d005e264/9.4.8/pkgdb
        -hide-all-packages -package-id=Cabal-3.8.1.0 -package-id=base-4.17.2.1 -package-id=clashilator-0.1.3-IfbBYrcr43e6EtNP5GgB1K
        -optP-include -optP/home/cactus/prog/clash/pong/.stack-work/dist/x86_64-linux/ghc-9.4.8/setup/setup_macros.h
        /home/cactus/prog/clash/pong/Setup.hs
        /home/cactus/sdk/stack/setup-exe-src/setup-shim-6HauvNHV.hs
        -main-is StackSetupShim.mainOverride
        -o /home/cactus/prog/clash/pong/.stack-work/dist/x86_64-linux/ghc-9.4.8/setup/setup
        -threaded

Nothing immediately jumps at me that would set -dynamic.

@christiaanb
Copy link
Member

I was only asking whether the executable was dynamically linked, because I know that the clash binaries have a very slow startup time when they are statically linked (on non-Windows platforms) to Haskell libraries. So if you're saying that your binary is dynamically linked to other Haskell libraries, than that is not the issue.

I think you confirmed that the issue doesn't show itself with GHC 9.4.7, which suggests it's the same issue that was hurting doctest-parallel: https://gitlab.haskell.org/ghc/ghc/-/issues/23464

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

No branches or pull requests

3 participants