18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-02 05:02:45 +01:00

perf: the settings static without MSVC's thread-safe initialisation check

Global (GetGlobalSettings()) is a function-local static, read everywhere all the time: 1.3% of the main
thread was the function itself, MSVC's check of the thread-safe initialisation reading the thread's
epoch from the TLS on every call. utilities/Globals.cpp is now built with /Zc:threadSafeInit- (and
without the precompiled header, which is built with the default): the static is made once, by the main
thread at the start, before any other thread runs, and is only read afterwards, so the plain check of
the static is enough. It's the only function-local static of the file. MSVC only.

600 s in --test, seed 12345, one run each: Tomaszewo sim 115.7 s against 117.3 s the step before
(-1.4%); L107 14.9 s against 16.1 s (-7%). The physics logs (14 and 9) and the event logs are
byte-identical to staging's, unit tests 1207/1207 with exact golden traces.
This commit is contained in:
jerrrrycho
2026-11-30 11:32:38 +01:00
parent 3502ab6045
commit 3be7f5e828
+7
View File
@@ -483,6 +483,13 @@ 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")