aboutsummaryrefslogtreecommitdiff
path: root/penalty.lua
diff options
context:
space:
mode:
Diffstat (limited to 'penalty.lua')
-rw-r--r--penalty.lua56
1 files changed, 39 insertions, 17 deletions
diff --git a/penalty.lua b/penalty.lua
index 23f3e2f..beeaeac 100644
--- a/penalty.lua
+++ b/penalty.lua
@@ -2,9 +2,13 @@ local expected_dtime = tonumber(minetest.settings:get("dedicated_server_step"))
local subscribe_for_modification = mesecons_debug.settings._subscribe_for_modification
local max_penalty = mesecons_debug.settings.max_penalty
-subscribe_for_modification("max_penalty", function(value) max_penalty = value end)
+subscribe_for_modification("max_penalty", function(value)
+ max_penalty = value
+end)
local moderate_lag_ratio = mesecons_debug.settings.moderate_lag_ratio
-subscribe_for_modification("moderate_lag_ratio", function(value) moderate_lag_ratio = value end)
+subscribe_for_modification("moderate_lag_ratio", function(value)
+ moderate_lag_ratio = value
+end)
local high_lag_ratio = mesecons_debug.settings.high_lag_ratio
local high_lag_dtime = expected_dtime * high_lag_ratio
subscribe_for_modification("high_lag_ratio", function(value)
@@ -12,21 +16,37 @@ subscribe_for_modification("high_lag_ratio", function(value)
high_lag_dtime = expected_dtime * value
end)
local high_load_threshold = mesecons_debug.settings.high_load_threshold
-subscribe_for_modification("high_load_threshold", function(value) high_load_threshold = value end)
+subscribe_for_modification("high_load_threshold", function(value)
+ high_load_threshold = value
+end)
local penalty_check_steps = mesecons_debug.settings.penalty_check_steps
-subscribe_for_modification("penalty_check_steps", function(value) penalty_check_steps = value end)
+subscribe_for_modification("penalty_check_steps", function(value)
+ penalty_check_steps = value
+end)
local high_penalty_scale = mesecons_debug.settings.high_penalty_scale
-subscribe_for_modification("high_penalty_scale", function(value) high_penalty_scale = value end)
+subscribe_for_modification("high_penalty_scale", function(value)
+ high_penalty_scale = value
+end)
local high_penalty_offset = mesecons_debug.settings.high_penalty_offset
-subscribe_for_modification("high_penalty_offset", function(value) high_penalty_offset = value end)
+subscribe_for_modification("high_penalty_offset", function(value)
+ high_penalty_offset = value
+end)
local medium_penalty_scale = mesecons_debug.settings.medium_penalty_scale
-subscribe_for_modification("medium_penalty_scale", function(value) medium_penalty_scale = value end)
+subscribe_for_modification("medium_penalty_scale", function(value)
+ medium_penalty_scale = value
+end)
local medium_penalty_offset = mesecons_debug.settings.medium_penalty_offset
-subscribe_for_modification("medium_penalty_offset", function(value) medium_penalty_offset = value end)
+subscribe_for_modification("medium_penalty_offset", function(value)
+ medium_penalty_offset = value
+end)
local low_penalty_scale = mesecons_debug.settings.low_penalty_scale
-subscribe_for_modification("low_penalty_scale", function(value) low_penalty_scale = value end)
+subscribe_for_modification("low_penalty_scale", function(value)
+ low_penalty_scale = value
+end)
local low_penalty_offset = mesecons_debug.settings.low_penalty_offset
-subscribe_for_modification("low_penalty_offset", function(value) low_penalty_offset = value end)
+subscribe_for_modification("low_penalty_offset", function(value)
+ low_penalty_offset = value
+end)
local relative_load_max = mesecons_debug.settings.relative_load_clamp
local relative_load_min = 1 / mesecons_debug.settings.relative_load_clamp
subscribe_for_modification("relative_load_clamp", function(value)
@@ -35,7 +55,9 @@ subscribe_for_modification("relative_load_clamp", function(value)
end)
-- see https://en.wikipedia.org/w/index.php?title=Moving_average&oldid=1069105690#Exponential_moving_average
local averaging_coefficient = mesecons_debug.settings.averaging_coefficient
-subscribe_for_modification("averaging_coefficient", function(value) averaging_coefficient = value end)
+subscribe_for_modification("averaging_coefficient", function(value)
+ averaging_coefficient = value
+end)
local max = math.max
local min = math.min
@@ -56,8 +78,8 @@ local has_monitoring = mesecons_debug.has.monitoring
local mapblock_count, penalized_mapblock_count
if has_monitoring then
mapblock_count = monitoring.gauge("mesecons_debug_mapblock_count", "count of tracked mapblocks")
- penalized_mapblock_count = monitoring.gauge("mesecons_debug_penalized_mapblock_count",
- "count of penalized mapblocks")
+ penalized_mapblock_count =
+ monitoring.gauge("mesecons_debug_penalized_mapblock_count", "count of penalized mapblocks")
end
local elapsed_steps = 0
@@ -76,11 +98,11 @@ minetest.register_globalstep(function(dtime)
return
end
- local context_store_size = mesecons_debug.context_store_size -- # of blocks w/ active mesecons
+ local context_store_size = mesecons_debug.context_store_size -- # of blocks w/ active mesecons
local total_micros = mesecons_debug.total_micros
local total_micros_per_second = total_micros / elapsed
- local avg_total_micros_per_second = update_average(total_micros_per_second,
- mesecons_debug.avg_total_micros_per_second)
+ local avg_total_micros_per_second =
+ update_average(total_micros_per_second, mesecons_debug.avg_total_micros_per_second)
mesecons_debug.avg_total_micros_per_second = avg_total_micros_per_second
-- how much lag is there?
@@ -134,7 +156,7 @@ minetest.register_globalstep(function(dtime)
-- avg load per active context
local avg_avg_micros_per_second = avg_total_micros_per_second / context_store_size
- local penalized_count = 0 -- for monitoring
+ local penalized_count = 0 -- for monitoring
for _, ctx in pairs(mesecons_debug.context_store) do
if not ctx.whitelisted then
-- moving avg