dpranke suggested that external include guards might speed up
compilation on windows quite a bit. External include guard means that
instead of including a file like this
#include "base/string16.h"
you include it like this:
#ifndef BASE_STRING16_H_
#include "base/string16.h"
#endif
(assuming that BASE_STRING16_H_ is the include guard used in string16.h).
The idea is that if string16.h has been included already, the compiler
doesn't even need to start string16.h a second time.
Another approach to achieve more or less the same is to add #pragma
once to string16.h. This is nicer in that including files don't need
to be littered with #ifndef/#endif noise. The downside is that not all
compilers support #pragma once (but both gcc and msvc do, and other
compilers just ignore it, so it doesn't really hurt).
gcc doesn't need external include guards and does this optimization
itself, but msvc doesn't seem to do this.
http://www.gamearchitect.net/Articles/ExperimentsWithIncludes.html
suggests that as well.
I tried doing clean builds of chrome on my windows box (z600). I did
this only for base, chrome, gfx for testing, but that should be good
enough to get an idea. Results:
Normal clean build: 40 min (I'm apparently not using /mp?)
Clean build w/ #pragma once to all headers in chrome, base, and gfx: 36 min
Clean build w / external include guards: 35 min
This suggests we should add "#pragma once" to all our header files
(except for the _messages_internal headers used for IPC, cause that
breaks stuff). Is anyone opposed to this idea?
Nico
ps:
pragma once: http://codepad.org/AXRjx93w
external guards: http://codepad.org/jxdtJDc8
-- Dirk
> --
> Chromium Developers mailing list: chromi...@chromium.org
> View archives, change email options, or unsubscribe:
> http://groups.google.com/a/chromium.org/group/chromium-dev
>
I retested on windows /mp, and build times went from 13 to 11 minutes.
http://src.chromium.org/viewvc/chrome/trunk/src/tools/pragmaonce/pragmaonce.py?view=markup&pathrev=53271
does now contain the script I intend to run on our source some time
next week (if I hear no objections until then).
Nico
On Wed, Jul 21, 2010 at 3:25 PM, Dirk Pranke <dpr...@chromium.org> wrote:
I just tested on Mac with, and as expected build times didn't change.
I retested on windows /mp, and build times went from 13 to 11 minutes.
http://src.chromium.org/viewvc/chrome/trunk/src/tools/pragmaonce/pragmaonce.py?view=markup&pathrev=53271
does now contain the script I intend to run on our source some time
next week (if I hear no objections until then).
http://build.chromium.org/buildbot/waterfall/stats/Chromium%20XP
http://build.chromium.org/buildbot/waterfall/stats/Chromium%20Builder
http://build.chromium.org/buildbot/waterfall/stats/Chromium%20Builder%20(dbg)
, build times on the bots didn't go down at all (how often are these
charts updated? They're not labeled).
On Wed, Jul 21, 2010 at 3:10 PM, Elliot Glaysher <e...@google.com> wrote:
> Feel free to send the review to me when you do this.
On Tue, Jul 27, 2010 at 9:25 AM, Thomas Van Lenten <thom...@google.com> wrote:
> I believe they update with every run.
> TVL
I added #pragma once to ~2700 header files yesterday. Judging from
http://build.chromium.org/buildbot/waterfall/stats/Chromium%20XP
http://build.chromium.org/buildbot/waterfall/stats/Chromium%20Builder
http://build.chromium.org/buildbot/waterfall/stats/Chromium%20Builder%20(dbg)
, build times on the bots didn't go down at all (how often are these
charts updated? They're not labeled).
It adds maintenance burden. Everyone will need to learn to maintain this and add #pragma once to new files. That is not free.
Perhaps a presubmit check could be written. If this is really worth it, then we should probably implement that.
-- Dirk
I think this ended up being unclear if it was a win or not, so we're
not currently requiring it (or forbidding it).