From e623b688ad6fd169dfd806e191eabe973f1c26d0 Mon Sep 17 00:00:00 2001 From: oakeredolu_microsoft Date: Tue, 21 Jul 2026 10:37:26 -0700 Subject: [PATCH] Add precompiled header for kernel libraries Profiling with vcperf showed kernels/common/default.h is the most expensive included header, parsed in every kernel translation unit and transitively pulling in platform.h, intrinsics.h, windows.h and heavy STL headers. Precompile it once per ISA target via target_precompile_headers. Measured on a full clean rebuild (5 runs each, MSVC, Release): baseline: 1898.5s (sd 17.05) post PCH: 1673.5s (sd 17.45) -> 11.85% faster Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 78e85f7d-912f-4a77-9a1c-3c4f0316d659 --- kernels/CMakeLists.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/kernels/CMakeLists.txt b/kernels/CMakeLists.txt index b82780799c..317ef99e37 100644 --- a/kernels/CMakeLists.txt +++ b/kernels/CMakeLists.txt @@ -357,6 +357,17 @@ target_include_directories(embree PUBLIC $ $) +# Precompiled header: kernels/common/default.h is included by nearly every +# kernel translation unit and transitively pulls in platform.h, intrinsics.h, +# windows.h and heavy STL headers. Precompiling it once per (ISA) target +# amortizes that parse cost across all TUs of the target. +SET(EMBREE_PCH_HEADER "${CMAKE_CURRENT_SOURCE_DIR}/common/default.h") +FOREACH(EMBREE_PCH_TARGET embree embree_sse42 embree_avx embree_avx2 embree_avx512) + IF (TARGET ${EMBREE_PCH_TARGET}) + TARGET_PRECOMPILE_HEADERS(${EMBREE_PCH_TARGET} PRIVATE "${EMBREE_PCH_HEADER}") + ENDIF() +ENDFOREACH() + # libtbb is located in same install folder as libembree IF(WIN32)