Skip to content

8365053: Refresh hotspot precompiled.hpp with headers based on current frequency #26681

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
348 changes: 326 additions & 22 deletions src/hotspot/share/precompiled/precompiled.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,52 +26,356 @@
// --disable-precompiled-headers to configure.

// These header files are included in at least 130 C++ files, as of
// measurements made in November 2018. This list excludes files named
// *.inline.hpp, since including them decreased build performance.
// measurements made in August 2025.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there's anything particularly special about the number 130.

Another thing to consider when a header file has a high include count is
whether it's being overincluded. We've had lots of those, and some folks
occasionally try to poke at that problem. Some of the removals here look like
they might be a result of such efforts.

Still another thing to consider is the cost of inclusion. Some files may just
be a lot more expensive to process and benefit more for being precompiled.
File size can be an indicator, but there are others. Unfortunately, I don't
know of a good way to measure this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to modify the comment here, too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I'll wait just a bit so the discussion on how to approach the problem stabilizes :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This number is based on my original experimentation. If I tried to lower the bar by lowering the number, the PCH list grew too much and it made for a worse performance. And contrary, if I raised the number, fewer files where included which made the PCH quicker to process but less helpful. That number was the optimum I found. It seems from https://bugs.openjdk.org/browse/JDK-8365053 that this is still around the optimum. However, rather than just mentioning the number in the comment, the rationale could be specified, like the optimum number of includes.


