RFR: JDK-8213339 Update precompiled.hpp with headers based on current frequency

David Holmes david.holmes at oracle.com
Sun Nov 4 22:07:05 UTC 2018

On 4/11/2018 5:27 PM, Magnus Ihse Bursie wrote:
>> 3 nov. 2018 kl. 23:24 skrev David Holmes <david.holmes at oracle.com>:
>>> On 3/11/2018 10:09 PM, David Holmes wrote:
>>> Looks okay - thanks for doing all the experiments! (Though I'm still curious what happens if you recompile individual header files :) ).
>> s/recompile/precompile/  :)
> What do you mean? To have more than one set of PCH? As far as I know, all compilers we use only support a single PCH per source file to compile. So while you could have a PCH tailored per source file, that would only make sense in a scenario were you recompile all source files (but no header files) often.

The GCC description for PCH describes it as a per-file header file 
optimization. You can precompile each .hpp file and if it is located in 
the same directory as the .hpp (or is on an include directory ahead of 
the .hpp) then the PCH file will be used instead. So rather than 
precompiling precompiled.hpp and having source files include it, you 
would precompile each individual (chosen) header file and have that in 
the special PCH include directory, and they would then be included where 
a source file asked for the corresponding .hpp file.

That would also remove the problem of things not compiling with PCH 
disabled as a single set of includes would be used for both PCH and 
non-PCH building.

I don't know if the other compilers support PCH in a similar manner to gcc.


> /Magnus
>> David
>>>   25 // Precompiled headers are turned off for Sun Studio,
>>> May as well change to Solaris Studio if you're going to fix the typo :)
>>> Thanks.
>>> David
>>>> On 3/11/2018 7:06 PM, Magnus Ihse Bursie wrote:
>>>> The reasons for the current set of files included in precompiled.hpp is somewhat lost in the mists of history. However, it is clear that it is not optimal.
>>>> This patch replaces the current set with a new set, based on how often a header file is included in a C++ file. This selection contains all header files that are included by at least 130 C++ files. Testing has shown that this is around the optimal value -- include many more, and too many "innocent" files get hurt by unneeded work, leave out many more, and we miss out on optimization possibilities.
>>>> The same set turned out to work well for both clang and gcc. However, files named "*.inline.hpp" did hurt rather than help performance, so those have been left out. For visual studio, the same set was also optimal, as long as the inline files were included. Presumably, visual studio is better than gcc/clang on handling precompiled headers containing inlined code.
>>>> Here are some rough comparisons from our internal CI system, for building the target "hotspot" from scratch.
>>>> macosx-x64:
>>>> old: 00:05:00
>>>> new: 00:03:47
>>>> linux-x64:
>>>> old: 00:05:43
>>>> new: 00:04:51
>>>> windows-x64:
>>>> old: 00:05:18
>>>> new: 00:04:33
>>>> linux-aarch64:
>>>> old: 00:07:57
>>>> new: 00:03:48
>>>> Bug: https://bugs.openjdk.java.net/browse/JDK-8213339
>>>> WebRev: http://cr.openjdk.java.net/~ihse/JDK-8213339-update-precompiled-headers/webrev.01
>>>> /Magnus

More information about the build-dev mailing list