From 5b77fed81f7f464579f1661b47c99fdb0ec3dc2e Mon Sep 17 00:00:00 2001 From: jerrrrycho Date: Tue, 1 Dec 2026 16:57:52 +0100 Subject: [PATCH] perf: the settings static back with MSVC's thread-safe initialisation check Takes back 3be7f5e82. /Zc:threadSafeInit- on utilities/Globals.cpp drops the guard from every function-local static compiled in that file, those of the inline and template functions of stdafx.h and the project's headers included, and the linker may keep that file's copy of such a function for the whole program. The 1.4% it gave in one run is inside the run-to-run noise, so a static put in a header later and used from two threads isn't worth the risk. Globals.cpp is built with the precompiled header again. --- CMakeLists.txt | 7 ------- 1 file changed, 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 166bc5107..561bbc127 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -483,13 +483,6 @@ set(SOURCES set(DEFINITIONS) set(SOURCES ${SOURCES} "imgui/imgui_impl_opengl3.cpp") set_source_files_properties("imgui/imgui_impl_opengl3.cpp" PROPERTIES SKIP_PRECOMPILE_HEADERS TRUE) -# the settings (Global, GetGlobalSettings()) are a function-local static read everywhere all the time: MSVC's check of its -# thread-safe initialisation reads the thread's epoch from the TLS on every call. it's made once, by the main thread, before -# any other thread starts, so the plain check of the static does; the only function-local static of the file. without the -# precompiled header, which is built with the default -if(MSVC) - set_source_files_properties("utilities/Globals.cpp" PROPERTIES COMPILE_OPTIONS "/Zc:threadSafeInit-" SKIP_PRECOMPILE_HEADERS TRUE) -endif() if (WITH_CRASHPAD) set(DEFINITIONS ${DEFINITIONS} "WITH_CRASHPAD")