#include "classfile/classLoaderData.hpp"
#include "classfile/javaClasses.hpp"
#include "classfile/systemDictionary.hpp"
#include "asm/assembler.hpp"
#include "asm/codeBuffer.hpp"
#include "asm/macroAssembler.hpp"
#include "asm/register.hpp"
#include "c1/c1_globals.hpp"
#include "cds/aotLinkedClassBulkLoader.hpp"
#include "cds/cds_globals.hpp"
#include "classfile/classLoaderData.inline.hpp"
#include "classfile/compactHashtable.hpp"
#include "classfile/javaClasses.inline.hpp"
#include "classfile/vmClassID.hpp"
#include "classfile/vmClassMacros.hpp"
#include "classfile/vmClasses.hpp"
#include "classfile/vmIntrinsics.hpp"
#include "code/codeBlob.inline.hpp"
#include "code/codeCache.inline.hpp"
#include "code/compressedStream.hpp"
#include "code/debugInfo.hpp"
#include "code/location.hpp"
#include "code/nativeInst.hpp"
#include "code/nmethod.inline.hpp"
#include "code/oopRecorder.hpp"
#include "code/pcDesc.hpp"
#include "code/relocInfo.hpp"
#include "code/stubs.hpp"
#include "code/vmreg.inline.hpp"
#include "code/vmregTypes.hpp"
#include "compiler/compilerDefinitions.hpp"
#include "compiler/compiler_globals.hpp"
#include "compiler/compiler_globals_pd.hpp"
#include "compiler/oopMap.inline.hpp"
#include "gc/serial/serial_globals.hpp"
#include "gc/shared/barrierSet.inline.hpp"
#include "gc/shared/barrierSetConfig.inline.hpp"
#include "gc/shared/barrierSetStackChunk.hpp"
#include "gc/shared/cardTable.hpp"
#include "gc/shared/cardTableBarrierSet.inline.hpp"
#include "gc/shared/collectedHeap.hpp"
#include "gc/shared/gcBehaviours.hpp"
#include "gc/shared/gcCause.hpp"
#include "gc/shared/gcId.hpp"
#include "gc/shared/gcThreadLocalData.hpp"
#include "gc/shared/gcUtil.hpp"
#include "gc/shared/gcWhen.hpp"
#include "gc/shared/gc_globals.hpp"
#include "gc/shared/modRefBarrierSet.inline.hpp"
#include "gc/shared/oopStorage.inline.hpp"
#include "gc/shared/referenceDiscoverer.hpp"
#include "gc/shared/referencePolicy.hpp"
#include "gc/shared/referenceProcessor.hpp"
#include "gc/shared/referenceProcessorStats.hpp"
#include "gc/shared/softRefPolicy.hpp"
#include "gc/shared/threadLocalAllocBuffer.hpp"
#include "gc/shared/verifyOption.hpp"
#include "gc/shared/workerThread.hpp"
#include "interpreter/abstractInterpreter.hpp"
#include "interpreter/bootstrapInfo.hpp"
#include "interpreter/bytecodes.hpp"
#include "interpreter/interp_masm.hpp"
#include "interpreter/interpreter.hpp"
#include "interpreter/invocationCounter.hpp"
#include "interpreter/linkResolver.hpp"
#include "interpreter/templateInterpreter.hpp"
#include "interpreter/templateTable.hpp"
#include "interpreter/zero/zeroInterpreter.hpp"
#include "jfr/jfr.hpp"
#include "jfr/periodic/sampling/jfrCPUTimeThreadSampler.hpp"
#include "jfr/periodic/sampling/jfrSampleRequest.hpp"
#include "jfr/recorder/checkpoint/types/traceid/jfrTraceId.hpp"
#include "jfr/recorder/checkpoint/types/traceid/jfrTraceIdMacros.hpp"
#include "jfr/recorder/storage/jfrBuffer.hpp"
#include "jfr/support/jfrIntrinsics.hpp"
#include "jfr/support/jfrKlassExtension.hpp"
#include "jfr/support/jfrThreadExtension.hpp"
#include "jfr/support/jfrThreadId.hpp"
#include "jfr/support/jfrThreadLocal.hpp"
#include "jfr/support/jfrTraceIdExtension.hpp"
#include "jfr/utilities/jfrAllocation.hpp"
#include "jfr/utilities/jfrBlob.hpp"
#include "jfr/utilities/jfrRefCountPointer.hpp"
#include "jfr/utilities/jfrTime.hpp"
#include "jfr/utilities/jfrTypes.hpp"
#include "jvmci/jvmci_globals.hpp"
#include "logging/log.hpp"
#include "logging/logDecorations.hpp"
#include "logging/logDecorators.hpp"
#include "logging/logHandle.hpp"
#include "logging/logLevel.hpp"
#include "logging/logMessage.hpp"
#include "logging/logMessageBuffer.hpp"
#include "logging/logOutputList.hpp"
#include "logging/logPrefix.hpp"
#include "logging/logSelection.hpp"
#include "logging/logStream.hpp"
#include "logging/logTag.hpp"
#include "logging/logTagSet.hpp"
#include "memory/allStatic.hpp"
#include "memory/allocation.hpp"
#include "memory/iterator.hpp"
#include "memory/arena.hpp"
#include "memory/classLoaderMetaspace.hpp"
#include "memory/heap.hpp"
#include "memory/iterator.inline.hpp"
#include "memory/memRegion.hpp"
#include "memory/metadataFactory.hpp"
#include "memory/metaspace.hpp"
#include "memory/metaspaceClosure.hpp"
#include "memory/padded.hpp"
#include "memory/referenceType.hpp"
#include "memory/reservedSpace.hpp"
#include "memory/resourceArea.hpp"
#include "memory/universe.hpp"
#include "nmt/memTracker.hpp"
#include "oops/instanceKlass.hpp"
#include "oops/klass.hpp"
#include "memory/virtualspace.hpp"
#include "metaprogramming/enableIf.hpp"
#include "metaprogramming/primitiveConversions.hpp"
#include "nmt/memTag.hpp"
#include "oops/access.inline.hpp"
#include "oops/accessBackend.inline.hpp"
#include "oops/accessDecorators.hpp"
#include "oops/annotations.hpp"
#include "oops/array.inline.hpp"
#include "oops/arrayKlass.hpp"
#include "oops/arrayOop.hpp"
#include "oops/compressedKlass.inline.hpp"
#include "oops/compressedOops.inline.hpp"
#include "oops/constMethod.hpp"
#include "oops/constMethodFlags.hpp"
#include "oops/constantPool.hpp"
#include "oops/cpCache.hpp"
#include "oops/fieldInfo.inline.hpp"
#include "oops/instanceClassLoaderKlass.inline.hpp"
#include "oops/instanceKlass.inline.hpp"
#include "oops/instanceKlassFlags.hpp"
#include "oops/instanceMirrorKlass.inline.hpp"
#include "oops/instanceOop.hpp"
#include "oops/instanceRefKlass.inline.hpp"
#include "oops/instanceStackChunkKlass.inline.hpp"
#include "oops/klass.inline.hpp"
#include "oops/klassFlags.hpp"
#include "oops/klassVtable.hpp"
#include "oops/markWord.inline.hpp"
#include "oops/metadata.hpp"
#include "oops/method.hpp"
#include "oops/objArrayKlass.hpp"
#include "oops/objArrayOop.hpp"
#include "oops/oop.hpp"
#include "oops/methodData.hpp"
#include "oops/methodFlags.hpp"
#include "oops/objArrayKlass.inline.hpp"
#include "oops/objArrayOop.inline.hpp"
#include "oops/objLayout.inline.hpp"
#include "oops/oop.inline.hpp"
#include "oops/oopHandle.inline.hpp"
#include "oops/oopsHierarchy.hpp"
#include "oops/stackChunkOop.inline.hpp"
#include "oops/symbol.hpp"
#include "oops/typeArrayKlass.inline.hpp"
#include "oops/typeArrayOop.inline.hpp"
#include "oops/weakHandle.inline.hpp"
#include "opto/adlcVMDeps.hpp"
#include "opto/c2_globals.hpp"
#include "prims/vectorSupport.hpp"
#include "runtime/abstract_vm_version.hpp"
#include "runtime/atomic.hpp"
#include "runtime/basicLock.hpp"
#include "runtime/continuation.hpp"
#include "runtime/continuationEntry.hpp"
#include "runtime/continuationJavaClasses.inline.hpp"
#include "runtime/deoptimization.hpp"
#include "runtime/flags/flagSetting.hpp"
#include "runtime/frame.inline.hpp"
#include "runtime/globals.hpp"
#include "runtime/handles.hpp"
#include "runtime/globals_shared.hpp"
#include "runtime/handles.inline.hpp"
#include "runtime/handshake.hpp"
#include "runtime/icache.hpp"
#include "runtime/javaFrameAnchor.hpp"
#include "runtime/javaThread.hpp"
#include "runtime/lockStack.hpp"
#include "runtime/monitorChunk.hpp"
#include "runtime/mutex.hpp"
#include "runtime/mutexLocker.hpp"
#include "runtime/nonJavaThread.hpp"
#include "runtime/objectMonitor.hpp"
#include "runtime/orderAccess.hpp"
#include "runtime/os.hpp"
#include "runtime/osInfo.hpp"
#include "runtime/park.hpp"
#include "runtime/perfDataTypes.hpp"
#include "runtime/registerMap.hpp"
#include "runtime/safepoint.hpp"
#include "runtime/safepointMechanism.hpp"
#include "runtime/semaphore.hpp"
#include "runtime/sharedRuntime.hpp"
#include "runtime/smallRegisterMap.inline.hpp"
#include "runtime/stackChunkFrameStream.hpp"
#include "runtime/stackOverflow.hpp"
#include "runtime/stackWatermarkKind.hpp"
#include "runtime/stackWatermarkSet.hpp"
#include "runtime/stubCodeGenerator.hpp"
#include "runtime/stubDeclarations.hpp"
#include "runtime/stubInfo.hpp"
#include "runtime/stubRoutines.hpp"
#include "runtime/suspendResumeManager.hpp"
#include "runtime/task.hpp"
#include "runtime/thread.hpp"
#include "runtime/threadHeapSampler.hpp"
#include "runtime/threadIdentifier.hpp"
#include "runtime/threadLocalStorage.hpp"
#include "runtime/threadStatisticalInfo.hpp"
#include "runtime/threadWXSetters.inline.hpp"
#include "runtime/timer.hpp"
#include "runtime/unhandledOops.hpp"
#include "runtime/vmOperation.hpp"
#include "runtime/vmThread.hpp"
#include "runtime/vm_version.hpp"
#include "services/memoryUsage.hpp"
#include "utilities/accessFlags.hpp"
#include "utilities/align.hpp"
#include "utilities/bitMap.hpp"
#include "utilities/autoRestore.hpp"
#include "utilities/bitMap.inline.hpp"
#include "utilities/breakpoint.hpp"
#include "utilities/bytes.hpp"
#include "utilities/byteswap.hpp"
#include "utilities/checkedCast.hpp"
#include "utilities/compilerWarnings.hpp"
#include "utilities/constantTag.hpp"
#include "utilities/copy.hpp"
#include "utilities/count_leading_zeros.hpp"
#include "utilities/count_trailing_zeros.hpp"
#include "utilities/debug.hpp"
#include "utilities/devirtualizer.inline.hpp"
#include "utilities/enumIterator.hpp"
#include "utilities/exceptions.hpp"
#include "utilities/fakeRttiSupport.hpp"
#include "utilities/filterQueue.hpp"
#include "utilities/forbiddenFunctions.hpp"
#include "utilities/formatBuffer.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/growableArray.hpp"
#include "utilities/linkedlist.hpp"
#include "utilities/macros.hpp"
#include "utilities/numberSeq.hpp"
#include "utilities/ostream.hpp"
#include "utilities/population_count.hpp"
#include "utilities/powerOfTwo.hpp"
#include "utilities/resizeableResourceHash.hpp"
#include "utilities/resourceHash.hpp"
#include "utilities/rotate_bits.hpp"
#include "utilities/singleWriterSynchronizer.hpp"
#include "utilities/sizes.hpp"
#include "utilities/tableStatistics.hpp"
#include "utilities/ticks.hpp"
#include "utilities/unsigned5.hpp"
#include "utilities/utf8.hpp"
#include "utilities/vmEnums.hpp"
#include "utilities/waitBarrier.hpp"
#include "utilities/waitBarrier_generic.hpp"

