On Tuesday, 28 November 2006 18:05, D. Michael McIntyre wrote:
> On Monday 27 November 2006 4:47 pm, Pedro Lopez-Cabanillas wrote:
> > with full debug. I would like to hear your opinions, bug reports, and
> > time savings numbers.
>
> I didn't tweak anything, because I have no idea how to tweak anything and
> am not even sure if I'm expected to tweak something.

OK, I understand that you are requesting some explanation about how the PCH 
works.

There is a new header (src/misc/stableheaders.h) which is made #including all 
the Qt and KDE headers, and also some standard C++ library headers. This 
header is precompiled as the first step of the build process, and the output  
resulting from the compiler (a PCH file) is stored in the directory 
RGbuild/stableheaders.h.gch/ in a file named "${CMAKE_BUILD_TYPE}.c++", so in 
the destination dir you can have as much as three files: "Debug.c++", 
"Release.c++" and "RelWithDebInfo.c++"; this is necessary because the 
compiler will reject the PCHs which don't match exactly the same flags used 
by the current compilation step.

When the .cpp sources are compiled, the PCH is included using the following 
option in the command line: "-include stableheaders.h"
The compiler will search the include directories (-I) for a file or directory 
named "stableheaders.h.gch" and if it is a directory it selects the PCH 
having the best matching flags. More details about this are explained here:
http://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html

How can we improve the compile times? Of course if there is some Qt/KDE header 
used by Rosegarden but missing from stableheaders.h, it should be included. 
We can use the preprocessor flag "-H" to spy which headers are processed on 
each compilation step, and the compiler flag "-Winvalid-pch" to get a warning 
from the compiler when there is a PCH file found but can't be used because 
the compiler flags, or whatever reason. See the last lines of the script  
cmake_admin/UsePCH.cmake to get the idea.

Using PCH and the -H flag you can observe that there are still some Qt and KDE 
headers printed, but much less than when PCH is not used. This is because the 
files explicitly included in the sources are still read by the preprocessor. 
As the headers usually have the "#ifndef NAME_H" protection, the body isn't  
processed again if it was already included from the PCH. An optimization 
could be to protect the #include lines in every source with "#ifndef  
USE_PCH", but this would be a lot of work, and perhaps it is not worth.

An unrelated optimization on build time would be to use the CMake option   
KDE3_ENABLE_FINAL, which doesn't work at this moment (it fails to execute the  
moc process). It should create for each executable a big file including all 
the sources, and compiling it in one single and big step. This would require 
a large amount of memory for Rosegarden, but could be efficient.

If somebody has GCC 3.4.6 or above, please test PCH support with it:
http://gcc.gnu.org/onlinedocs/gcc-3.4.6/gcc/Precompiled-Headers.html

> Full debug build with all options TRUE:
>
> PCH:
> real    11m52.095s
> user    8m41.077s
> sys     1m13.334s
>
> No PCH:
> real    15m44.583s
> user    13m5.823s
> sys     0m59.931s
>
> gcc (GCC) 4.0.3 (Ubuntu 4.0.3-1ubuntu5)

Very similar to my ~30% time savings.

> Let's see...  Not exactly 100% accurate, but fairly close.  For comparison,
> I dug a build time report out of an old message from early July.
>
> real    11m49.907s
> user    9m6.444s
> sys     0m43.527s
>
> The new build system is probably close enough to what I found in July that
> various background factors (eg. what else I was doing with the computer at
> that time, differences in the kernel scheduler then and now, whether that
> build in July was a debug build or not, etc.) probably eat up the small
> time difference one way or the other.
>
> So I'd say this PCH thing is a remarkably effective achievement, in
> comparison to the non-PCH build.

We have a lot more source files now than before the reorganisation, and this 
had a hard impact in our build time. The PCH compensates it, and doing a full 
debug build with PCH now takes the same time as before the reorganisation.

Regards,
Pedro

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Rosegarden-devel mailing list
[email protected] - use the link below to unsubscribe
https://lists.sourceforge.net/lists/listinfo/rosegarden-devel

Reply via email to