Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove lack of queue_icon_update optimization #2793

Merged
merged 3 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion baystation12.dme
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@
#include "code\controllers\subsystems\initialization\culture.dm"
#include "code\controllers\subsystems\initialization\customitems.dm"
#include "code\controllers\subsystems\initialization\fabrication.dm"
#include "code\controllers\subsystems\initialization\icon_updates.dm"
#include "code\controllers\subsystems\initialization\materials.dm"
#include "code\controllers\subsystems\initialization\misc.dm"
#include "code\controllers\subsystems\initialization\misc_early.dm"
Expand All @@ -247,7 +248,6 @@
#include "code\controllers\subsystems\processing\disposals.dm"
#include "code\controllers\subsystems\processing\fast_process.dm"
#include "code\controllers\subsystems\processing\graphs.dm"
#include "code\controllers\subsystems\processing\icon_updates.dm"
#include "code\controllers\subsystems\processing\nano.dm"
#include "code\controllers\subsystems\processing\obj.dm"
#include "code\controllers\subsystems\processing\processing.dm"
Expand Down
3 changes: 2 additions & 1 deletion code/__defines/subsystem-priority.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// SS_TICKER
#define SS_PRIORITY_TIMER 30
#define SS_PRIORITY_OVERLAYS 20
#define SS_PRIORITY_ICON_UPDATE 10


// Normal
#define SS_PRIORITY_TICKER 100 // Gameticker.
Expand All @@ -26,6 +26,7 @@
#define SS_PRIORITY_CHAT 40 // Chat
#define SS_PRIORITY_AI 25 // Mob AI
#define SS_PRIORITY_ALARM 20 // Alarm processing.
#define SS_PRIORITY_ICON_UPDATE 20 // Queued icon updates. Mostly used by APCs and tables.
#define SS_PRIORITY_EVENT 20 // Event processing and queue handling.
#define SS_PRIORITY_SHUTTLE 20 // Shuttle movement.
#define SS_PRIORITY_CIRCUIT_COMP 20 // Processing circuit component do_work.
Expand Down
79 changes: 79 additions & 0 deletions code/controllers/subsystems/initialization/icon_updates.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
SUBSYSTEM_DEF(icon_update)
name = "Icon Updates"
wait = 1
priority = SS_PRIORITY_ICON_UPDATE
init_order = SS_INIT_ICON_UPDATE
runlevels = RUNLEVEL_LOBBY | RUNLEVELS_DEFAULT // If you make it not fire in lobby, you also have to remove atoms from queue in Destroy.

// Linked lists, queue_refs[x] should have null or args stored in queue_args[x]
var/list/queue_refs = list() // Atoms
var/list/queue_args = list() // null or args


/datum/controller/subsystem/icon_update/UpdateStat(time)
if (PreventUpdateStat(time))
return ..()
..("queue: [length(queue_refs)]")


/datum/controller/subsystem/icon_update/Initialize(start_uptime)
fire(FALSE, TRUE)


/datum/controller/subsystem/icon_update/fire(resumed = FALSE, no_mc_tick = FALSE)
if(!queue_refs.len)
suspend()
return

while (queue_refs.len)

if(Master.map_loading)
return

// Pops the atom and it's args
var/atom/A = queue_refs[queue_refs.len]
var/myArgs = queue_args[queue_args.len]

queue_refs.len -= 1
queue_args.len -= 1

if(QDELETED(A))
continue

A.icon_update_queued = FALSE

if (islist(myArgs))
A.update_icon(arglist(myArgs))
else
A.update_icon()

if (no_mc_tick)
CHECK_TICK
else if (MC_TICK_CHECK)
return

/atom
var/icon_update_queued = FALSE

/atom/proc/queue_icon_update(...)
// Skips if this is already queued
if(!icon_update_queued)

icon_update_queued = TRUE
SSicon_update.queue_refs.Add(src)

// Makes sure these are in sync, in case runtimes/badmin
var/length = length(SSicon_update.queue_refs)
SSicon_update.queue_args.len = length
SSicon_update.queue_args[length] = args.len ? args : null

// SSicon_update sleeps when it runs out of things in its
// queue, so wake it up.
if(!Master.map_loading) // Don't wake early if we're loading a map, it'll get woken up when the map loads.
SSicon_update.wake()

/datum/controller/subsystem/icon_update/StartLoadingMap()
suspend()

/datum/controller/subsystem/icon_update/StopLoadingMap()
wake()
62 changes: 0 additions & 62 deletions code/controllers/subsystems/processing/icon_updates.dm

This file was deleted.

2 changes: 1 addition & 1 deletion code/modules/power/lighting.dm
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@
update_icon(FALSE)
sleep(rand(5, 15))
on = (get_status() == LIGHT_OK)
update_icon(0)
queue_icon_update(0)
flickering = FALSE

// ai attack - make lights flicker, because why not
Expand Down
2 changes: 1 addition & 1 deletion test/check-paths.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ exactly 0 "emagged = 0/1" 'emagged\s*=\s*\d' -P
exactly 0 "simulated = 0/1" 'simulated\s*=\s*\d' -P
exactly 2 "var/ in proc arguments" '(^/[^/].+/.+?\(.*?)var/' -P
exactly 0 "tmp/ vars" 'var.*/tmp/' -P
exactly 7 "uses of .len" '\.len\b' -P
exactly 15 "uses of .len" '\.len\b' -P
exactly 15 "uses of examine()" '[.|\s]examine\(' -P # If this fails it's likely because you used '/atom/proc/examine(mob)' instead of '/proc/examinate(mob, atom)' - Exception: An examine()-proc may call other examine()-procs
exactly 13 "direct modifications of overlays list" '\boverlays((\s*[|^=+&-])|(\.(Cut)|(Add)|(Copy)|(Remove)|(Remove)))' -P
exactly 0 "new/list list instantiations" 'new\s*/list' -P
Expand Down