#ifdef TARGET_COMPILER_visCPP

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of the reported testing was on Linux. These were included specifically because measurements
said their inclusion here was beneficial. And my recollection from previous discussions is that
Visual Studio may be the compiler where precompiled headers are most beneficial.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, Visual Studio is the place where PCH is most needed. I see Erik says he tested on Windows with no difference. While he concluded that this means no regression, I see it as a missed opportunity. Giving the Windows platform a bit of extra love can probably increase compilation speed where it is needed the most.

// For Visual Studio, including the *.inline.hpp files actually
// increased performance.
#include "memory/allocation.inline.hpp"
#include "oops/access.inline.hpp"
#include "oops/oop.inline.hpp"
#include "runtime/handles.inline.hpp"
#endif // TARGET_COMPILER_visCPP
#ifdef COMPILER2
#include "asm/assembler.hpp"
#include "asm/codeBuffer.hpp"
#include "cds/cds_globals.hpp"
#include "classfile/vmIntrinsics.hpp"
#include "code/codeBlob.hpp"
#include "code/debugInfo.hpp"
#include "code/location.hpp"
#include "code/nmethod.hpp"
#include "code/oopRecorder.hpp"
#include "code/pcDesc.hpp"
#include "code/relocInfo.hpp"
#include "compiler/compiler_globals.hpp"
#include "jfr/support/jfrIntrinsics.hpp"
#include "logging/logDecorations.hpp"
#include "logging/logHandle.hpp"
#include "logging/logMessage.hpp"
#include "logging/logMessageBuffer.hpp"
#include "logging/logStream.hpp"
#include "opto/adlcVMDeps.hpp"
#include "opto/c2_globals.hpp"
#include "runtime/nonJavaThread.hpp"
#include "runtime/stubDeclarations.hpp"
#include "runtime/stubInfo.hpp"
#include "utilities/resizeableResourceHash.hpp"
#endif

