From e28b80eca20fd97c18308992d8d10a032ea47189 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Thu, 13 Aug 2020 00:19:33 +0200 Subject: [PATCH] [MIRROR] The profiler now starts earlier into the init process. + Documents the initialization order and pipeline (#319) * The profiler now starts earlier into the init process. + Documents the initialization order and pipeline (#52662) * The profiler now starts earlier into the init process. Also documents the init pipeline and order in world/New()'s codedoc. * better early profiler * NEWMAN! * The profiler now starts earlier into the init process. + Documents the initialization order and pipeline Co-authored-by: Kyle Spier-Swenson --- code/__DEFINES/_profile.dm | 4 ++++ code/controllers/subsystem/profiler.dm | 2 +- code/game/world.dm | 21 +++++++++++++-------- tgstation.dme | 1 + 4 files changed, 19 insertions(+), 9 deletions(-) create mode 100644 code/__DEFINES/_profile.dm diff --git a/code/__DEFINES/_profile.dm b/code/__DEFINES/_profile.dm new file mode 100644 index 00000000000..41047b8b7ba --- /dev/null +++ b/code/__DEFINES/_profile.dm @@ -0,0 +1,4 @@ +#if DM_BUILD >= 1506 +// We don't actually care about storing the output here, this is just an easy way to ensure the profile runs first. +GLOBAL_REAL_VAR(world_init_profiler) = world.Profile(PROFILE_START) +#endif diff --git a/code/controllers/subsystem/profiler.dm b/code/controllers/subsystem/profiler.dm index 019945b3d16..b3e972bdef4 100644 --- a/code/controllers/subsystem/profiler.dm +++ b/code/controllers/subsystem/profiler.dm @@ -18,7 +18,7 @@ SUBSYSTEM_DEF(profiler) if(CONFIG_GET(flag/auto_profile)) StartProfiling() else - StopProfiling() //Stop the early start from world/New + StopProfiling() //Stop the early start profiler return ..() /datum/controller/subsystem/profiler/fire() diff --git a/code/game/world.dm b/code/game/world.dm index 28d009a2f84..4ed77a3ad44 100644 --- a/code/game/world.dm +++ b/code/game/world.dm @@ -5,18 +5,28 @@ GLOBAL_VAR(restart_counter) /** * World creation * - * Here is where a round itself is actually begun and setup, lots of important config changes happen here + * Here is where a round itself is actually begun and setup. * * db connection setup * * config loaded from files * * loads admins * * Sets up the dynamic menu system * * and most importantly, calls initialize on the master subsystem, starting the game loop that causes the rest of the game to begin processing and setting up * - * Note this happens after the Master subsystem is created (as that is a global datum), this means all the subsystems exist, - * but they have not been Initialized at this point, only their New proc has run * * Nothing happens until something moves. ~Albert Einstein * + * For clarity, this proc gets triggered later in the initialization pipeline, it is not the first thing to happen, as it might seem. + * + * Initialization Pipeline: + * Global vars are new()'ed, (including config, glob, and the master controller will also new and preinit all subsystems when it gets new()ed) + * Compiled in maps are loaded (mainly centcom). all areas/turfs/objs/mobs(ATOMs) in these maps will be new()ed + * world/New() (You are here) + * Once world/New() returns, client's can connect. + * 1 second sleep + * Master Controller initialization. + * Subsystem initialization. + * Non-compiled-in maps are maploaded, all atoms are new()ed + * All atoms in both compiled and uncompiled maps are initialized() */ /world/New() var/extools = world.GetConfig("env", "EXTOOLS_DLL") || (world.system_type == MS_WINDOWS ? "./byond-extools.dll" : "./libbyond-extools.so") @@ -27,11 +37,6 @@ GLOBAL_VAR(restart_counter) enable_reference_tracking() #endif - //Early profile for auto-profiler - will be stopped on profiler init if necessary. -#if DM_BUILD >= 1506 - world.Profile(PROFILE_START) -#endif - log_world("World loaded at [time_stamp()]!") make_datum_references_lists() //initialises global lists for referencing frequently used datums (so that we only ever do it once) diff --git a/tgstation.dme b/tgstation.dme index f271bd78046..c48135c245a 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -18,6 +18,7 @@ #include "code\world.dm" #include "code\__DEFINES\_globals.dm" #include "code\__DEFINES\_helpers.dm" +#include "code\__DEFINES\_profile.dm" #include "code\__DEFINES\_protect.dm" #include "code\__DEFINES\_tick.dm" #include "code\__DEFINES\access.dm"