feat(profiler): frame timing and scope trees of a server's main loop

Profiler.h: frames, named scopes and phases, recorded on the main thread only (other threads' scopes do nothing). Per second: frames, total and longest frame time, a mergeable frame time histogram (TrafficStats::Histogram) and time per phase. Per report: the packet types that took longest, the worst frames and the frames over a threshold with their heaviest scopes. Profiling sessions merge every frame's scope tree for a while into one (folded stacks for flame graphs). Optional Tracy client (DLU_TRACY, off by default) gets the same frames and scopes. Task 96.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Aaron Kimbrell
2026-09-29 22:06:29 -05:00
parent 6758b32605
commit 06af6c3aaa
6 changed files with 1157 additions and 0 deletions

View File

@@ -6,6 +6,7 @@ set(DCOMMON_SOURCES
"dConfig.cpp"
"Diagnostics.cpp"
"TrafficStats.cpp"
"Profiler.cpp"
"Locale.cpp"
"Logger.cpp"
"Game.cpp"
@@ -115,3 +116,9 @@ target_link_libraries(dCommon
PUBLIC glm::glm dBuildInfo
PRIVATE ZLIB::ZLIB bcrypt tinyxml2
INTERFACE dDatabase)
# Profiler.h's frames and scopes also go to Tracy (thirdparty/CMakeLists.txt, DLU_TRACY)
if(DLU_TRACY)
target_link_libraries(dCommon PUBLIC Tracy::TracyClient)
target_compile_definitions(dCommon PRIVATE DLU_TRACY)
endif()