Skip to content

Commit

Permalink
bugfix: Returns possibility to reference tracking, fixes mobs hard de…
Browse files Browse the repository at this point in the history
…letion issue and makes landmarks hard delete now (ss220-space#5568)
  • Loading branch information
Vladisvell authored Jul 25, 2024
1 parent 643e5c6 commit 1df9a54
Show file tree
Hide file tree
Showing 14 changed files with 114 additions and 38 deletions.
14 changes: 11 additions & 3 deletions code/__DEFINES/qdel.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,17 @@
#define QDEL_HINT_IWILLGC 2 //functionally the same as the above. qdel should assume the object will gc on its own, and not check it.
#define QDEL_HINT_HARDDEL 3 /// Qdel should assume this object won't GC, and queue a hard delete using a hard reference.
#define QDEL_HINT_HARDDEL_NOW 4 // Qdel should assume this object won't gc, and hard delete it posthaste.
#define QDEL_HINT_FINDREFERENCE 5 //functionally identical to QDEL_HINT_QUEUE if TESTING is not enabled in _compiler_options.dm.
//if TESTING is enabled, qdel will call this object's find_references() verb.
#define QDEL_HINT_IFFAIL_FINDREFERENCE 6 //Above but only if gc fails.

#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 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 gc_destroyed var

Expand Down
9 changes: 9 additions & 0 deletions code/__HELPERS/_logging.dm
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,15 @@ GLOBAL_PROTECT(log_end)
messages.Add("[GLOB.log_end]")
WRITE_LOG(GLOB.tgui_log, messages.Join())

#ifdef REFERENCE_TRACKING
/proc/log_gc(text)
rustg_log_write(GLOB.gc_log, "[text][GLOB.log_end]", "true")
for(var/client/C in GLOB.admins)
if(check_rights(R_DEBUG | R_VIEWRUNTIMES, FALSE, C.mob) && (C.prefs.toggles & PREFTOGGLE_CHAT_DEBUGLOGS))
to_chat(C, "GC DEBUG: [text]")
#endif


/proc/log_sql(text)
WRITE_LOG(GLOB.sql_log, "[text][GLOB.log_end]")
SEND_TEXT(world.log, text) // Redirect it to DD too
Expand Down
20 changes: 16 additions & 4 deletions code/_compile_options.dm
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,23 @@
#define UNIT_TESTS
#endif

#ifdef TESTING
//#define GC_FAILURE_HARD_LOOKUP //makes paths that fail to GC call find_references before del'ing.
//implies FIND_REF_NO_CHECK_TICK
///Used to find the sources of harddels, quite laggy, don't be surpised if it freezes your client for a good while
//#define REFERENCE_TRACKING
#ifdef REFERENCE_TRACKING
#warn Reference tracking is enabled
///Run a lookup on things hard deleting by default.
//#define GC_FAILURE_HARD_LOOKUP
#ifdef GC_FAILURE_HARD_LOOKUP
#warn Lookup on things hard deleted is enabled
///Don't stop when searching, go till you're totally done
#define FIND_REF_NO_CHECK_TICK
#endif //ifdef GC_FAILURE_HARD_LOOKUP

// Log references in their own file, rather then in runtimes.log
#endif //ifdef REFERENCE_TRACKING

//#define FIND_REF_NO_CHECK_TICK //Sets world.loop_checks to false and prevents find references from sleeping
#ifdef TESTING
#warn Testing mode is enabled

#endif

Expand Down
5 changes: 5 additions & 0 deletions code/_globalvars/logging.dm
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ GLOBAL_PROTECT(sql_log)
GLOBAL_VAR(round_id)
GLOBAL_PROTECT(round_id)

#ifdef REFERENCE_TRACKING
GLOBAL_VAR(gc_log)
GLOBAL_PROTECT(gc_log)
#endif

GLOBAL_LIST_EMPTY(jobMax)
GLOBAL_PROTECT(jobMax)
GLOBAL_LIST_EMPTY(admin_log)
Expand Down
10 changes: 8 additions & 2 deletions code/controllers/subsystem/garbage.dm
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ SUBSYSTEM_DEF(garbage)
var/client/admin = c
if(!check_rights_for(admin, R_ADMIN))
continue
to_chat(admin, "## TESTING: GC: -- [ADMIN_VV(D)] | [type] was unable to be GC'd --")
to_chat(admin, "## TESTING: GC: -- [ADMIN_VV(D, "VV")] | [type] was unable to be GC'd --")
#endif
I.failures++

Expand Down Expand Up @@ -281,6 +281,7 @@ SUBSYSTEM_DEF(garbage)
type_info.hard_delete_time += tick_usage
if (tick_usage > type_info.hard_delete_max)
type_info.hard_delete_max = tick_usage

if (tick_usage > highest_del_ms)
highest_del_ms = tick_usage
highest_del_type_string = "[type]"
Expand All @@ -289,7 +290,12 @@ SUBSYSTEM_DEF(garbage)

if (time > 0.1 SECONDS)
postpone(time)
var/threshold = CONFIG_GET(number/hard_deletes_overrun_threshold)

var/threshold = 0
//Issue with global config not loading can happen when hard deletions happening before config loading
if(global.config)
threshold = CONFIG_GET(number/hard_deletes_overrun_threshold)

if (threshold && (time > threshold SECONDS))
if (!(type_info.qdel_flags & QDEL_ITEM_ADMINS_WARNED))
log_game("Error: [type]([refID]) took longer than [threshold] seconds to delete (took [round(time/10, 0.1)] seconds to delete)")
Expand Down
4 changes: 4 additions & 0 deletions code/controllers/subsystem/idlenpcpool.dm
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#ifdef UNIT_TESTS
GLOBAL_VAR_INIT(idlenpc_suspension, FALSE)
#else
GLOBAL_VAR_INIT(idlenpc_suspension, TRUE)
#endif

SUBSYSTEM_DEF(idlenpcpool)
name = "Idling NPC Pool"
Expand Down
4 changes: 4 additions & 0 deletions code/controllers/subsystem/mobs.dm
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#ifdef UNIT_TESTS
GLOBAL_VAR_INIT(mob_suspension, FALSE)
#else
GLOBAL_VAR_INIT(mob_suspension, TRUE)
#endif

SUBSYSTEM_DEF(mobs)
name = "Mobs"
Expand Down
4 changes: 4 additions & 0 deletions code/controllers/subsystem/npcpool.dm
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#ifdef UNIT_TESTS
GLOBAL_VAR_INIT(npcpool_suspension, FALSE)
#else
GLOBAL_VAR_INIT(npcpool_suspension, TRUE)
#endif

SUBSYSTEM_DEF(npcpool)
name = "NPC Pool"
Expand Down
40 changes: 24 additions & 16 deletions code/game/gamemodes/devil/game_mode.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,36 @@

/datum/game_mode/proc/auto_declare_completion_sintouched()
var/text = ""
if(sintouched.len)
text += "<br><span class='big'><b>The sintouched were:</b></span>"
var/list/sintouchedUnique = uniqueList(sintouched)
for(var/S in sintouchedUnique)
var/datum/mind/sintouched_mind = S
text += printplayer(sintouched_mind)
text += printobjectives(sintouched_mind)
text += "<br>"
if(!length(sintouched))
return

text += "<br><span class='big'><b>The sintouched were:</b></span>"
var/list/sintouchedUnique = uniqueList(sintouched)
for(var/S in sintouchedUnique)
var/datum/mind/sintouched_mind = S
text += printplayer(sintouched_mind)
text += printobjectives(sintouched_mind)
text += "<br>"

text += "<br>"

to_chat(world,text)

/datum/game_mode/proc/auto_declare_completion_devils()
var/text = ""
if(devils.len)
text += "<br><span class='big'><b>The devils were:</b></span>"
for(var/D in devils)
var/datum/mind/devil = D
text += printplayer(devil)
text += printdevilinfo(devil)
text += printobjectives(devil)
text += "<br>"
if(!length(devils))
return

text += "<br><span class='big'><b>The devils were:</b></span>"
for(var/D in devils)
var/datum/mind/devil = D
text += printplayer(devil)
text += printdevilinfo(devil)
text += printobjectives(devil)
text += "<br>"

text += "<br>"

to_chat(world,text)


Expand Down
28 changes: 16 additions & 12 deletions code/game/gamemodes/miniantags/abduction/abduction.dm
Original file line number Diff line number Diff line change
Expand Up @@ -211,20 +211,24 @@

/datum/game_mode/proc/auto_declare_completion_abduction()
var/text = ""
if(abductors.len)
text += "<br><span class='big'><b>The abductors were:</b></span><br>"
for(var/datum/mind/abductor_mind in abductors)
text += printplayer(abductor_mind)
if(!length(abductors))
return

text += "<br><span class='big'><b>The abductors were:</b></span><br>"
for(var/datum/mind/abductor_mind in abductors)
text += printplayer(abductor_mind)
text += "<br>"
text += printobjectives(abductor_mind)
text += "<br>"

if(abductees.len)
text += "<br><span class='big'><b>The abductees were:</b></span><br>"
for(var/datum/mind/abductee_mind in abductees)
text += printplayer(abductee_mind)
text += "<br>"
text += printobjectives(abductor_mind)
text += printobjectives(abductee_mind)
text += "<br>"
if(abductees.len)
text += "<br><span class='big'><b>The abductees were:</b></span><br>"
for(var/datum/mind/abductee_mind in abductees)
text += printplayer(abductee_mind)
text += "<br>"
text += printobjectives(abductee_mind)
text += "<br>"

to_chat(world, text)

//Landmarks
Expand Down
3 changes: 2 additions & 1 deletion code/game/objects/effects/landmarks.dm
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,9 @@
return 1

/obj/effect/landmark/Destroy()
. = ..()
GLOB.landmarks_list -= src
return ..()
return QDEL_HINT_HARDDEL_NOW

/obj/effect/landmark/singularity_act()
return
Expand Down
5 changes: 5 additions & 0 deletions code/game/world.dm
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,11 @@ GLOBAL_LIST_EMPTY(world_topic_handlers)
start_log(GLOB.http_log)
start_log(GLOB.sql_log)

#ifdef REFERENCE_TRACKING
GLOB.gc_log = "[GLOB.log_directory]/gc_debug.log"
start_log(GLOB.gc_log)
#endif

// This log follows a special format and this path should NOT be used for anything else
GLOB.runtime_summary_log = "data/logs/runtime_summary.log"
if(fexists(GLOB.runtime_summary_log))
Expand Down
3 changes: 3 additions & 0 deletions code/modules/mob/mob.dm
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
QDEL_LIST(diseases)
for(var/alert in alerts)
clear_alert(alert)
if(client)
var/client/client_ = client
client_.movingmob = null
ghostize()
QDEL_LIST_ASSOC_VAL(tkgrabbed_objects)
if(buckled)
Expand Down
3 changes: 3 additions & 0 deletions code/world.dm
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@
cache_lifespan = 0 //stops player uploaded stuff from being kept in the rsc past the current session
fps = 20 // If this isnt hard-defined, anything relying on this variable before world load will cry a lot
map_format = SIDE_MAP // If you want to destroy reality, remove this. (Caution: Also breaks Multi-Z)
#ifdef FIND_REF_NO_CHECK_TICK
loop_checks = FALSE
#endif

0 comments on commit 1df9a54

Please sign in to comment.