Lighting Process Workload Cap

Resolves some round-start and powernet failure lag caused by lighting updates. Excessive lighting updates are deferred until later.

# Changes
* Caps added to number of light sources and lighting overlays processed per tick.  This makes lighting updates slower to respond and "choppier" during large outages, but less likely to interrupt other server activities, such as mobs.
  * Max turf overlays per tick: 1,000
  * Max light sources per tick: 100
This commit is contained in:
Rob Nelson
2015-08-15 14:18:17 -07:00
parent 48f43321a6
commit 76b8a58e79
2 changed files with 20 additions and 3 deletions

View File

@@ -1,5 +1,10 @@
/datum/controller/process/lighting
schedule_interval = LIGHTING_INTERVAL
var/const/MAX_LIGHT_UPDATES_PER_WORK=100
var/const/MAX_OVERLAY_UPDATES_PER_WORK=1000 // idfk
var/light_updates=0
var/overlay_updates=0
/datum/controller/process/lighting/setup()
name = "lighting"
@@ -10,9 +15,12 @@
var/list/lighting_update_lights_old = lighting_update_lights //We use a different list so any additions to the update lists during a delay from scheck() don't cause things to be cut from the list without being updated.
lighting_update_lights = null //Nulling it first because of http://www.byond.com/forum/?post=1854520
lighting_update_lights = list()
light_updates=0
for(var/datum/light_source/L in lighting_update_lights_old)
if(L)
if(light_updates>MAX_LIGHT_UPDATES_PER_WORK)
lighting_update_lights += L
continue // DON'T break, we're adding stuff back into the update queue.
. = L.check()
if(L.destroyed || . || L.force_update)
L.remove_lum()
@@ -26,15 +34,23 @@
L.force_update = 0
L.needs_update = 0
light_updates++
scheck()
var/list/lighting_update_overlays_old = lighting_update_overlays //Same as above.
lighting_update_overlays = null //Same as above
lighting_update_overlays = list()
overlay_updates=0
for(var/atom/movable/lighting_overlay/O in lighting_update_overlays_old)
if(O)
if(overlay_updates>MAX_OVERLAY_UPDATES_PER_WORK)
lighting_update_overlays += O
continue // DON'T break, we're adding stuff back into the update queue.
O.update_overlay()
O.needs_update = 0
overlay_updates++
scheck()
world << "LIT: [light_updates]:[overlay_updates]"