[LLVMdev] #include <iostream>

Chris Lattner sabre at nondot.org
Fri Dec 8 11:34:16 PST 2006


On Fri, 8 Dec 2006, Vladimir Prus wrote:
> And what is the actual measured effect on compile time and run time?

The main impact of eliminating the #include of <iostream> is that it 
eliminates a static ctor from each .o file that #includes it.  For 
something like llvm-gcc4, this will marginally reduce the startup time of 
the app, though probably not significantly (it may not even be 
measurable).

The primary reason for doing this is to support clients using LLVM as 
libraries as part of larger systems.  In particular, we statically link 
LLVM into some dynamic libraries.  Even if LLVM isn't used, the static 
ctors are run whenever an app starts up that uses the dynamic library. 
There are two problems with this: 1) The time to run the static ctors 
impacts startup time of applications, a critical time for gui apps.  2) 
the static ctors cause the app to pull many extra pages of memory off the 
disk: both the code for the static ctors in each .o file and the small 
amount of data that gets touched.  In addition, touched/dirty pages put 
more pressure on the VM system on low-memory machines.

#2 is the big killer, and it's a reason we're eliminating static ctors in 
general.  Soon I will be landing a patch to the Statistic class that 
eliminates its static ctor, which will eliminate another large 
contributor to the problem.

-Chris

-- 
http://nondot.org/sabre/
http://llvm.org/



More information about the llvm-dev mailing list