From f3d9c4433f6b999542e2e5be9e3647b86bcf9c4b Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Tue, 28 May 2024 05:12:52 +0200 Subject: [PATCH] [MIRROR] Saves profiler snapshots every 5 minutes (#27875) * Saves profiler snapshots every 5 minutes (#83467) ## About The Pull Request As the title says. Each saved snapshot will be named - `profiler-[TIME IN SECONDS].json` - `sendmaps-[TIME IN SECONDS].json` For example, `profiler-0.json`, `profiler-300.json`, `profiler-600.json` would correspond to a profile at the start of the round, a profile 300 seconds into a round and a profile 600 seconds into a round. The timings depend on world.time, so it's probably not a good idea to rely on these timings to stay consistent. ## Why It's Good For The Game Allows us to track performance of procs over time. Could allow us to spot any sort of anomalies or performance sinks. CC: @ MrStonedOne @ bobbah @ LemonInTheDark --------- Co-authored-by: Watermelon914 <3052169-Watermelon914@ users.noreply.gitlab.com> * Saves profiler snapshots every 5 minutes --------- Co-authored-by: Watermelon914 <37270891+Watermelon914@users.noreply.github.com> Co-authored-by: Watermelon914 <3052169-Watermelon914@ users.noreply.gitlab.com> --- code/controllers/subsystem/profiler.dm | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/code/controllers/subsystem/profiler.dm b/code/controllers/subsystem/profiler.dm index dc06c2bc6ae..46d5b0fd57b 100644 --- a/code/controllers/subsystem/profiler.dm +++ b/code/controllers/subsystem/profiler.dm @@ -1,11 +1,8 @@ -#define PROFILER_FILENAME "profiler.json" -#define SENDMAPS_FILENAME "sendmaps.json" - SUBSYSTEM_DEF(profiler) name = "Profiler" init_order = INIT_ORDER_PROFILER runlevels = RUNLEVELS_DEFAULT | RUNLEVEL_LOBBY - wait = 3000 + wait = 300 SECONDS var/fetch_cost = 0 var/write_cost = 0 @@ -56,12 +53,12 @@ SUBSYSTEM_DEF(profiler) if(!length(current_profile_data)) //Would be nice to have explicit proc to check this stack_trace("Warning, profiling stopped manually before dump.") - var/prof_file = file("[GLOB.log_directory]/[PROFILER_FILENAME]") + var/prof_file = file("[GLOB.log_directory]/profiler/profiler-[round(world.time * 0.1, 10)].json") if(fexists(prof_file)) fdel(prof_file) if(!length(current_sendmaps_data)) //Would be nice to have explicit proc to check this stack_trace("Warning, sendmaps profiling stopped manually before dump.") - var/sendmaps_file = file("[GLOB.log_directory]/[SENDMAPS_FILENAME]") + var/sendmaps_file = file("[GLOB.log_directory]/profiler/sendmaps-[round(world.time * 0.1, 10)].json") if(fexists(sendmaps_file)) fdel(sendmaps_file) @@ -70,5 +67,3 @@ SUBSYSTEM_DEF(profiler) WRITE_FILE(sendmaps_file, current_sendmaps_data) write_cost = MC_AVERAGE(write_cost, TICK_DELTA_TO_MS(TICK_USAGE_REAL - timer)) -#undef PROFILER_FILENAME -#undef SENDMAPS_FILENAME