[vtk-developers] Pending release... (precompiled headers)
Sebastien BARRE
sebastien at barre.nom.fr
Fri Dec 8 13:30:14 EST 2000
At 08/12/2000 18:16, John Biddiscombe wrote:
>>before, I already wrote a Perl script that build a
>>vtkPrecompiledHeaders.h file made of #include directives corresponding to
>>the most included headers.
>
>I'd suggest
>#include "vtkCommon.h"
>#include "vtkGraphics.h"
>#include "vtkImaging.h"
>
>because you don't want to include anything that might be platform or
>architecture dependent.
I was quite sure John would pop up :)
Sorry John, but :
> #include "vtkCommon.h"
> #include "vtkGraphics.h"
> #include "vtkImaging.h"
is definitely too much for MSVC++ as a precompiled header. Things are
*much* complicated, because the size of the precompiled header has an
impact on the size of *all* objs.
Here is a copy of what I send some months ago :
+++++++++++++++++++++
I tried :
#ifndef __vtkPrecompiledHeaders_h
#define __vtkPrecompiledHeaders_h
#include "vtkCommon.h"
#include "vtkGraphics.h"
#include "vtkImaging.h"
#endif /* __vtkPrecompiledHeaders_h */
but the compiler crashed and burned : out of heap space, and various other
memory problems. Setting /Zm to the max did not help, although I have 200
RAM and enough swap space. This is a bad news, the Microsoft Compiler seems
not to be able to handle big precompiled headers.
Thus, I removed each header one by one, until it worked with :
#include "vtkCommon.h"
which is better than nothing.
At this time, my compile time was 69 s., instead of the previous 85 s. with
no precompiled headers.
But not satisfying me :)
I wrote a Perl script that automatically generate
local/vtkPrecompiledHeaders.h with the 'n' most dependent header files
(parsed from the vtkdll/makefile). For example, the 10 most are :
#include "vtkWin32Header.h" // 589
#include "vtkSetGet.h" // 589
#include "vtkSystemIncludes.h" // 589
#include "vtkTimeStamp.h" // 589
#include "vtkIndent.h" // 589
#include "vtkObject.h" // 589
#include "vtkDataArray.h" // 543
#include "vtkIdList.h" // 527
#include "vtkObjectFactory.h" // 520
#include "vtkAttributeData.h" // 505
Then I tried with different 'n'.
Here are the results :
n / compile time / size of the dll / size of the precompiled header / total
size of the .obj
********************************************
10 / 71 s. / 512 Ko / 6157 Ko / 3243 Ko
20 / 57 s. / 512 Ko / 7189 Ko / 3243 Ko
40 / 36 s. / 512 Ko / 9794 Ko / 3725 Ko
50 / 34 s. / 520 Ko / 10257 Ko / 4157 Ko
60 / 37 s. / 565 Ko / 10928 Ko / 4852 Ko
75 / 59 s. / 819 Ko / 16732 Ko / 7984 Ko
100 / 83 s. / 1069 Ko / 21308 Ko / 11048 Ko
As you see, the more headers in the precompiled header file, the larger it
grows, and the larger the .obj and the .dll are. Thus, at a given point the
compiler spends too much time reading and writing big amount of data to the
disk, and it slows done the compilation process, disabling the precompiled
header benefit.
On my configuration, the best threshold is 50 headers in
vtkPrecompiledHeaders.h :
with VTK ANSI stdlib support: DLL build time : 34 s. (was 86 s.)
without VTK ANSI stdlib support: DLL build time : 25 s. (was 45 s.)
Needless to say that it would be nice to see this feature in the VTK source
tree :), but it requires adding a couple of line at the beginning of each
.cxx. This would have no influence until the user choose to compile VTK
with the /YX /D "USE_PCH" flags, and provides a "vtkPrecompiledHeaders.h"
somewhere in the include directories.
The Perl script is here :
ftp://sic.sp2mi.univ-poitiers.fr/pub/barre/vtk/build_pch.pl
and shall be run in the vtk source tree, after pcmaker has been run. Use
--from to specify where your build directory is (the script needs to parse
vtkdll/makefile). By default it dumps vtkPrecompiledHeaders.h to the local/
directory (add the according -I flag to the compilation options, or check
the "local" box in pcmaker). The --limit n parameters might be used to
write at most 'n' headers. Use --help anyway.
Hope this helps.
+++++++++++++++
my precompiled header is :
/*
50 of the 642 most dependent header(s).
Generated on Fri Dec 8 19:27:35 2000 with build_pch.pl 0.1, by S. Barre
*/
#ifndef __vtkPrecompiledHeaders_h
#define __vtkPrecompiledHeaders_h
#ifdef USE_PCH
#ifdef _MSC_VER
#include "vtkWin32Header.h"
#include "vtkIndent.h" // 100%
#include "vtkObject.h" // 100%
#include "vtkSystemIncludes.h" // 100%
#include "vtkTimeStamp.h" // 100%
#include "vtkSetGet.h" // 100%
#include "vtkDataArray.h" // 92%
#include "vtkIdList.h" // 89%
#include "vtkObjectFactory.h" // 88%
#include "vtkAttributeData.h" // 85%
#include "vtkPoints.h" // 83%
#include "vtkNormals.h" // 83%
#include "vtkVectors.h" // 82%
#include "vtkFieldData.h" // 80%
#include "vtkDataObject.h" // 80%
#include "vtkScalars.h" // 79%
#include "vtkUnsignedCharArray.h" // 79%
#include "vtkCellType.h" // 78%
#include "vtkTensor.h" // 77%
#include "vtkCell.h" // 77%
#include "vtkTCoords.h" // 77%
#include "vtkTensors.h" // 77%
#include "vtkGhostLevels.h" // 77%
#include "vtkDataSetAttributes.h" // 77%
#include "vtkCellData.h" // 76%
#include "vtkCellTypes.h" // 76%
#include "vtkPointData.h" // 76%
#include "vtkGenericCell.h" // 76%
#include "vtkDataSet.h" // 76%
#include "vtkProcessObject.h" // 72%
#include "vtkSource.h" // 64%
#include "vtkStructuredData.h" // 55%
#include "vtkImageData.h" // 52%
#include "vtkMutexLock.h" // 43%
#include "vtkLocator.h" // 36%
#include "vtkPointLocator.h" // 35%
#include "vtkIntArray.h" // 34%
#include "vtkPointSet.h" // 33%
#include "vtkCellArray.h" // 33%
#include "vtkStructuredPoints.h" // 31%
#include "vtkCellLinks.h" // 31%
#include "vtkMatrix4x4.h" // 29%
#include "vtkImageToStructuredPoints.h" // 28%
#include "vtkAbstractTransform.h" // 28%
#include "vtkPolyData.h" // 27%
#include "vtkCollection.h" // 23%
#include "vtkMath.h" // 22%
#include "vtkImplicitFunction.h" // 21%
#include "vtkPolyDataSource.h" // 20%
#include "vtkAssemblyPath.h" // 19%
#include "vtkAssemblyPaths.h" // 19%
#include "vtkProp.h" // 19%
#endif /* _MSC_VER */
#endif /* USE_PCH */
#endif /* __vtkPrecompiledHeaders_h */
More information about the vtk-developers
mailing list