From beb8111b2aef45c8ec991c72324fefcd56cce0e6 Mon Sep 17 00:00:00 2001 From: Mothblocks <35135081+Mothblocks@users.noreply.github.com> Date: Mon, 12 Dec 2022 22:05:33 -0800 Subject: [PATCH] Defer admin profiling access until the admin logs in - Saves 69ms (#71680) Just some unnecessary costs. We create `/datum/admins` for every admin in the txt and database. It might sound silly, but it ends up being useful for things like the permissions panel. Anyway, admins are usually given profiling access, but the SetConfig call is extremely slow. So slow that we have it config'd off on Campbell, AFAIK. This defers that cost to when an admin joins. This could in theory cause issues with latejoining admins getting debug perms, but it appears to work in testing. noting for far future --- code/modules/admin/holder2.dm | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/code/modules/admin/holder2.dm b/code/modules/admin/holder2.dm index 9091ce8e211..476f4ac3117 100644 --- a/code/modules/admin/holder2.dm +++ b/code/modules/admin/holder2.dm @@ -45,6 +45,8 @@ GLOBAL_PROTECT(href_token) /// A lazylist of tagged datums, for quick reference with the View Tags verb var/list/tagged_datums + var/given_profiling = FALSE + /datum/admins/New(list/datum/admin_rank/ranks, ckey, force_active = FALSE, protected) if(IsAdminAdvancedProcCall()) var/msg = " has tried to elevate permissions!" @@ -65,9 +67,6 @@ GLOBAL_PROTECT(href_token) src.ranks = ranks admin_signature = "Nanotrasen Officer #[rand(0,9)][rand(0,9)][rand(0,9)]" href_token = GenerateToken() - if(!CONFIG_GET(flag/forbid_admin_profiling)) - if(rank_flags() & R_DEBUG) //grant profile access, assuming admin profile access is enabled - world.SetConfig("APP/admin", ckey, "role=admin") //only admins with +ADMIN start admined if(protected) GLOB.protected_admins[target] = src @@ -157,6 +156,8 @@ GLOBAL_PROTECT(href_token) owner.init_verbs() //re-initialize the verb list GLOB.admins |= client + try_give_profiling() + /datum/admins/proc/disassociate() if(IsAdminAdvancedProcCall()) var/msg = " has tried to elevate permissions!" @@ -388,6 +389,19 @@ GLOBAL_PROTECT(href_token) return combined_flags +/datum/admins/proc/try_give_profiling() + if (CONFIG_GET(flag/forbid_admin_profiling)) + return + + if (given_profiling) + return + + if (!(rank_flags() & R_DEBUG)) + return + + given_profiling = TRUE + world.SetConfig("APP/admin", owner.ckey, "role=admin") + /datum/admins/vv_edit_var(var_name, var_value) return FALSE //nice try trialmin