#if INCLUDE_JFR
#include "asm/assembler.hpp"
#include "asm/codeBuffer.hpp"
#include "cds/cds_globals.hpp"
#include "classfile/vmIntrinsics.hpp"
#include "code/codeBlob.hpp"
#include "code/nmethod.hpp"
#include "code/oopRecorder.hpp"
#include "code/pcDesc.hpp"
#include "code/relocInfo.hpp"
#include "code/vmreg.inline.hpp"
#include "compiler/compiler_globals.hpp"
#include "gc/epsilon/epsilon_globals.hpp"
#include "gc/shared/gc_globals.hpp"
#include "jfr/jfr.hpp"
#include "jfr/periodic/sampling/jfrCPUTimeThreadSampler.hpp"
#include "jfr/periodic/sampling/jfrSampleRequest.hpp"
#include "jfr/recorder/checkpoint/types/traceid/jfrTraceId.hpp"
#include "jfr/recorder/checkpoint/types/traceid/jfrTraceIdMacros.hpp"
#include "jfr/recorder/storage/jfrBuffer.hpp"
#include "jfr/support/jfrIntrinsics.hpp"
#include "jfr/support/jfrKlassExtension.hpp"
#include "jfr/support/jfrThreadExtension.hpp"
#include "jfr/support/jfrThreadId.hpp"
#include "jfr/support/jfrThreadLocal.hpp"
#include "jfr/support/jfrTraceIdExtension.hpp"
#include "jfr/utilities/jfrAllocation.hpp"
#include "jfr/utilities/jfrBlob.hpp"
#include "jfr/utilities/jfrRefCountPointer.hpp"
#include "jfr/utilities/jfrTime.hpp"
#include "jfr/utilities/jfrTypes.hpp"
#include "logging/logDecorations.hpp"
#include "logging/logHandle.hpp"
#include "logging/logMessage.hpp"
#include "logging/logMessageBuffer.hpp"
#include "logging/logStream.hpp"
#include "runtime/nonJavaThread.hpp"
#include "runtime/stubDeclarations.hpp"
#include "runtime/stubInfo.hpp"
#include "utilities/resizeableResourceHash.hpp"
#endif

#if INCLUDE_G1GC
#include "asm/codeBuffer.hpp"
#include "code/oopRecorder.hpp"
#include "code/relocInfo.hpp"
#include "compiler/compiler_globals.hpp"
#include "logging/logDecorations.hpp"
#include "logging/logMessageBuffer.hpp"
#include "utilities/resizeableResourceHash.hpp"
#endif

#if INCLUDE_SHENANDOAHGC
#include "asm/codeBuffer.hpp"
#include "code/codeBlob.hpp"
#include "code/oopRecorder.hpp"
#include "code/relocInfo.hpp"
#include "compiler/compiler_globals.hpp"
#include "logging/logDecorations.hpp"
#include "logging/logHandle.hpp"
#include "logging/logMessage.hpp"
#include "logging/logMessageBuffer.hpp"
#include "logging/logStream.hpp"
#include "utilities/resizeableResourceHash.hpp"
#endif

#if INCLUDE_ZGC
#include "compiler/compiler_globals.hpp"
#endif
Loading