remove useless profiling verbs; remove controller timers; master controller cleanup

This commit is contained in:
BurnZeZ
2014-06-24 20:51:46 -04:00
parent e0b8e99b66
commit 004a907bfa
9 changed files with 222 additions and 433 deletions

View File

@@ -771,7 +771,6 @@
#include "code\modules\admin\verbs\playsound.dm"
#include "code\modules\admin\verbs\possess.dm"
#include "code\modules\admin\verbs\pray.dm"
#include "code\modules\admin\verbs\profiling.dm"
#include "code\modules\admin\verbs\randomverbs.dm"
#include "code\modules\admin\verbs\striketeam.dm"
#include "code\modules\admin\verbs\striketeam_syndicate.dm"

View File

@@ -75,10 +75,9 @@
process()
..()
CHECK_DISABLED(vents)
if(stat & (NOPOWER|BROKEN))
return
if (!node)
if(!node)
on = 0
//broadcast_status() // from now air alarm/control computer should request update purposely --rastaf0
if(!on)

View File

@@ -98,10 +98,9 @@
process()
..()
CHECK_DISABLED(scrubbers)
if(stat & (NOPOWER|BROKEN))
return
if (!node)
if(!node)
on = 0
//broadcast_status()
if(!on)

View File

@@ -1,55 +1,28 @@
//simplified MC that is designed to fail when procs 'break'. When it fails it's just replaced with a new one.
//It ensures master_controller.process() is never doubled up by killing the MC (hence terminating any of its sleeping procs)
//WIP, needs lots of work still
var/global/datum/controller/game_controller/master_controller //Set in world.New()
// simplified MC that is designed to fail when procs 'break'. When it fails it's just replaced with a new one.
// It ensures master_controller.process() is never doubled up by killing the MC (hence terminating any of its sleeping procs)
var/global/datum/controller/game_controller/master_controller
var/global/last_tick_timeofday = world.timeofday
var/global/last_tick_duration = 0
var/global/air_processing_killed = 0
var/global/pipe_processing_killed = 0
#ifdef PROFILE_MACHINES
// /type = time this tick
var/list/machine_profiling=list()
#endif
datum/controller/game_controller
var/breather_ticks = 2 //a somewhat crude attempt to iron over the 'bumps' caused by high-cpu use by letting the MC have a breather for this many ticks after every loop
var/minimum_ticks = 20 //The minimum length of time between MC ticks
var/air_cost = 0
var/sun_cost = 0
var/mobs_cost = 0
var/diseases_cost = 0
var/machines_cost = 0
var/objects_cost = 0
var/networks_cost = 0
var/powernets_cost = 0
var/nano_cost = 0
var/events_cost = 0
var/ticker_cost = 0
var/total_cost = 0
var/last_thing_processed
var/mob/list/expensive_mobs = list()
var/rebuild_active_areas = 0
var/minimum_ticks = 20
datum/controller/game_controller/New()
. = ..()
// There can be only one master_controller. Out with the old and in with the new.
if (master_controller != src)
if(master_controller != src) // THERE CAN ONLY BE ONE
log_debug("Rebuilding Master Controller")
if (istype(master_controller))
if(istype(master_controller))
recover()
qdel(master_controller)
master_controller = src
if (isnull(job_master))
if(job_master == null)
job_master = new /datum/controller/occupations()
job_master.SetupOccupations()
job_master.LoadJobs("config/jobs.txt")
@@ -87,21 +60,17 @@ datum/controller/game_controller/proc/setup()
for(var/i=0, i<max_secret_rooms, i++)
make_mining_asteroid_secret()
//if(config.socket_talk)
// keepalive()
spawn(0)
if(ticker)
ticker.pregame()
lighting_controller.Initialize()
datum/controller/game_controller/proc/setup_objects()
world << "\red \b Initializing objects"
sleep(-1)
for(var/atom/movable/object in world)
object.initialize()
for(var/atom/movable/O in world)
O.initialize()
world << "\red \b Initializing pipe networks"
sleep(-1)
@@ -125,31 +94,24 @@ datum/controller/game_controller/proc/setup_objects()
/datum/controller/game_controller/proc/process()
processing = 1
spawn (0)
spawn(0)
set background = BACKGROUND_ENABLED
while (1) // Far more efficient than recursively calling ourself.
if (isnull(failsafe))
while(1)
if(failsafe == null)
new /datum/controller/failsafe()
var/currenttime = world.timeofday
last_tick_duration = (currenttime - last_tick_timeofday) / 10
last_tick_timeofday = currenttime
if (processing)
if(processing)
iteration++
var/timer
var/start_time = world.timeofday
vote.process()
//process_newscaster()
//AIR
if(!air_processing_killed)
timer = world.timeofday
last_thing_processed = air_master.type
if(!air_master.Tick()) //Runtimed.
air_master.failed_ticks++
if(air_master.failed_ticks > 5)
@@ -160,191 +122,86 @@ datum/controller/game_controller/proc/setup_objects()
air_processing_killed = 1
air_master.failed_ticks = 0
air_cost = (world.timeofday - timer) / 10
sleep(breather_ticks)
//SUN
timer = world.timeofday
last_thing_processed = sun.type
sun.calc_position()
sun_cost = (world.timeofday - timer) / 10
sleep(breather_ticks)
//MOBS
timer = world.timeofday
processMobs()
mobs_cost = (world.timeofday - timer) / 10
sleep(breather_ticks)
//DISEASES
timer = world.timeofday
processDiseases()
diseases_cost = (world.timeofday - timer) / 10
sleep(breather_ticks)
//MACHINES
timer = world.timeofday
processMachines()
machines_cost = (world.timeofday - timer) / 10
sleep(breather_ticks)
//OBJECTS
timer = world.timeofday
processObjects()
objects_cost = (world.timeofday - timer) / 10
sleep(breather_ticks)
//PIPENETS
if(!pipe_processing_killed)
timer = world.timeofday
processPipenets()
networks_cost = (world.timeofday - timer) / 10
sleep(breather_ticks)
//POWERNETS
timer = world.timeofday
processPowernets()
powernets_cost = (world.timeofday - timer) / 10
sleep(breather_ticks)
//NANO UIS
timer = world.timeofday
processNano()
nano_cost = (world.timeofday - timer) / 10
sleep(breather_ticks)
//EVENTS
timer = world.timeofday
processEvents()
events_cost = (world.timeofday - timer) / 10
//TICKER
timer = world.timeofday
last_thing_processed = ticker.type
ticker.process()
ticker_cost = (world.timeofday - timer) / 10
//TIMING
total_cost = air_cost + sun_cost + mobs_cost + diseases_cost + machines_cost + objects_cost + networks_cost + powernets_cost + nano_cost + events_cost + ticker_cost
var/end_time = world.timeofday
if(end_time < start_time)
start_time -= 864000 //deciseconds in a day
sleep( round(minimum_ticks - (end_time - start_time),1) )
sleep(round(minimum_ticks - (end_time-start_time), 1))
else
sleep(10)
datum/controller/game_controller/proc/processMobs()
var/i = 1
expensive_mobs.Cut()
while(i<=mob_list.len)
var/mob/M = mob_list[i]
if(M)
var/clock = world.timeofday
last_thing_processed = M.type
M.Life()
if((world.timeofday - clock) > 1)
expensive_mobs += M
i++
/datum/controller/game_controller/proc/processMobs()
for(var/mob/M in mob_list)
if(M == null)
mob_list -= M
continue
mob_list.Cut(i,i+1)
M.Life()
/datum/controller/game_controller/proc/processDiseases()
for (var/datum/disease/Disease in active_diseases)
if(Disease)
last_thing_processed = Disease.type
Disease.process()
for(var/datum/disease/D in active_diseases)
if(D == null)
active_diseases -= D
continue
active_diseases -= Disease
D.process()
/datum/controller/game_controller/proc/processMachines()
#ifdef PROFILE_MACHINES
machine_profiling.Cut()
#endif
for (var/obj/machinery/Machinery in machines)
if (Machinery && Machinery.loc)
last_thing_processed = Machinery.type
#ifdef PROFILE_MACHINES
var/start = world.timeofday
#endif
if(PROCESS_KILL == Machinery.process())
Machinery.inMachineList = 0
machines.Remove(Machinery)
for(var/obj/machinery/M in machines)
if(M == null || M.loc == null)
// Not sure if safe to remove from list
continue
if (Machinery && Machinery.use_power)
Machinery.auto_use_power()
#ifdef PROFILE_MACHINES
var/end = world.timeofday
if (!(Machinery.type in machine_profiling))
machine_profiling[Machinery.type] = 0
machine_profiling[Machinery.type] += (end - start)
#endif
if(M.process() == PROCESS_KILL)
M.inMachineList = 0
machines.Remove(M)
continue
if(M.use_power)
M.auto_use_power()
/datum/controller/game_controller/proc/processObjects()
for (var/obj/Object in processing_objects)
if (Object && Object.loc)
last_thing_processed = Object.type
Object.process()
for(var/obj/O in processing_objects)
if(O == null || O.loc == null)
processing_objects -= O
continue
processing_objects -= Object
O.process()
/datum/controller/game_controller/proc/processPipenets()
last_thing_processed = /datum/pipe_network
for (var/datum/pipe_network/Pipe_Network in pipe_networks)
if(Pipe_Network)
Pipe_Network.process()
for(var/datum/pipe_network/P in pipe_networks)
if(P == null)
pipe_networks -= P
continue
pipe_networks -= Pipe_Network
P.process()
/datum/controller/game_controller/proc/processPowernets()
last_thing_processed = /datum/powernet
for (var/datum/powernet/Powernet in powernets)
if (Powernet)
Powernet.reset()
for(var/datum/powernet/P in powernets)
if(P == null)
powernets -= P
continue
powernets -= Powernet
P.reset()
/datum/controller/game_controller/proc/processNano()
for (var/datum/nanoui/Nanoui in nanomanager.processing_uis)
if (Nanoui)
Nanoui.process()
for(var/datum/nanoui/N in nanomanager.processing_uis)
if(N == null)
nanomanager.processing_uis -= N
continue
nanomanager.processing_uis -= Nanoui
N.process()
/datum/controller/game_controller/proc/processEvents()
last_thing_processed = /datum/event
for (var/datum/event/Event in events)
if (Event)
Event.process()
for(var/datum/event/E in events)
if(E == null)
events -= E
continue
events -= Event
checkEvent()
datum/controller/game_controller/recover() //Mostly a placeholder for now.
@@ -361,4 +218,3 @@ datum/controller/game_controller/recover() //Mostly a placeholder for now.
else
msg += "\t [varname] = [varval]\n"
world.log << msg

