Files
VMSolidusandGitHub 7aeab49ce5 Datum Destroy Optimizing (#22693)
Some concerns were brought up about the potential for performance
concerns with wrapping Destroy() in a try catch. So let me make a trade.
/datum is the parent of all objects in existence, and is spending a
large chunk of time on proc overhead for 2.6 million qdel'ed objects.

<img width="1196" height="811" alt="image"
src="https://github.com/user-attachments/assets/06ca1596-2d56-40ca-9ec6-9215ed02113c"
/>

I'll trade you a faster global destroy() for the better logging so I can
finish destroying the garbage collector lag.

The cost reduction is from 0.01209ms per datum to 0.007525ms per datum,
about a 28% time saving.
2026-06-19 16:08:15 +00:00

34 lines
986 B
Plaintext

GLOBAL_LIST_EMPTY(global_listen_count)
GLOBAL_LIST_EMPTY(event_sources_count)
GLOBAL_LIST_EMPTY(event_listen_count)
/singleton/observ/register(datum/event_source, datum/listener, proc_call)
. = ..()
if(.)
GLOB.event_sources_count[event_source] += 1
GLOB.event_listen_count[listener] += 1
/singleton/observ/unregister(datum/event_source, datum/listener, proc_call)
. = ..()
if(.)
GLOB.event_sources_count[event_source] -= 1
GLOB.event_listen_count[listener] -= 1
if(GLOB.event_sources_count[event_source] <= 0)
GLOB.event_sources_count -= event_source
if(GLOB.event_listen_count[listener] <= 0)
GLOB.event_listen_count -= listener
/singleton/observ/register_global(datum/listener, proc_call)
. = ..()
if(.)
GLOB.global_listen_count[listener] += 1
/singleton/observ/unregister_global(datum/listener, proc_call)
. = ..()
if(.)
GLOB.global_listen_count[listener] -= 1
if(GLOB.global_listen_count[listener] <= 0)
GLOB.global_listen_count -= listener