Changes between Initial Version and Version 1 of April 2011 Meeting/Getting compile time under control


Ignore:
Timestamp:
Apr 25, 2011 11:32:00 AM (13 years ago)
Author:
Adam Roben
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • April 2011 Meeting/Getting compile time under control

    v1 v1  
     1= TODO =
     2 * Run Include What You Use
     3 * Measure compile times of individual files
     4 * Experiment with splitting Frame data members into a base class
     5 * Experiment with splitting inline functions into a separate file so that they are not actually inlined in Debug builds, especially for commonly-included files
     6 * Create a way to measure build time and track that over time, perhaps including compiling old builds to get historical data
     7 * Experiment with un-inlining functions in commonly-included headers
     8
     9= Notes =
     10
     11What are the major issues with compile time? What is causing slowness?
     12
     13How many files recompile when you make a change?
     14How long does it take one file to compile?
     15How long is linking?
     16How long do generation scripts take?
     17How long does the build system take to calculate dependencies?
     18
     19How long is a no-op build
     20Chromium Linux no-op build is <10 seconds (make)
     21Ninja (make replacement) is 0.1 seconds for dependency analysis
     22
     23Geoff: Fixed cost of no-op build is 30-60 seconds, linking is 30-60 seconds, rebuilding lots of files is 20-30 minutes
     24
     25Sam: When I started on the project I could build and run tests in under an hour
     26
     27Gavin: Platform.h causes lots of recompilation and is touched frequently, would be interesting to look at stats of how frequently certain files are changed vs. how many files they cause to be recompiled
     28
     29abarth: Someone wrote a script for analyzing header dependency graph, what are the biggest wins for reducing header includes?
     30Sam: Document.h, Frame.h, FrameLoader.h, etc.
     31
     32Eric: Frame.h includes some headers so that some of its members don't have to be pointers
     33
     34abarth: How long does Frame.cpp take to compile?
     35Sam: 3rd-longest in the source tree
     36
     37Michael: Reducing the number of files that have to be compiled is the biggest win
     38
     39Can we extract data members into simple base classes that don't include all the member functions?
     40A lot of files just need to access Frame's members, don't need its other functions, so this could be a big win
     41
     42Eric: .h files including other .h files contributes to .o file size, maybe also to linking time etc.
     43
     44Dan: >10% of the object files on Mac are essentially empty object files from .cpp files for disabled features
     45Dan: It's unlikely that those rebuild a lot, but the linker still has to open and process them
     46Dan: Maybe we can avoid compiling files for disabled features at all (e.g., by using a smarter build system or better naming conventions)
     47abarth: Generating a build system can help with this
     48Dan: Also built-in features of Xcode can do it
     49
     50Geoff: How can we reduce the time when you *do* need to rebuild everything (like I often do)
     51Geoff: It's not disk-bound, but I don't know where the time is being spent
     52
     53Sam: How can we figure out what the costs are?
     54
     55Geoff: Run a clean world build and sort by most expensive files to compile, then compile those individually and profile the compiler
     56Eric: And look at the intermediate files
     57
     58Someone: Worked on Chrome build, made it 25% faster (not familiar with WebKit though)
     59Main reason for long build times is that we have too much code
     60One way is to remove features
     61Inline code gets compiled multiple times, then linker has to strip them out
     62Implicit constructor/destructors are also inlined
     63Templates also generate a lot of code, one solution is to pull most code into a non-template base class
     64WTF::Vector uses 700k of binary data in WebKit, etc.
     65Include What You Use tool can help identify unnecessary includes
     66
     67Sam: Switching to Clang is a big speedup, too, but can't switch right now for some reason
     68
     69We can use the CC environment variable to find out how long it takes to compile individual files (maybe add a flag to build-webkit)
     70
     71Does #pragma once help? No, not any better than #ifdef guards
     72
     73We include RefPtr/PassRefPtr in a lot of places
     74We have Forward.h but don't know when to use it
     75Forward.h can let you avoid including RefPtr.h in a header, but inline functions that use RefPtrs defeat this strategy
     76
     77What about not having any #include statements in .h files?
     78Might be able to help based on experience with another project, but it's ugly
     79
     80Chromium bots keep a graph of compile time
     81General trend is up, but it's fairly level
     82No-op builds are around 90 seconds, longest builds are around 1 hour
     83
     84Tony Gentilcore worked on using forward-declarations more aggressively
     85Helped with clean time but not rebuild time
     86
     87Even if we get rid of all unnecessary #includes, we'll still have a lot of inline functions which require you to #include lots of things
     88Maybe we could put all inline functions into a single header file
     89Could try to include that file as little as possible
     90Could also, in Debug builds, put the function definitions into .cpp file so that Debug builds don't pay the compile-time cost of inline functions
     91Could do this on a per-class basis
     92Can we just use a don't inline flag instead? No, the compiler still has to read the function definitions, etc.
     93
     94Could instead use a linker that knows how to inline at compile-time
     95More generally, we should move everything we can into .cpp files if it doesn't affect performance
     96
     97Would be good to have historical data for build time, lines of code, etc.
     98
     99Can we measure the incremental effect of a new commit? Should we yell at people for increasing compile time?
     100What do we measure? Clean builds, incremental builds, something else?
     101Maybe should only yell for individual commits that massively increase compile time
     102
     103Can use Clang plugins to detect when an inlined function contains a large template instantiation, etc.
     104
     105What are we optimizing for? Link time (good for people with infinite CPUs)? Compile time?
     106
     107A compile farm for WebKit developers' use could perhaps reduce compile times
     108Maybe this won't work for Apple
     109Maybe this isn't practical across the whole internet
     110
     111How much time is spent on code generation vs. preprocessing?
     112Once upon a time, a lot of time was spent statting directories to find include files (gets worse as the number of include paths goes up)
     113
     114SSDs give questionable improvements (maybe just for incremental builds, maybe just makes your computer more usable while compiling)
     115Some tests showed that, given sufficient RAM, SSDs didn't help much
     116
     117If you don't have enough RAM to fit all of WebKit in Mac OS X's vnode cache, your build time is waaaaay longer
     118
     119lipoing GCC down to 32 bits helps reduce memory usage because GCC stores lots of pointers
     120
     121Is it possible to split WebKit into multiple libraries?
     122On Mac OS X, we have 4 frameworks: JSC, WebCore, WebKit, WebKit2
     123We've discussed splitting out WebCore/platform, but layering violations make it hard
     124Also discussed splitting out WTF
     125
     126Chromium uses a bindings layer on top of WebCore (.a)
     127
     128Could try un-inlining functions in commonly-included headers
     129Hard to measure the effect
     130Could be dangerous not to inline trivial data accessors