View File

@@ -152,9 +152,6 @@ var/list/admin_verbs_debug = list(
/client/proc/qdel_toggle, // /vg/
/client/proc/cmd_admin_dump_instances, // /vg/
/client/proc/disable_bloodvirii, // /vg/
#ifdef PROFILE_MACHINES
/client/proc/cmd_admin_dump_macprofile,
#endif
)
var/list/admin_verbs_possess = list(
/proc/possess,

View File

@@ -1125,21 +1125,6 @@ Pressure: [env.return_pressure()]"}
usr << "\blue Dumped to instances.csv."
#ifdef PROFILE_MACHINES
/client/proc/cmd_admin_dump_macprofile()
set category = "Debug"
set name = "Dump Machine Profiling"
var/F = file("machine_profiling.csv")
fdel(F)
F << "type,nanoseconds"
for(var/typepath in machine_profiling)
var/ns = machine_profiling[typepath]
F << "[typepath],[ns]"
usr << "\blue Dumped to machine_profiling.csv."
#endif
/client/proc/gib_money()
set category = "Fun"
set name = "Dispense Money"

View File

@@ -1,25 +0,0 @@
var/global/PROFILING_VERBS = list(
/client/proc/disable_scrubbers,
/client/proc/disable_vents,
)
/*
/client/proc/disable_scrubbers()
set category = "Debug"
set name = "Disable all scrubbers"
disable_scrubbers = !disable_scrubbers
world << "\red Scrubbers are now <b>[disable_scrubbers?"OFF":"ON"]</b>."
*/
#define gen_disable_proc(TYPE,LABEL) \
/client/proc/disable_##TYPE() { \
set category = "Debug"; \
set name = "Disable all "+LABEL; \
disable_##TYPE = !disable_##TYPE; \
world << "\red "+LABEL+" are now <b>[disable_##TYPE?"OFF":"ON"]</b>."; \
}
gen_disable_proc(scrubbers,"Scrubbers")
gen_disable_proc(vents, "Vents")
#undef gen_disable_proc

