From 7b7a4ca287d07ba53fb82cb0f01f5ac762d51db6 Mon Sep 17 00:00:00 2001 From: MrStonedOne Date: Fri, 6 Oct 2017 00:29:04 -0700 Subject: [PATCH 1/2] High pop reduced MC processing mode. The logic behind this is that at higher populations, byond ends up needing to do more at the end of the tick to update clients, that the mc and traditional sleep timers end up fighting for a very small amount of time left. Increasing the MC's sleep time means its wakes up sooner in the tick. So it has more time to do things, even if they don't happen as often, and leaving every other tick free allows for sleeping CHECK_TICK task to wake up without finding the MC left them very little time to do things. Admins have been regularly manually doing this by varediting the processing variable to 2, that i figured we should automate it. for /tg/, i plan on raising the player count a bit, but they make decent defaults for the avg server. --- code/__DEFINES/configuration.dm | 1 + .../configuration/entries/config.dm | 25 ++++++++++++++++- code/controllers/master.dm | 10 +++++++ code/modules/client/client_procs.dm | 3 ++ config/config.txt | 28 +++++++++++++++++-- 5 files changed, 64 insertions(+), 3 deletions(-) diff --git a/code/__DEFINES/configuration.dm b/code/__DEFINES/configuration.dm index c78dfb28ab2..3db0ca24c2c 100644 --- a/code/__DEFINES/configuration.dm +++ b/code/__DEFINES/configuration.dm @@ -2,6 +2,7 @@ #define CONFIG_DEF(X) /datum/config_entry/##X { resident_file = CURRENT_RESIDENT_FILE }; /datum/config_entry/##X #define CONFIG_GET(X) global.config.Get(/datum/config_entry/##X) #define CONFIG_SET(X, Y) global.config.Set(/datum/config_entry/##X, ##Y) +#define CONFIG_TWEAK(X) /datum/config_entry/##X #define CONFIG_MAPS_FILE "maps.txt" diff --git a/code/controllers/configuration/entries/config.dm b/code/controllers/configuration/entries/config.dm index dda8fd9a3ce..e7cb363e553 100644 --- a/code/controllers/configuration/entries/config.dm +++ b/code/controllers/configuration/entries/config.dm @@ -348,4 +348,27 @@ CONFIG_DEF(number/error_msg_delay) // How long to wait between messaging admins CONFIG_DEF(flag/irc_announce_new_game) -CONFIG_DEF(flag/debug_admin_hrefs) \ No newline at end of file +CONFIG_DEF(flag/debug_admin_hrefs) + + +CONFIG_DEF(number/mc_tick_rate/base_mc_tick_rate) + integer = FALSE + value = 1 + +CONFIG_DEF(number/mc_tick_rate/high_pop_mc_tick_rate) + integer = FALSE + value = 1.1 + +CONFIG_DEF(number/mc_tick_rate/high_pop_mc_mode_amount) + value = 65 + +CONFIG_DEF(number/mc_tick_rate/disable_high_pop_mc_mode_amount) + value = 60 + +CONFIG_TWEAK(number/mc_tick_rate) + abstract_type = /datum/config_entry/number/mc_tick_rate + +CONFIG_TWEAK(number/mc_tick_rate/ValidateAndSet(str_val)) + . = ..() + if (. && Master) + Master.UpdateTickRate() diff --git a/code/controllers/master.dm b/code/controllers/master.dm index 6ed3121179d..b92853a2c47 100644 --- a/code/controllers/master.dm +++ b/code/controllers/master.dm @@ -573,3 +573,13 @@ GLOBAL_REAL(Master, /datum/controller/master) = new for(var/S in subsystems) var/datum/controller/subsystem/SS = S SS.StopLoadingMap() + + +/datum/controller/master/proc/UpdateTickRate() + if (!processing) + return + var/client_count = length(GLOB.clients) + if (client_count < CONFIG_GET(number/mc_tick_rate/disable_high_pop_mc_mode_amount)) + processing = CONFIG_GET(number/mc_tick_rate/base_mc_tick_rate) + else if (client_count > CONFIG_GET(number/mc_tick_rate/high_pop_mc_mode_amount)) + processing = CONFIG_GET(number/mc_tick_rate/high_pop_mc_tick_rate) \ No newline at end of file diff --git a/code/modules/client/client_procs.dm b/code/modules/client/client_procs.dm index 7699c9cd5f8..886477fa965 100644 --- a/code/modules/client/client_procs.dm +++ b/code/modules/client/client_procs.dm @@ -350,6 +350,8 @@ GLOBAL_LIST(external_rsc_urls) if (menuitem) menuitem.Load_checked(src) + Master.UpdateTickRate() + ////////////// //DISCONNECT// ////////////// @@ -386,6 +388,7 @@ GLOBAL_LIST(external_rsc_urls) if(movingmob != null) movingmob.client_mobs_in_contents -= mob UNSETEMPTY(movingmob.client_mobs_in_contents) + Master.UpdateTickRate() return ..() /client/Destroy() diff --git a/config/config.txt b/config/config.txt index 1602cd4f48d..61a5b1c9d4c 100644 --- a/config/config.txt +++ b/config/config.txt @@ -232,9 +232,13 @@ ALLOW_HOLIDAYS ##This is currently a testing optimized setting. A good value for production would be 98. TICK_LIMIT_MC_INIT 500 -##Defines the ticklag for the world. 0.9 is the normal one, 0.5 is smoother. +##Defines the ticklag for the world. Ticklag is the amount of time between game ticks (aka byond ticks) (in 1/10ths of a second). +## This also controls the client network update rate, as well as the default client fps TICKLAG 0.5 +##Can also be set as per-second value, the follow value is identical to the above. +#FPS 20 + ## Comment this out to disable automuting #AUTOMUTE_ON @@ -360,4 +364,24 @@ MINUTE_TOPIC_LIMIT 100 #IRC_ANNOUNCE_NEW_GAME ## Allow admin hrefs that don't use the new token system, will eventually be removed -DEBUG_ADMIN_HREFS \ No newline at end of file +DEBUG_ADMIN_HREFS + +###Master Controller High Pop Mode### + +##The Master Controller(MC) is the primary system controlling timed tasks and events in SS13 (lobby timer, game checks, lighting updates, atmos, etc) +##Default base MC tick rate (1 = process every "byond tick" (see: tick_lag/fps config settings), 2 = process every 2 byond ticks, etc) +## Setting this to 0 will prevent the Master Controller from ticking +BASE_MC_TICK_RATE 1 + +##High population MC tick rate +## Byond rounds timer values UP, but the tick rate is modified with heuristics during lag spites so setting this to something like 2 +## will make it run every 2 byond ticks, but will also double the effect of anti-lag heuristics. You can instead set it to something like +## 1.1 to make it run every 2 byond ticks, but only increase the effect of anti-lag heuristics by 10%. or 1.5 for 50%. +## (As an aside, you could in theory also reduce the effect of anti-lag heuristics in the base tick rate by setting it to something like 0.5) +HIGH_POP_MC_TICK_RATE 1.1 + +##Engage high pop mode if player count raises above this (Player in this context means any connected user. Lobby, ghost or in-game all count) +HIGH_POP_MC_MODE_AMOUNT 65 + +##Disengage high pop mode if player count drops below this +DISABLE_HIGH_POP_MC_MODE_AMOUNT 60 From 8f5ee3927c10bd7edbb7e324a734cdd6ff6ec853 Mon Sep 17 00:00:00 2001 From: MrStonedOne Date: Fri, 6 Oct 2017 11:55:34 -0700 Subject: [PATCH 2/2] Some tweaks --- code/controllers/configuration/entries/config.dm | 2 +- config/config.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/code/controllers/configuration/entries/config.dm b/code/controllers/configuration/entries/config.dm index e7cb363e553..3be6db06c71 100644 --- a/code/controllers/configuration/entries/config.dm +++ b/code/controllers/configuration/entries/config.dm @@ -370,5 +370,5 @@ CONFIG_TWEAK(number/mc_tick_rate) CONFIG_TWEAK(number/mc_tick_rate/ValidateAndSet(str_val)) . = ..() - if (. && Master) + if (.) Master.UpdateTickRate() diff --git a/config/config.txt b/config/config.txt index 61a5b1c9d4c..39ebc952b6b 100644 --- a/config/config.txt +++ b/config/config.txt @@ -236,7 +236,7 @@ TICK_LIMIT_MC_INIT 500 ## This also controls the client network update rate, as well as the default client fps TICKLAG 0.5 -##Can also be set as per-second value, the follow value is identical to the above. +##Can also be set as per-second value, the following value is identical to the above. #FPS 20 ## Comment this out to disable automuting