From 3a044ef627780b041161851c52e1d86e1090a248 Mon Sep 17 00:00:00 2001 From: Mothblocks <35135081+Mothblocks@users.noreply.github.com> Date: Mon, 31 Oct 2022 23:03:55 -0700 Subject: [PATCH] Add defines for byond-tracy support (#70931) Adds `USE_BYOND_TRACY`, which automatically loads a given prof.dll/libprof.so using https://github.com/mafemergency/byond-tracy/. Not intended for use in production, and we do not ship a copy of byond-tracy. It is extremely easy to compile yourself, but if you're someone interesting enough to play around with this then let me know and I can just give you a build. I'm going to be using this for init profiling. --- .gitignore | 18 ++++++++++++++++++ code/_compile_options.dm | 4 +++- code/game/world.dm | 21 +++++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index ef738bcf38..b365634c32 100644 --- a/.gitignore +++ b/.gitignore @@ -196,5 +196,23 @@ Temporary Items /tools/LinuxOneShot/TGS_Config /tools/LinuxOneShot/TGS_Instances /tools/LinuxOneShot/TGS_Logs + + +# Built auxtools libraries and intermediate files +aux*.dll +libaux*.so +aux*.pdb + +# byond-tracy, we intentionally do not ship this and do not want to maintain it +prof.dll +libprof.so + +# JavaScript tools +**/node_modules + +# Screenshot tests +/artifacts + +#byond-tracy tools/UnstandardnessTestForDM/UnstandardnessTestForDM/obj/x86/Debug/UnstandardnessTestForDM.csproj.AssemblyReference.cache tools/UnstandardnessTestForDM/UnstandardnessTestForDM/obj/x86/Debug/.NETFramework,Version=v4.0,Profile=Client.AssemblyAttributes.cs diff --git a/code/_compile_options.dm b/code/_compile_options.dm index 1ed2075537..9e5227df96 100644 --- a/code/_compile_options.dm +++ b/code/_compile_options.dm @@ -43,7 +43,9 @@ // #define TRACK_MAX_SHARE //Allows max share tracking, for use in the atmos debugging ui #endif //ifdef TESTING -//#define UNIT_TESTS //If this is uncommented, we do a single run though of the game setup and tear down process with unit tests in between +// If this is uncommented, will attempt to load and initialize prof.dll/libprof.so. +// We do not ship byond-tracy. Build it yourself here: https://github.com/mafemergency/byond-tracy/ +// #define USE_BYOND_TRACY #ifndef PRELOAD_RSC //set to: #define PRELOAD_RSC 2 // 0 to allow using external resources or on-demand behaviour; diff --git a/code/game/world.dm b/code/game/world.dm index c6a5a2ef95..df92c7c8fa 100644 --- a/code/game/world.dm +++ b/code/game/world.dm @@ -14,6 +14,11 @@ GLOBAL_LIST(topic_status_cache) LIBCALL(dll, "auxtools_init")() enable_debugging() +#ifdef USE_BYOND_TRACY + #warn USE_BYOND_TRACY is enabled + init_byond_tracy() +#endif + world.Profile(PROFILE_START) log_world("World loaded at [TIME_STAMP("hh:mm:ss", FALSE)]!") @@ -369,3 +374,19 @@ GLOBAL_LIST(topic_status_cache) /world/proc/on_tickrate_change() SStimer?.reset_buckets() + +/world/proc/init_byond_tracy() + var/library + + switch (system_type) + if (MS_WINDOWS) + library = "prof.dll" + if (UNIX) + library = "libprof.so" + else + CRASH("Unsupported platform: [system_type]") + + var/init_result = call(library, "init")() + if (init_result != "0") + CRASH("Error initializing byond-tracy: [init_result]") +