mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-09 16:05:07 +00:00
* Optimizes timer insertion by 80% (W QDEL_IN micro) (#76214) <!-- Write **BELOW** The Headers and **ABOVE** The comments else it may not be viewable. --> <!-- You can view Contributing.MD for a detailed description of the pull request process. --> ## About The Pull Request [Reduces timer insertion cost by 80%](c9e5b285ed) Timer name generation involved a LOT of string shit, some in ways where the string only existed for a moment. This costs a good bit of time, and can be reduced with only minimal impacts on the end product, so let's do that. Includes a compile flag to flip it back if we ever have trouble in future. This is about 0.1s off init, since we do a lot of timer stuff then too [Removes STOPPABLE flag from QDEL_IN, moves it to a bespoke macro](e7a5d7f2a7) Its a waste most of the time, tho I would LOVE to analyze at compile time to work out if we care ## Why It's Good For The Game I like it when we don't spend all of our cpu time just setting the name var on timers. that's good and not bad. This saves time fucking everywhere. 15% off explosions, 0.1 seconds off init, bunch of time off foam. it's just good. Cherry picked out of #76104 since that was too cluttered (sannnnnn) <!-- Argue for the merits of your changes and how they benefit the game, especially if they are controversial and/or far reaching. If you can't actually explain WHY what you are doing will improve the game, then it probably isn't good for the game in the first place. --> <!-- Both 🆑's are required for the changelog to work! You can put your name to the right of the first 🆑 if you want to overwrite your GitHub username as author ingame. --> <!-- You can use multiple of the same prefix (they're only used for the icon ingame) and delete the unneeded ones. Despite some of the tags, changelogs should generally represent how a player might be affected by the changes rather than a summary of the PR's contents. --> * Optimizes timer insertion by 80% (W QDEL_IN micro) --------- Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com>
68 lines
3.9 KiB
Plaintext
68 lines
3.9 KiB
Plaintext
//! Defines that give qdel hints.
|
|
//!
|
|
//! These can be given as a return in [/atom/proc/Destroy] or by calling [/proc/qdel].
|
|
|
|
/// `qdel` should queue the object for deletion.
|
|
#define QDEL_HINT_QUEUE 0
|
|
/// `qdel` should let the object live after calling [/atom/proc/Destroy].
|
|
#define QDEL_HINT_LETMELIVE 1
|
|
/// Functionally the same as the above. `qdel` should assume the object will gc on its own, and not check it.
|
|
#define QDEL_HINT_IWILLGC 2
|
|
/// Qdel should assume this object won't GC, and queue a hard delete using a hard reference.
|
|
#define QDEL_HINT_HARDDEL 3
|
|
// Qdel should assume this object won't gc, and hard delete it posthaste.
|
|
#define QDEL_HINT_HARDDEL_NOW 4
|
|
|
|
|
|
#ifdef REFERENCE_TRACKING
|
|
/** If REFERENCE_TRACKING is enabled, qdel will call this object's find_references() verb.
|
|
*
|
|
* Functionally identical to [QDEL_HINT_QUEUE] if [GC_FAILURE_HARD_LOOKUP] is not enabled in _compiler_options.dm.
|
|
*/
|
|
#warn TG0001 qdel REFERENCE_TRACKING enabled
|
|
#define QDEL_HINT_FINDREFERENCE 5
|
|
/// Behavior as [QDEL_HINT_FINDREFERENCE], but only if the GC fails and a hard delete is forced.
|
|
#define QDEL_HINT_IFFAIL_FINDREFERENCE 6
|
|
#endif
|
|
|
|
// Defines for the ssgarbage queues
|
|
#define GC_QUEUE_FILTER 1 //! short queue to filter out quick gc successes so they don't hang around in the main queue for 5 minutes
|
|
#define GC_QUEUE_CHECK 2 //! main queue that waits 5 minutes because thats the longest byond can hold a reference to our shit.
|
|
#define GC_QUEUE_HARDDELETE 3 //! short queue for things that hard delete instead of going thru the gc subsystem, this is purely so if they *can* softdelete, they will soft delete rather then wasting time with a hard delete.
|
|
#define GC_QUEUE_COUNT 3 //! Number of queues, used for allocating the nested lists. Don't forget to increase this if you add a new queue stage
|
|
|
|
|
|
// Defines for the ssgarbage queue items
|
|
#define GC_QUEUE_ITEM_QUEUE_TIME 1 //! Time this item entered the queue
|
|
#define GC_QUEUE_ITEM_REF 2 //! Ref to the item
|
|
#define GC_QUEUE_ITEM_GCD_DESTROYED 3 //! Item's gc_destroyed var value. Used to detect ref reuse.
|
|
#define GC_QUEUE_ITEM_INDEX_COUNT 3 //! Number of item indexes, used for allocating the nested lists. Don't forget to increase this if you add a new queue item index
|
|
|
|
// Defines for the time an item has to get its reference cleaned before it fails the queue and moves to the next.
|
|
#define GC_FILTER_QUEUE (1 SECONDS)
|
|
#define GC_CHECK_QUEUE (5 MINUTES)
|
|
#define GC_DEL_QUEUE (10 SECONDS)
|
|
|
|
|
|
#define QDEL_ITEM_ADMINS_WARNED (1<<0) //! Set when admins are told about lag causing qdels in this type.
|
|
#define QDEL_ITEM_SUSPENDED_FOR_LAG (1<<1) //! Set when a type can no longer be hard deleted on failure because of lag it causes while this happens.
|
|
|
|
// Defines for the [gc_destroyed][/datum/var/gc_destroyed] var.
|
|
#define GC_CURRENTLY_BEING_QDELETED -2
|
|
|
|
#define QDELING(X) (X.gc_destroyed)
|
|
#define QDELETED(X) (isnull(X) || QDELING(X))
|
|
#define QDESTROYING(X) (!X || X.gc_destroyed == GC_CURRENTLY_BEING_QDELETED)
|
|
|
|
// This is a bit hacky, we do it to avoid people relying on a return value for the macro
|
|
// If you need that you should use QDEL_IN_STOPPABLE instead
|
|
#define QDEL_IN(item, time) ; \
|
|
addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(qdel), (time) > GC_FILTER_QUEUE ? WEAKREF(item) : item), time);
|
|
#define QDEL_IN_STOPPABLE(item, time) addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(qdel), (time) > GC_FILTER_QUEUE ? WEAKREF(item) : item), time, TIMER_STOPPABLE)
|
|
#define QDEL_IN_CLIENT_TIME(item, time) addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(qdel), item), time, TIMER_STOPPABLE | TIMER_CLIENT_TIME)
|
|
#define QDEL_NULL(item) qdel(item); item = null
|
|
#define QDEL_LIST(L) if(L) { for(var/I in L) qdel(I); L.Cut(); }
|
|
#define QDEL_LIST_IN(L, time) addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(______qdel_list_wrapper), L), time, TIMER_STOPPABLE)
|
|
#define QDEL_LIST_ASSOC(L) if(L) { for(var/I in L) { qdel(L[I]); qdel(I); } L.Cut(); }
|
|
#define QDEL_LIST_ASSOC_VAL(L) if(L) { for(var/I in L) qdel(L[I]); L.Cut(); }
|