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
This commit is contained in:
Mothblocks
2022-12-12 22:05:33 -08:00
committed by GitHub
parent ac6b67a731
commit beb8111b2a
+17 -3
View File
@@ -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