You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I just run the almost-noop command: time cabal build asdf
cabal: Unknown build target 'asdf'.
There is no component 'asdf' or module 'asdf'.
cabal build asdf 3.82s user 0.08s system 99% cpu 3.903 total
What is cabal doing in these 4 seconds?
When I run time cabal build asdf -v3, I get the output
Using internal setup method with build-type Simple and args:
["build","--verbose=3","--builddir=dist","--jobs=1","asdf"]
after 2 seconds, and then the rest of the output after another 2 seconds.
I also noticed that this time seems to grow the longer I make the build-depends section in my cabal file.
What is going on behind the scenes, and can we make this no-op time faster?
This startup time seems to add to all cabal build commands; it is especially painful for builds with nothing to do, where the penalty is quite high versus the actual time needed to compile: A no-op build only takes 6.8 seconds for me.
Correct me if I'm wrong, but the time is spent in parsing internal structures, not .cabal file. So some kind of efficient binary serialization seems to be the right solution.
% time cabal build --only -v asdf
Skipping add-source deps check...
Using a sandbox located at /home/feuerbach/work/.cabal-sandbox
cabal: Unknown build target 'asdf'.
There is no component 'asdf' or module 'asdf'.
cabal build --only -v asdf 1.91s user 0.02s system 100% cpu 1.928 total
I just tried with a larger sandbox (installed snap, haskell-src-exts and all lens dependencies + a single add-source dep), but it didn't make a big difference:
cabal build asdf 0,82s user 0,04s system 91% cpu 0,938 total
build --only time is the same:
cabal build --only asdf 0,83s user 0,04s system 90% cpu 0,957 total
@23Skidoo GHC ships with binary, and since GHC 7.2, binary has a generic instance. GHC 7.2.1 was released 9 August 2011, so it just fell within our 3 year backward-compatible window! That means we can migrate to Binary instead of Read/Show with no boilerplate.
@dcoutts@tibbe Any objections to deriving Generic on all the LocalBuildInfo-related types, and switching to a binary setup-config?
Activity
tibbe commentedon May 4, 2014
That's an interesting observation. Since -v3 doesn't give you much, could you try with time profiling to see roughly what cabal is doing?
UnkindPartition commentedon Jul 23, 2014
Full profile: https://gist.github.com/08f25e0fa907e239be9f
This is with current cabal master (d35bf72).
nh2 commentedon Jul 23, 2014
Oh well,
read, what pleasure.23Skidoo commentedon Jul 23, 2014
@dcoutts's new parser would probably help here.
UnkindPartition commentedon Jul 24, 2014
Correct me if I'm wrong, but the time is spent in parsing internal structures, not .cabal file. So some kind of efficient binary serialization seems to be the right solution.
23Skidoo commentedon Jul 24, 2014
Yes, it may also be
dist/setup-config, where we are basically doing a singleread.23Skidoo commentedon Jul 24, 2014
@nh2 Is the package that you're experiencing this with on Hackage? On my system, the no-op time is a bit faster (I tested with
lens):UnkindPartition commentedon Jul 24, 2014
@23Skidoo try this in a sandbox with many packages installed
23Skidoo commentedon Jul 24, 2014
Then it's likely the
add-sourcedeps check, which reads the installed package index. So we should be optimisinggetPackageDBContents.UnkindPartition commentedon Jul 24, 2014
Well...
23Skidoo commentedon Jul 24, 2014
I just tried with a larger sandbox (installed
snap,haskell-src-extsand alllensdependencies + a single add-source dep), but it didn't make a big difference:build --onlytime is the same:UnkindPartition commentedon Jul 24, 2014
Can you take a look at the full profile that I published above? It should point exactly to where the time is spent.
23Skidoo commentedon Jul 24, 2014
Well, it does look like half of the time is spent in parsing
dist/setup-config.So the larger that file is (which depends on how many dependencies you have), the longer it should take.
23Skidoo commentedon Jul 24, 2014
OK, I tested this theory, and the do-nothing
cabal buildindeed takes longer on packages with large sets of dependencies, such assnap:So the problem is inefficient parsing of
LocalBuildInfo.nh2 commentedon Jul 24, 2014
Could
Cabaldepend onbinaryif it wanted?23Skidoo commentedon Jul 25, 2014
Maybe. GHC ships with
binary.ttuegel commentedon Aug 29, 2014
@23Skidoo GHC ships with
binary, and since GHC 7.2,binaryhas a generic instance. GHC 7.2.1 was released 9 August 2011, so it just fell within our 3 year backward-compatible window! That means we can migrate toBinaryinstead ofRead/Showwith no boilerplate.@dcoutts @tibbe Any objections to
deriving Genericon all theLocalBuildInfo-related types, and switching to a binarysetup-config?tibbe commentedon Aug 29, 2014
@ttuegel not from my perspective.
23Skidoo commentedon Aug 31, 2014
Fixed by #2076. Thanks to @feuerbach for helping to diagnose the problem and @ttuegel for actually writing the code.