View File

@@ -1173,17 +1173,6 @@ note dizziness decrements automatically in the mob's Life() proc.
if (master_controller)
stat(null, "MasterController-[last_tick_duration] ([master_controller.processing?"On":"Off"]-[master_controller.iteration])")
stat(null, "Air-[master_controller.air_cost]")
stat(null, "Sun-[master_controller.sun_cost]")
stat(null, "Mob-[master_controller.mobs_cost]\t#[mob_list.len]")
stat(null, "Dis-[master_controller.diseases_cost]\t#[active_diseases.len]")
stat(null, "Mch-[master_controller.machines_cost]\t#[machines.len]")
stat(null, "Obj-[master_controller.objects_cost]\t#[processing_objects.len]")
stat(null, "PiNet-[master_controller.networks_cost]\t#[pipe_networks.len]")
stat(null, "Ponet-[master_controller.powernets_cost]\t#[powernets.len]")
stat(null, "NanoUI-[master_controller.nano_cost]\t#[nanomanager.processing_uis.len]")
stat(null, "Tick-[master_controller.ticker_cost]")
stat(null, "ALL-[master_controller.total_cost]")
else
stat(null, "master controller - ERROR")

View File

@@ -1,16 +1,6 @@
//This file was auto-corrected by findeclaration.exe on 25.5.2012 20:42:31
#define DEBUG
#define PROFILE_MACHINES // Disable when not debugging.
#ifdef PROFILE_MACHINES
#define CHECK_DISABLED(TYPE) if(disable_##TYPE) return
var/global/disable_scrubbers = 0
var/global/disable_vents = 0
#else
#define CHECK_DISABLED(TYPE) /* DO NOTHINK */
#endif
#define PI 3.1415
#define R_IDEAL_GAS_EQUATION 8.31 //kPa*L/(K*mol)