mirror of
https://github.com/fulpstation/fulpstation.git
synced 2025-12-10 18:11:47 +00:00
Remove the prequeue
Delaying the gc wasn't having a worthwhile notice on qdel() cost and can slow shit down
This commit is contained in:
committed by
GitHub
parent
2d5d8f01e0
commit
36a1572eab
@@ -85,13 +85,10 @@ SUBSYSTEM_DEF(garbage)
|
|||||||
|
|
||||||
/datum/controller/subsystem/garbage/fire()
|
/datum/controller/subsystem/garbage/fire()
|
||||||
//the fact that this resets its processing each fire (rather then resume where it left off) is intentional.
|
//the fact that this resets its processing each fire (rather then resume where it left off) is intentional.
|
||||||
var/queue = GC_QUEUE_PREQUEUE
|
var/queue = GC_QUEUE_CHECK
|
||||||
|
|
||||||
while (state == SS_RUNNING)
|
while (state == SS_RUNNING)
|
||||||
switch (queue)
|
switch (queue)
|
||||||
if (GC_QUEUE_PREQUEUE)
|
|
||||||
HandlePreQueue()
|
|
||||||
queue = GC_QUEUE_PREQUEUE+1
|
|
||||||
if (GC_QUEUE_CHECK)
|
if (GC_QUEUE_CHECK)
|
||||||
HandleQueue(GC_QUEUE_CHECK)
|
HandleQueue(GC_QUEUE_CHECK)
|
||||||
queue = GC_QUEUE_CHECK+1
|
queue = GC_QUEUE_CHECK+1
|
||||||
@@ -103,25 +100,6 @@ SUBSYSTEM_DEF(garbage)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
//If you see this proc high on the profile, what you are really seeing is the garbage collection/soft delete overhead in byond.
|
|
||||||
//Don't attempt to optimize, not worth the effort.
|
|
||||||
/datum/controller/subsystem/garbage/proc/HandlePreQueue()
|
|
||||||
var/list/tobequeued = queues[GC_QUEUE_PREQUEUE]
|
|
||||||
var/static/count = 0
|
|
||||||
if (count)
|
|
||||||
var/c = count
|
|
||||||
count = 0 //so if we runtime on the Cut, we don't try again.
|
|
||||||
tobequeued.Cut(1,c+1)
|
|
||||||
|
|
||||||
for (var/ref in tobequeued)
|
|
||||||
count++
|
|
||||||
Queue(ref, GC_QUEUE_PREQUEUE+1)
|
|
||||||
tobequeued[count] = null
|
|
||||||
if (MC_TICK_CHECK)
|
|
||||||
return
|
|
||||||
if (count)
|
|
||||||
tobequeued.Cut(1,count+1)
|
|
||||||
count = 0
|
|
||||||
|
|
||||||
/datum/controller/subsystem/garbage/proc/HandleQueue(level = GC_QUEUE_CHECK)
|
/datum/controller/subsystem/garbage/proc/HandleQueue(level = GC_QUEUE_CHECK)
|
||||||
if (level == GC_QUEUE_CHECK)
|
if (level == GC_QUEUE_CHECK)
|
||||||
@@ -196,11 +174,6 @@ SUBSYSTEM_DEF(garbage)
|
|||||||
queue.Cut(1,count+1)
|
queue.Cut(1,count+1)
|
||||||
count = 0
|
count = 0
|
||||||
|
|
||||||
/datum/controller/subsystem/garbage/proc/PreQueue(datum/D)
|
|
||||||
if (D.gc_destroyed == GC_CURRENTLY_BEING_QDELETED)
|
|
||||||
queues[GC_QUEUE_PREQUEUE] += D
|
|
||||||
D.gc_destroyed = GC_QUEUED_FOR_QUEUING
|
|
||||||
|
|
||||||
/datum/controller/subsystem/garbage/proc/Queue(datum/D, level = GC_QUEUE_CHECK)
|
/datum/controller/subsystem/garbage/proc/Queue(datum/D, level = GC_QUEUE_CHECK)
|
||||||
if (isnull(D))
|
if (isnull(D))
|
||||||
return
|
return
|
||||||
@@ -251,11 +224,6 @@ SUBSYSTEM_DEF(garbage)
|
|||||||
message_admins("Error: [type]([refID]) took longer than 1 second to delete (took [time/10] seconds to delete).")
|
message_admins("Error: [type]([refID]) took longer than 1 second to delete (took [time/10] seconds to delete).")
|
||||||
postpone(time)
|
postpone(time)
|
||||||
|
|
||||||
/datum/controller/subsystem/garbage/proc/HardQueue(datum/D)
|
|
||||||
if (D.gc_destroyed == GC_CURRENTLY_BEING_QDELETED)
|
|
||||||
queues[GC_QUEUE_PREQUEUE] += D
|
|
||||||
D.gc_destroyed = GC_QUEUED_FOR_HARD_DEL
|
|
||||||
|
|
||||||
/datum/controller/subsystem/garbage/Recover()
|
/datum/controller/subsystem/garbage/Recover()
|
||||||
if (istype(SSgarbage.queues))
|
if (istype(SSgarbage.queues))
|
||||||
for (var/i in 1 to SSgarbage.queues.len)
|
for (var/i in 1 to SSgarbage.queues.len)
|
||||||
@@ -310,7 +278,7 @@ SUBSYSTEM_DEF(garbage)
|
|||||||
return
|
return
|
||||||
switch(hint)
|
switch(hint)
|
||||||
if (QDEL_HINT_QUEUE) //qdel should queue the object for deletion.
|
if (QDEL_HINT_QUEUE) //qdel should queue the object for deletion.
|
||||||
SSgarbage.PreQueue(D)
|
SSgarbage.Queue(D)
|
||||||
if (QDEL_HINT_IWILLGC)
|
if (QDEL_HINT_IWILLGC)
|
||||||
D.gc_destroyed = world.time
|
D.gc_destroyed = world.time
|
||||||
return
|
return
|
||||||
@@ -330,18 +298,18 @@ SUBSYSTEM_DEF(garbage)
|
|||||||
#endif
|
#endif
|
||||||
I.no_respect_force++
|
I.no_respect_force++
|
||||||
|
|
||||||
SSgarbage.PreQueue(D)
|
SSgarbage.Queue(D)
|
||||||
if (QDEL_HINT_HARDDEL) //qdel should assume this object won't gc, and queue a hard delete using a hard reference to save time from the locate()
|
if (QDEL_HINT_HARDDEL) //qdel should assume this object won't gc, and queue a hard delete
|
||||||
SSgarbage.HardQueue(D)
|
SSgarbage.Queue(D, GC_QUEUE_HARDDELETE)
|
||||||
if (QDEL_HINT_HARDDEL_NOW) //qdel should assume this object won't gc, and hard del it post haste.
|
if (QDEL_HINT_HARDDEL_NOW) //qdel should assume this object won't gc, and hard del it post haste.
|
||||||
SSgarbage.HardDelete(D)
|
SSgarbage.HardDelete(D)
|
||||||
if (QDEL_HINT_FINDREFERENCE)//qdel will, if TESTING is enabled, display all references to this object, then queue the object for deletion.
|
if (QDEL_HINT_FINDREFERENCE)//qdel will, if TESTING is enabled, display all references to this object, then queue the object for deletion.
|
||||||
SSgarbage.PreQueue(D)
|
SSgarbage.Queue(D)
|
||||||
#ifdef TESTING
|
#ifdef TESTING
|
||||||
D.find_references()
|
D.find_references()
|
||||||
#endif
|
#endif
|
||||||
if (QDEL_HINT_IFFAIL_FINDREFERENCE)
|
if (QDEL_HINT_IFFAIL_FINDREFERENCE)
|
||||||
SSgarbage.PreQueue(D)
|
SSgarbage.Queue(D)
|
||||||
#ifdef TESTING
|
#ifdef TESTING
|
||||||
SSgarbage.reference_find_on_fail[REF(D)] = TRUE
|
SSgarbage.reference_find_on_fail[REF(D)] = TRUE
|
||||||
#endif
|
#endif
|
||||||
@@ -351,7 +319,7 @@ SUBSYSTEM_DEF(garbage)
|
|||||||
testing("WARNING: [D.type] is not returning a qdel hint. It is being placed in the queue. Further instances of this type will also be queued.")
|
testing("WARNING: [D.type] is not returning a qdel hint. It is being placed in the queue. Further instances of this type will also be queued.")
|
||||||
#endif
|
#endif
|
||||||
I.no_hint++
|
I.no_hint++
|
||||||
SSgarbage.PreQueue(D)
|
SSgarbage.Queue(D)
|
||||||
else if(D.gc_destroyed == GC_CURRENTLY_BEING_QDELETED)
|
else if(D.gc_destroyed == GC_CURRENTLY_BEING_QDELETED)
|
||||||
CRASH("[D.type] destroy proc was called multiple times, likely due to a qdel loop in the Destroy logic")
|
CRASH("[D.type] destroy proc was called multiple times, likely due to a qdel loop in the Destroy logic")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user