From c85f8af662067df05702a5217c46a705616c7432 Mon Sep 17 00:00:00 2001 From: dwasint <82520990+dwasint@users.noreply.github.com> Date: Fri, 23 Aug 2024 14:07:31 -0700 Subject: [PATCH] Revert "Optimize replays by implementing batch marking (#2840)" This reverts commit 9d90bee71e89fb3cf2eba0b72bdbbc4a1eed8d2b. --- code/_onclick/item_attack.dm | 4 +- code/controllers/subsystem/atoms.dm | 4 - code/datums/components/overlay_lighting.dm | 4 +- code/game/atoms.dm | 2 +- code/modules/lighting/lighting_source.dm | 25 +++---- code/modules/shuttle/docking.dm | 3 - code/modules/shuttle/on_move.dm | 2 + .../code/modules/replays/subsystem/replay.dm | 75 +++++-------------- 8 files changed, 35 insertions(+), 84 deletions(-) diff --git a/code/_onclick/item_attack.dm b/code/_onclick/item_attack.dm index 539dcb585ab2..4bf89bac58cd 100644 --- a/code/_onclick/item_attack.dm +++ b/code/_onclick/item_attack.dm @@ -10,13 +10,13 @@ /obj/item/proc/melee_attack_chain(mob/user, atom/target, params) var/is_right_clicking = (user.istate & ISTATE_SECONDARY) - // monkestation start: REPLAYS + //Monkestation edit: REPLAYS SSdemo.mark_dirty(src) if(isturf(target)) SSdemo.mark_turf(target) else SSdemo.mark_dirty(target) - // monkestation end: REPLAYS + //Monkestation edit: REPLAYS if(tool_behaviour && (target.tool_act(user, src, tool_behaviour, is_right_clicking) & TOOL_ACT_MELEE_CHAIN_BLOCKING)) return TRUE diff --git a/code/controllers/subsystem/atoms.dm b/code/controllers/subsystem/atoms.dm index 5bc5d756c691..db565d2c15cc 100644 --- a/code/controllers/subsystem/atoms.dm +++ b/code/controllers/subsystem/atoms.dm @@ -103,19 +103,16 @@ SUBSYSTEM_DEF(atoms) PROFILE_INIT_ATOM_BEGIN() InitAtom(A, TRUE, mapload_arg) PROFILE_INIT_ATOM_END(A) - SSdemo.mark_multiple_new(atoms) // monkestation edit: replays else #ifdef TESTING count = 0 #endif - var/list/atoms_to_mark = list() // monkestation edit: replays for(var/atom/A as anything in world) if(!(A.flags_1 & INITIALIZED_1)) PROFILE_INIT_ATOM_BEGIN() InitAtom(A, FALSE, mapload_arg) PROFILE_INIT_ATOM_END(A) - atoms_to_mark += A // monkestation edit: replays #ifdef TESTING ++count #endif @@ -124,7 +121,6 @@ SUBSYSTEM_DEF(atoms) stoplag() if(mapload_source) set_tracked_initalized(INITIALIZATION_INNEW_MAPLOAD, mapload_source) - SSdemo.mark_multiple_new(atoms_to_mark) // monkestation edit: replays testing("Initialized [count] atoms") diff --git a/code/datums/components/overlay_lighting.dm b/code/datums/components/overlay_lighting.dm index f6948f92d5e8..95115d98629e 100644 --- a/code/datums/components/overlay_lighting.dm +++ b/code/datums/components/overlay_lighting.dm @@ -170,7 +170,7 @@ /datum/component/overlay_lighting/proc/clean_old_turfs() for(var/turf/lit_turf as anything in affected_turfs) lit_turf.dynamic_lumcount -= lum_power - SSdemo.mark_multiple_turfs(affected_turfs) // monkestation edit: REPLAYS + SSdemo.mark_turf(lit_turf) //Monkestation Edit: REPLAYS affected_turfs = null @@ -181,9 +181,9 @@ . = list() for(var/turf/lit_turf in view(lumcount_range, get_turf(current_holder))) lit_turf.dynamic_lumcount += lum_power + SSdemo.mark_turf(lit_turf) //Monkestation Edit: REPLAYS . += lit_turf if(length(.)) - SSdemo.mark_multiple_turfs(.) // monkestation edit: REPLAYS affected_turfs = . diff --git a/code/game/atoms.dm b/code/game/atoms.dm index bea55e0b37e3..4c1dfd909545 100644 --- a/code/game/atoms.dm +++ b/code/game/atoms.dm @@ -203,7 +203,7 @@ if(SSatoms.InitAtom(src, FALSE, args)) //we were deleted return - SSdemo.mark_new(src) //Monkestation edit: Replays + SSdemo.mark_new(src) //Monkestation edit: Replays /** * The primary method that objects are setup in SS13 with diff --git a/code/modules/lighting/lighting_source.dm b/code/modules/lighting/lighting_source.dm index 3abfd151153f..1c6da704dfd1 100644 --- a/code/modules/lighting/lighting_source.dm +++ b/code/modules/lighting/lighting_source.dm @@ -193,21 +193,16 @@ /datum/light_source/proc/remove_lum() SETUP_CORNERS_REMOVAL_CACHE(src) applied = FALSE - var/list/turfs_to_mark = list() for (var/datum/lighting_corner/corner as anything in effect_str) REMOVE_CORNER(corner) LAZYREMOVE(corner.affecting, src) - // monkestation start: REPLAYS - turfs_to_mark += list( - corner.master_NE, - corner.master_SE, - corner.master_SW, - corner.master_NW - ) - // monkestation end: REPLAYS - - SSdemo.mark_multiple_turfs(turfs_to_mark) // monkestation edit: REPLAYS + //Monkestation Edit: REPLAYS + SSdemo.mark_turf(corner.master_NE) + SSdemo.mark_turf(corner.master_SE) + SSdemo.mark_turf(corner.master_SW) + SSdemo.mark_turf(corner.master_NW) + //Monkestation Edit: REPLAYS effect_str = null @@ -326,7 +321,6 @@ var/uses_multiz = !!GET_LOWEST_STACK_OFFSET(source_turf.z) var/oldlum = source_turf.luminosity source_turf.luminosity = CEILING(light_outer_range, 1) - var/list/turfs_to_mark = list() if(!uses_multiz) // Yes I know this could be acomplished with an if in the for loop, but it's fukin lighting code man for(var/turf/T in view(CEILING(light_outer_range, 1), source_turf)) if(IS_OPAQUE_TURF(T)) @@ -338,7 +332,7 @@ corners[T.lighting_corner_SE] = 0 corners[T.lighting_corner_SW] = 0 corners[T.lighting_corner_NW] = 0 - turfs_to_mark += T // Monkestation Edit: REPLAYS + SSdemo.mark_turf(T) //Monkestation Edit: REPLAYS else for(var/turf/T in view(CEILING(light_outer_range, 1), source_turf)) if(IS_OPAQUE_TURF(T)) @@ -350,7 +344,7 @@ corners[T.lighting_corner_SE] = 0 corners[T.lighting_corner_SW] = 0 corners[T.lighting_corner_NW] = 0 - turfs_to_mark += T // Monkestation Edit: REPLAYS + SSdemo.mark_turf(T) //Monkestation Edit: REPLAYS var/turf/below = GET_TURF_BELOW(T) var/turf/previous = T @@ -389,10 +383,9 @@ corners[above.lighting_corner_SW] = 0 corners[above.lighting_corner_NW] = 0 above = GET_TURF_ABOVE(above) - turfs_to_mark += T // Monkestation Edit: REPLAYS + SSdemo.mark_turf(T) //Monkestation Edit: REPLAYS source_turf.luminosity = oldlum - SSdemo.mark_multiple_turfs(turfs_to_mark) SETUP_CORNERS_CACHE(src) diff --git a/code/modules/shuttle/docking.dm b/code/modules/shuttle/docking.dm index 04553ccd4f7d..a11ede8578f5 100644 --- a/code/modules/shuttle/docking.dm +++ b/code/modules/shuttle/docking.dm @@ -133,7 +133,6 @@ old_turfs[oldT] = move_mode /obj/docking_port/mobile/proc/takeoff(list/old_turfs, list/new_turfs, list/moved_atoms, rotation, movement_direction, old_dock, area/underlying_old_area) - var/list/atoms_to_mark = list() // monkestation edit: replays for(var/i in 1 to old_turfs.len) var/turf/oldT = old_turfs[i] var/turf/newT = new_turfs[i] @@ -153,8 +152,6 @@ continue moving_atom.onShuttleMove(newT, oldT, movement_force, movement_direction, old_dock, src) //atoms moved_atoms[moving_atom] = oldT - atoms_to_mark += moving_atom - SSdemo.mark_multiple_dirty(atoms_to_mark) // monkestation edit: replays /obj/docking_port/mobile/proc/cleanup_runway(obj/docking_port/stationary/new_dock, list/old_turfs, list/new_turfs, list/areas_to_move, list/moved_atoms, rotation, movement_direction, area/underlying_old_area) diff --git a/code/modules/shuttle/on_move.dm b/code/modules/shuttle/on_move.dm index f13ed1b94765..a02524e06447 100644 --- a/code/modules/shuttle/on_move.dm +++ b/code/modules/shuttle/on_move.dm @@ -112,6 +112,8 @@ All ShuttleMove procs go here abstract_move(newT) + SSdemo.mark_dirty(src) //Monkestation Edit: Replays + return TRUE // Called on atoms after everything has been moved diff --git a/monkestation/code/modules/replays/subsystem/replay.dm b/monkestation/code/modules/replays/subsystem/replay.dm index e87f8890e7c6..d81e681777a4 100644 --- a/monkestation/code/modules/replays/subsystem/replay.dm +++ b/monkestation/code/modules/replays/subsystem/replay.dm @@ -163,18 +163,14 @@ SUBSYSTEM_DEF(demo) return SS_INIT_SUCCESS /datum/controller/subsystem/demo/fire() - var/marked_new_len = length(src.marked_new) - var/marked_dirty_len = length(src.marked_dirty) - var/marked_turfs_len = length(src.marked_turfs) - var/del_list_len = length(del_list) - if(!marked_new_len && !marked_dirty_len && !marked_turfs_len && !del_list_len) + if(!src.marked_new.len && !src.marked_dirty.len && !src.marked_turfs.len && !src.del_list.len) return // nothing to do - last_queued = marked_new_len + marked_dirty_len + marked_turfs_len + last_queued = src.marked_new.len + src.marked_dirty.len + src.marked_turfs.len last_completed = 0 write_time() - if(del_list_len) + if(src.del_list.len) var/s = "del [jointext(src.del_list, ",")]\n" // if I don't do it like this I get "incorrect number of macro arguments" because byond is stupid and sucks WRITE_LOG_NO_FORMAT(GLOB.demo_log, s) src.del_list.Cut() @@ -183,11 +179,11 @@ SUBSYSTEM_DEF(demo) var/list/marked_dirty = src.marked_dirty var/list/dirty_updates = list() - while(length(marked_dirty)) + while(marked_dirty.len) last_completed++ - var/atom/movable/M = marked_dirty[length(marked_dirty)] + var/atom/movable/M = marked_dirty[marked_dirty.len] marked_dirty.len-- - if(QDELETED(M)) + if(M.gc_destroyed || !M) continue if(M.loc == M.demo_last_loc) continue @@ -210,7 +206,7 @@ SUBSYSTEM_DEF(demo) if(MC_TICK_CHECK) canceled = TRUE break - if(length(dirty_updates)) + if(dirty_updates.len) var/s = "update [jointext(dirty_updates, ",")]\n" WRITE_LOG_NO_FORMAT(GLOB.demo_log, s) if(canceled) @@ -219,11 +215,11 @@ SUBSYSTEM_DEF(demo) var/list/marked_new = src.marked_new var/list/new_updates = list() - while(length(marked_new)) + while(marked_new.len) last_completed++ - var/atom/movable/M = marked_new[length(marked_new)] + var/atom/movable/M = marked_new[marked_new.len] marked_new.len-- - if(QDELETED(M)) + if(M.gc_destroyed || !M) continue var/loc_string = "null" if(isturf(M.loc)) @@ -235,7 +231,7 @@ SUBSYSTEM_DEF(demo) if(MC_TICK_CHECK) canceled = TRUE break - if(length(new_updates)) + if(new_updates.len) var/s = "new [jointext(new_updates, ",")]\n" WRITE_LOG_NO_FORMAT(GLOB.demo_log, s) if(canceled) @@ -244,9 +240,9 @@ SUBSYSTEM_DEF(demo) var/list/marked_turfs = src.marked_turfs var/list/turf_updates = list() - while(length(marked_turfs)) + while(marked_turfs.len) last_completed++ - var/turf/T = marked_turfs[length(marked_turfs)] + var/turf/T = marked_turfs[marked_turfs.len] marked_turfs.len-- if(T && T.appearance != T.demo_last_appearance) turf_updates += "([T.x],[T.y],[T.z])=[encode_appearance(T.appearance, T.demo_last_appearance)]" @@ -254,7 +250,7 @@ SUBSYSTEM_DEF(demo) if(MC_TICK_CHECK) canceled = TRUE break - if(length(turf_updates)) + if(turf_updates.len) var/s = "turf [jointext(turf_updates, ",")]\n" WRITE_LOG_NO_FORMAT(GLOB.demo_log, s) if(canceled) @@ -423,68 +419,35 @@ SUBSYSTEM_DEF(demo) msg += "}" return ..() -/datum/controller/subsystem/demo/proc/mark_turf(turf/turf) +/datum/controller/subsystem/demo/proc/mark_turf(turf/T) if(!can_fire) return - if(isturf(turf)) + if(!isturf(T)) return - marked_turfs[turf] = TRUE - -/datum/controller/subsystem/demo/proc/mark_multiple_turfs(list/turf/turf_list) - if(!can_fire) - return - if(!islist(turf_list)) - return - for(var/turf in turf_list) - if(!isturf(turf)) - continue - marked_turfs[turf] = TRUE + marked_turfs[T] = TRUE /datum/controller/subsystem/demo/proc/mark_new(atom/movable/M) if(!can_fire) return if(!isobj(M) && !ismob(M)) return - if(QDELING(M)) + if(M.gc_destroyed) return marked_new[M] = TRUE if(marked_dirty[M]) marked_dirty -= M -/datum/controller/subsystem/demo/proc/mark_multiple_new(list/atom/atom_list) - if(!can_fire) - return - for(var/atom/atom as anything in atom_list) - if(!isobj(atom) && !ismob(atom)) - continue - if(QDELING(atom)) - continue - marked_new[atom] = TRUE - if(marked_dirty[atom]) - marked_dirty -= atom - // I can't wait for when TG ports this and they make this a #define macro. /datum/controller/subsystem/demo/proc/mark_dirty(atom/movable/M) if(!can_fire) return if(!isobj(M) && !ismob(M)) return - if(QDELING(M)) + if(M.gc_destroyed) return if(!marked_new[M]) marked_dirty[M] = TRUE -/datum/controller/subsystem/demo/proc/mark_multiple_dirty(list/atom/movable/dirty_list) - if(!can_fire) - return - for(var/atom/movable/dirty as anything in dirty_list) - if(!isobj(dirty) && !ismob(dirty)) - continue - if(QDELING(dirty)) - continue - if(!marked_new[dirty]) - marked_dirty[dirty] = TRUE - /datum/controller/subsystem/demo/proc/mark_destroyed(atom/movable/M) if(!can_fire) return