1
votes

I am trying to use PCH in my solution to cut compilation time, but unbelievably, it takes more than twice as long with compared to without. Here's the stats:

Windows 7 x64 with 8GB running on i7

Sample project: 235 cpp files for a total of 4.5 MB source code (using MFC)

With PCH takes 13:55 minutes

Without PCH takes 6:15 minutes

I'm pretty sure I'm using them correctly, the project is set to Use Precompiled Headers at the project level, and the StdAfx.cpp is set to Create Precompiled Headers, through StdAfx.h

All standard #includes are placed in StdAfx.h, and all cpp files start with

#include "StdAfx.h"

I can't make sense of it. Anyone have an ideas what could be happening, or how I would even start to try to work it out?

1
Did you try to use GCC (ie g++) and to pre-compile with g++ that StdAfx.h header file?Basile Starynkevitch
Hi Basile, I don't use GCC, just the standard VS2008 tools. What's your thinking, how would your test help?Stephen
Perhaps for your particular case, GCC might do better on precompiled headers (I have no idea, just suggesting to try).Basile Starynkevitch

1 Answers

0
votes

So I worked around this eventually. My solution has a structure as follows:

C:\Data\Bus\VS\Projects\Solution.sln
C:\Data\Bus\VS\Projects\Proj1\
C:\Data\Bus\VS\Projects\Proj2\
C:\Data\Bus\VS\Projects\Proj3\
etc

Because these are used all the time, I have mapped a drive letter:

P = C:\Data\Bus\VS\Projects\

to this area for easier access to the solution using the following:

P:\Solution.sln
P:\Proj1\
P:\Proj2\
P:\Proj3\

I have found that VS2008 does not like opening the solution via the mapped drive letter (P), this is where the slower build with PCH occurs.

But if I open with a full path directly to the C drive, the PCH gives excellent speed advantage as expected.

Anyone have any idea about this? I can only think that the drive aliasing is giving VS the wrong impression that the PCH is always out of date, and so it rebuilds it with every file. Very mysterious.