haskell / cabal

Official upstream development repository for Cabal and cabal-install
https://haskell.org/cabal
Other
1.63k stars 696 forks source link

Profiling `cabal exec -v0 -- ghc --print-libdir` #9546

Open Kleidukos opened 11 months ago

Kleidukos commented 11 months ago

cabal exec -v0 -- ghc --print-libdir takes between 5 and 10 seconds to execute on a decent machine. Since it is part of the commands used by HLS when starting, I would like to do a temporal profiling and see if we can help improve the start time of HLS.

fendor commented 11 months ago

I think exec requires setting up a lot of the environment, solving for a build-plan, install dependencies...

To speed it up, we can either introduce a special case for ghc (bad idea since cabal exec -- ghci opens a ghci session with local packages installed), or take a look at the cabal paths (can't find the PR) or cabal status to give a fast path for project information.

Also, as additional data points:


Executed in 115.27 millis fish external usr time 54.71 millis 0.00 micros 54.71 millis sys time 52.14 millis 555.00 micros 51.58 millis


* On a completely clean project (but dependencies already installed)

time cabal exec -- ghc --print-libdir Resolving dependencies... /home/hugin/.ghcup/ghc/9.6.3/lib/ghc-9.6.3/lib


Executed in 3.58 secs fish external usr time 3.11 secs 455.00 micros 3.11 secs sys time 0.41 secs 66.00 micros 0.41 secs