[MIRROR] fixes _queue_verb() runtiming from /client/Click() thousands of times [MDB IGNORE] (#17034)

* fixes _queue_verb() runtiming from /client/Click() thousands of times (#70647)

* fixes _queue_verb() runtiming from /client/Click() and adds info

* Update code/controllers/subsystem/verb_manager.dm

Co-authored-by: Mothblocks <35135081+Mothblocks@ users.noreply.github.com>

Co-authored-by: Mothblocks <35135081+Mothblocks@ users.noreply.github.com>

* fixes _queue_verb() runtiming from /client/Click() thousands of times

Co-authored-by: Kylerace <kylerlumpkin1@gmail.com>
Co-authored-by: Mothblocks <35135081+Mothblocks@ users.noreply.github.com>
This commit is contained in:
SkyratBot
2022-10-20 13:29:05 +02:00
committed by GitHub
parent c162c3c2f9
commit 75c5d3d10d
4 changed files with 22 additions and 7 deletions

View File

@@ -82,7 +82,7 @@ VERB_MANAGER_SUBSYSTEM_DEF(input)
stack_trace("non /datum/callback/verb_callback instance inside SSinput's verb_queue!")
continue
average_click_delay = MC_AVG_FAST_UP_SLOW_DOWN(average_click_delay, (REALTIMEOFDAY - queued_click.creation_time) SECONDS)
average_click_delay = MC_AVG_FAST_UP_SLOW_DOWN(average_click_delay, TICKS2DS((DS2TICKS(world.time) - queued_click.creation_time)) SECONDS)
queued_click.InvokeAsync()
current_clicks++

View File

@@ -56,9 +56,24 @@ SUBSYSTEM_DEF(verb_manager)
* returns TRUE if the queuing was successful, FALSE otherwise.
*/
/proc/_queue_verb(datum/callback/verb_callback/incoming_callback, tick_check, datum/controller/subsystem/verb_manager/subsystem_to_use = SSverb_manager, ...)
if(QDELETED(incoming_callback) \
|| QDELETED(incoming_callback.object))
stack_trace("_queue_verb() returned false because it was given an invalid callback!")
if(QDELETED(incoming_callback))
var/destroyed_string
if(!incoming_callback)
destroyed_string = "callback is null."
else
destroyed_string = "callback was deleted [DS2TICKS(world.time - incoming_callback.gc_destroyed)] ticks ago. callback was created [DS2TICKS(world.time) - incoming_callback.creation_time] ticks ago."
stack_trace("_queue_verb() returned false because it was given a deleted callback! [destroyed_string]")
return FALSE
if(!istext(incoming_callback.object) && QDELETED(incoming_callback.object)) //just in case the object is GLOBAL_PROC
var/destroyed_string
if(!incoming_callback.object)
destroyed_string = "callback.object is null."
else
destroyed_string = "callback.object was deleted [DS2TICKS(world.time - incoming_callback.object.gc_destroyed)] ticks ago. callback was created [DS2TICKS(world.time) - incoming_callback.creation_time] ticks ago."
stack_trace("_queue_verb() returned false because it was given a callback acting on a qdeleted object! [destroyed_string]")
return FALSE
//we want unit tests to be able to directly call verbs that attempt to queue, and since unit tests should test internal behavior, we want the queue

View File

@@ -1,8 +1,8 @@
///like normal callbacks but they also record their creation time for measurement purposes
/datum/callback/verb_callback
///the REALTIMEOFDAY this callback datum was created in. used for testing latency
///the tick this callback datum was created in. used for testing latency
var/creation_time = 0
/datum/callback/verb_callback/New(thingtocall, proctocall, ...)
creation_time = REALTIMEOFDAY
creation_time = DS2TICKS(world.time)
. = ..()

View File

@@ -986,7 +986,7 @@ GLOBAL_LIST_INIT(blacklisted_builds, list(
//check if the server is overloaded and if it is then queue up the click for next tick
//yes having it call a wrapping proc on the subsystem is fucking stupid glad we agree unfortunately byond insists its reasonable
if(TRY_QUEUE_VERB(VERB_CALLBACK(object, /atom/proc/_Click, location, control, params), VERB_HIGH_PRIORITY_QUEUE_THRESHOLD, SSinput, control))
if(!QDELETED(object) && TRY_QUEUE_VERB(VERB_CALLBACK(object, /atom/proc/_Click, location, control, params), VERB_HIGH_PRIORITY_QUEUE_THRESHOLD, SSinput, control))
return
if (hotkeys)