mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-08-23 04:51:32 +01:00
Updated SSgarbage (#18173)
* pain * sadfas * sdfa * sdfasf * sfa * sdf * might the lord have mercy on our soul * i cri everidai * adeste fideles * sdf * where will this lead, what's coming next, from your inventions * dear lord * gjvhk * i cri everidai * fsgf * sdfa * sdaf * hiuhi
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
groups = list("create and destroy")
|
||||
var/result = null
|
||||
|
||||
// var/datum/running_create_and_destroy = FALSE
|
||||
GLOBAL_VAR_INIT(running_create_and_destroy, FALSE)
|
||||
/datum/unit_test/create_and_destroy/start_test()
|
||||
//We'll spawn everything here
|
||||
var/turf/spawn_at = locate()
|
||||
@@ -177,7 +177,7 @@
|
||||
var/original_baseturf = islist(spawn_at.baseturf) ? spawn_at.baseturf:Copy() : spawn_at.baseturf
|
||||
var/original_baseturf_count = length(original_baseturf)
|
||||
|
||||
// /datum/running_create_and_destroy = TRUE
|
||||
GLOB.running_create_and_destroy = TRUE
|
||||
for(var/type_path in typesof(/atom/movable, /turf) - ignore) //No areas please
|
||||
|
||||
TEST_DEBUG("[name]: now creating and destroying: [type_path]")
|
||||
@@ -188,7 +188,7 @@
|
||||
spawn_at.ChangeTurf(original_turf_type)
|
||||
if(original_baseturf_count != length(spawn_at.baseturf))
|
||||
TEST_FAIL("[type_path] changed the amount of baseturfs from [original_baseturf_count] to [length(spawn_at.baseturf)]; [english_list(original_baseturf)] to [islist(spawn_at.baseturf) ? english_list(spawn_at.baseturf) : spawn_at.baseturf]")
|
||||
// //Warn if it changes again
|
||||
//Warn if it changes again
|
||||
original_baseturf = islist(spawn_at.baseturf) ? spawn_at.baseturf:Copy() : spawn_at.baseturf
|
||||
original_baseturf_count = length(original_baseturf)
|
||||
else
|
||||
@@ -207,36 +207,54 @@
|
||||
for(var/atom/to_kill in to_del)
|
||||
qdel(to_kill)
|
||||
|
||||
GLOB.running_create_and_destroy = FALSE
|
||||
|
||||
//Hell code, we're bound to have ended the round somehow so let's stop if from ending while we work
|
||||
SSticker.delay_end = TRUE
|
||||
|
||||
// Drastically lower the amount of time it takes to GC, since we don't have clients that can hold it up.
|
||||
SSgarbage.collection_timeout[GC_QUEUE_CHECK] = 10 SECONDS
|
||||
//Clear it, just in case
|
||||
cached_contents.Cut()
|
||||
|
||||
var/list/queues_we_care_about = list()
|
||||
// All of em, I want hard deletes too, since we rely on the debug info from them
|
||||
for(var/i in 1 to GC_QUEUE_HARDDELETE)
|
||||
queues_we_care_about += i
|
||||
|
||||
//Now that we've qdel'd everything, let's sleep until the gc has processed all the shit we care about
|
||||
var/time_needed = SSgarbage.collection_timeout
|
||||
// + 2 seconds to ensure that everything gets in the queue.
|
||||
var/time_needed = 2 SECONDS
|
||||
for(var/index in queues_we_care_about)
|
||||
time_needed += SSgarbage.collection_timeout[index]
|
||||
|
||||
var/start_time = world.time
|
||||
var/real_start_time = REALTIMEOFDAY
|
||||
var/garbage_queue_processed = FALSE
|
||||
|
||||
sleep(time_needed)
|
||||
while(!garbage_queue_processed)
|
||||
var/list/queue_to_check = SSgarbage.queue
|
||||
//How the hell did you manage to empty this? Good job!
|
||||
if(!length(queue_to_check))
|
||||
garbage_queue_processed = TRUE
|
||||
break
|
||||
var/oldest_packet_creation = INFINITY
|
||||
for(var/index in queues_we_care_about)
|
||||
var/list/queue_to_check = SSgarbage.queues[index]
|
||||
if(!length(queue_to_check))
|
||||
continue
|
||||
|
||||
var/list/oldest_packet = queue_to_check[1]
|
||||
//Pull out the time we inserted at
|
||||
var/qdeld_at = oldest_packet[GC_QUEUE_ITEM_GCD_DESTROYED]
|
||||
|
||||
oldest_packet_creation = min(qdeld_at, oldest_packet_creation)
|
||||
|
||||
//Pull out the time we deld at
|
||||
var/qdeld_at = SSgarbage.queue[queue_to_check[1]]
|
||||
//If we've found a packet that got del'd later then we finished, then all our shit has been processed
|
||||
if(qdeld_at > start_time)
|
||||
//That said, if there are any pending hard deletes you may NOT sleep, we gotta handle that shit
|
||||
if(oldest_packet_creation > start_time && !length(SSgarbage.queues[GC_QUEUE_HARDDELETE]))
|
||||
garbage_queue_processed = TRUE
|
||||
break
|
||||
|
||||
#if !defined(REFERENCE_TRACKING)
|
||||
if(world.time > start_time + time_needed + 30 MINUTES) //If this gets us gitbanned I'm going to laugh so hard
|
||||
result = TEST_FAIL("Something has gone horribly wrong, the garbage queue has been processing for well over 30 minutes. What the hell did you do")
|
||||
if(REALTIMEOFDAY > real_start_time + time_needed + 50 MINUTES) //If this gets us gitbanned I'm going to laugh so hard
|
||||
TEST_FAIL("Something has gone horribly wrong, the garbage queue has been processing for well over 30 minutes. What the hell did you do")
|
||||
break
|
||||
#endif
|
||||
|
||||
//Immediately fire the gc right after
|
||||
SSgarbage.next_fire = 1
|
||||
@@ -244,11 +262,18 @@
|
||||
sleep(20 SECONDS)
|
||||
|
||||
//Alright, time to see if anything messed up
|
||||
var/list/cache_for_sonic_speed = SSgarbage.didntgc
|
||||
for(var/path in typesof(/atom/movable, /turf) - ignore)
|
||||
var/times = cache_for_sonic_speed[path]
|
||||
if(times)
|
||||
result = TEST_FAIL("[path] hard deleted [times] times.")
|
||||
var/list/cache_for_sonic_speed = SSgarbage.items
|
||||
for(var/path in cache_for_sonic_speed)
|
||||
var/datum/qdel_item/item = cache_for_sonic_speed[path]
|
||||
if(item.failures)
|
||||
result = TEST_FAIL("[item.name] hard deleted [item.failures] times out of a total del count of [item.qdels]")
|
||||
if(item.no_respect_force)
|
||||
result = TEST_FAIL("[item.name] failed to respect force deletion [item.no_respect_force] times out of a total del count of [item.qdels]")
|
||||
if(item.no_hint)
|
||||
result = TEST_FAIL("[item.name] failed to return a qdel hint [item.no_hint] times out of a total del count of [item.qdels]")
|
||||
if(LAZYLEN(item.extra_details))
|
||||
var/details = item.extra_details.Join("\n")
|
||||
result = TEST_FAIL("[item.name] failed with extra info: \n[details]")
|
||||
|
||||
cache_for_sonic_speed = SSatoms.BadInitializeCalls
|
||||
for(var/path in cache_for_sonic_speed)
|
||||
@@ -262,6 +287,6 @@
|
||||
|
||||
SSticker.delay_end = FALSE
|
||||
//This shouldn't be needed, but let's be polite
|
||||
SSgarbage.collection_timeout = initial(SSgarbage.collection_timeout)
|
||||
SSgarbage.collection_timeout[GC_QUEUE_CHECK] = GC_CHECK_QUEUE
|
||||
|
||||
return result ? result : TEST_PASS("All paths are created and destroyed successfully, without hard deletions or other unwanted behaviors")
|
||||
|
||||
@@ -32,12 +32,8 @@ SUBSYSTEM_DEF(unit_tests_config)
|
||||
var/retries = 0
|
||||
|
||||
/datum/controller/subsystem/unit_tests_config/PreInit()
|
||||
. = ..()
|
||||
|
||||
UT = new
|
||||
|
||||
world.fps = 10
|
||||
|
||||
//Acquire our identifier, or enter Hopper mode if failing to do so
|
||||
try
|
||||
src.identifier = rustg_file_read("config/unit_test/identifier.txt")
|
||||
|
||||
Reference in New Issue
Block a user