From baefac24e2cc118e28d3a4b2e664ba5c71d73835 Mon Sep 17 00:00:00 2001 From: NatureFreshMilk Date: Mon, 11 Mar 2019 08:42:51 +0100 Subject: [PATCH 1/4] remove monitoring code and deps --- technic/depends.txt | 1 - technic/machines/HV/quarry.lua | 12 ------------ technic/machines/switching_station.lua | 27 -------------------------- 3 files changed, 40 deletions(-) diff --git a/technic/depends.txt b/technic/depends.txt index a66d81c..1b76ab3 100644 --- a/technic/depends.txt +++ b/technic/depends.txt @@ -12,4 +12,3 @@ intllib? unified_inventory? vector_extras? dye? -monitoring? diff --git a/technic/machines/HV/quarry.lua b/technic/machines/HV/quarry.lua index 74fec66..4f90322 100644 --- a/technic/machines/HV/quarry.lua +++ b/technic/machines/HV/quarry.lua @@ -4,15 +4,6 @@ local S = technic.getter local tube_entry = "^pipeworks_tube_connection_metallic.png" local cable_entry = "^technic_cable_connection_overlay.png" -local has_monitoring = minetest.get_modpath("monitoring") -local metric_dig_count - -if has_monitoring then - metric_dig_count = monitoring.counter("technic_quarry_dig_count", - "number of technic quarry digs") - -end - minetest.register_craft({ recipe = { {"technic:carbon_plate", "pipeworks:filter", "technic:composite_plate"}, @@ -144,9 +135,6 @@ local function quarry_handle_purge(pos) end local function quarry_run(pos, node) - if metric_dig_count ~= nil then - metric_dig_count.inc() - end local meta = minetest.get_meta(pos) local owner = meta:get_string("owner") diff --git a/technic/machines/switching_station.lua b/technic/machines/switching_station.lua index 47d4fe8..7d79068 100644 --- a/technic/machines/switching_station.lua +++ b/technic/machines/switching_station.lua @@ -4,20 +4,6 @@ technic.networks = {} technic.cables = {} technic.redundant_warn = {} -local has_monitoring = minetest.get_modpath("monitoring") -local metric_abm_count -local metric_abm_latency - -if has_monitoring then - metric_abm_count = monitoring.counter("technic_switching_station_abm_count", - "number of technic switch abm calls") - - metric_abm_latency = monitoring.histogram("technic_switching_station_abm_latency", - "latency of the technic switch abm calls", - {0.001, 0.005, 0.01, 0.02, 0.1, 0.5, 1.0}) -end - - local mesecons_path = minetest.get_modpath("mesecons") local digilines_path = minetest.get_modpath("digilines") @@ -256,13 +242,6 @@ minetest.register_abm({ action = function(pos, node, active_object_count, active_object_count_wider) if not technic.powerctrl_state then return end - local timer - if has_monitoring then - metric_abm_count.inc() - timer = metric_abm_latency.timer() - end - - local t0 = minetest.get_us_time() local meta = minetest.get_meta(pos) local meta1 = nil @@ -445,8 +424,6 @@ minetest.register_abm({ minetest.log("warning", "[technic] [+supply] switching station abm took " .. diff .. " us at " .. minetest.pos_to_string(pos)) end - if timer ~= nil then timer.observe() end - return end -- If the PR supply is not enough for the RE demand we will discharge the batteries too @@ -476,8 +453,6 @@ minetest.register_abm({ minetest.log("warning", "[technic] [-supply] switching station abm took " .. diff .. " us at " .. minetest.pos_to_string(pos)) end - if timer ~= nil then timer.observe() end - return end -- If the PR+BA supply is not enough for the RE demand: Power only the batteries @@ -502,8 +477,6 @@ minetest.register_abm({ minetest.log("warning", "[technic] switching station abm took " .. diff .. " us at " .. minetest.pos_to_string(pos)) end - if timer ~= nil then timer.observe() end - end, }) From 37dcb2a1014e49cb68a836b8d68d12589aba52cb Mon Sep 17 00:00:00 2001 From: Thomas Rudin Date: Mon, 11 Mar 2019 21:42:40 +0100 Subject: [PATCH 2/4] Revert "remove monitoring code and deps" This reverts commit 7b16d4fe870016b5e415585f1a57d44ae882745a. --- technic/depends.txt | 1 + technic/machines/HV/quarry.lua | 12 ++++++++++++ technic/machines/switching_station.lua | 27 ++++++++++++++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/technic/depends.txt b/technic/depends.txt index 1b76ab3..a66d81c 100644 --- a/technic/depends.txt +++ b/technic/depends.txt @@ -12,3 +12,4 @@ intllib? unified_inventory? vector_extras? dye? +monitoring? diff --git a/technic/machines/HV/quarry.lua b/technic/machines/HV/quarry.lua index 4f90322..74fec66 100644 --- a/technic/machines/HV/quarry.lua +++ b/technic/machines/HV/quarry.lua @@ -4,6 +4,15 @@ local S = technic.getter local tube_entry = "^pipeworks_tube_connection_metallic.png" local cable_entry = "^technic_cable_connection_overlay.png" +local has_monitoring = minetest.get_modpath("monitoring") +local metric_dig_count + +if has_monitoring then + metric_dig_count = monitoring.counter("technic_quarry_dig_count", + "number of technic quarry digs") + +end + minetest.register_craft({ recipe = { {"technic:carbon_plate", "pipeworks:filter", "technic:composite_plate"}, @@ -135,6 +144,9 @@ local function quarry_handle_purge(pos) end local function quarry_run(pos, node) + if metric_dig_count ~= nil then + metric_dig_count.inc() + end local meta = minetest.get_meta(pos) local owner = meta:get_string("owner") diff --git a/technic/machines/switching_station.lua b/technic/machines/switching_station.lua index 7d79068..47d4fe8 100644 --- a/technic/machines/switching_station.lua +++ b/technic/machines/switching_station.lua @@ -4,6 +4,20 @@ technic.networks = {} technic.cables = {} technic.redundant_warn = {} +local has_monitoring = minetest.get_modpath("monitoring") +local metric_abm_count +local metric_abm_latency + +if has_monitoring then + metric_abm_count = monitoring.counter("technic_switching_station_abm_count", + "number of technic switch abm calls") + + metric_abm_latency = monitoring.histogram("technic_switching_station_abm_latency", + "latency of the technic switch abm calls", + {0.001, 0.005, 0.01, 0.02, 0.1, 0.5, 1.0}) +end + + local mesecons_path = minetest.get_modpath("mesecons") local digilines_path = minetest.get_modpath("digilines") @@ -242,6 +256,13 @@ minetest.register_abm({ action = function(pos, node, active_object_count, active_object_count_wider) if not technic.powerctrl_state then return end + local timer + if has_monitoring then + metric_abm_count.inc() + timer = metric_abm_latency.timer() + end + + local t0 = minetest.get_us_time() local meta = minetest.get_meta(pos) local meta1 = nil @@ -424,6 +445,8 @@ minetest.register_abm({ minetest.log("warning", "[technic] [+supply] switching station abm took " .. diff .. " us at " .. minetest.pos_to_string(pos)) end + if timer ~= nil then timer.observe() end + return end -- If the PR supply is not enough for the RE demand we will discharge the batteries too @@ -453,6 +476,8 @@ minetest.register_abm({ minetest.log("warning", "[technic] [-supply] switching station abm took " .. diff .. " us at " .. minetest.pos_to_string(pos)) end + if timer ~= nil then timer.observe() end + return end -- If the PR+BA supply is not enough for the RE demand: Power only the batteries @@ -477,6 +502,8 @@ minetest.register_abm({ minetest.log("warning", "[technic] switching station abm took " .. diff .. " us at " .. minetest.pos_to_string(pos)) end + if timer ~= nil then timer.observe() end + end, }) From e44bf929601274fdc6dcb7016dfe2d83a1db04a0 Mon Sep 17 00:00:00 2001 From: NatureFreshMilk Date: Thu, 21 Mar 2019 13:07:49 +0100 Subject: [PATCH 3/4] rate limit forcefield rendering (on-case) --- technic/machines/HV/forcefield.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/technic/machines/HV/forcefield.lua b/technic/machines/HV/forcefield.lua index 29c023d..d3bc984 100644 --- a/technic/machines/HV/forcefield.lua +++ b/technic/machines/HV/forcefield.lua @@ -43,6 +43,14 @@ end) -- \___/\___/ local function update_forcefield(pos, meta, active) + + if active then + -- rate limit by chance + if math.floor(math.random()*4) ~= 0 then + return + end + end + local shape = meta:get_int("shape") local range = meta:get_int("range") local vm = VoxelManip() @@ -374,4 +382,3 @@ end technic.register_machine("HV", "technic:forcefield_emitter_on", technic.receiver) technic.register_machine("HV", "technic:forcefield_emitter_off", technic.receiver) - From 0af2749ac445b39a1350f5a69d328d404c7ec43e Mon Sep 17 00:00:00 2001 From: NatureFreshMilk Date: Thu, 21 Mar 2019 13:10:10 +0100 Subject: [PATCH 4/4] tune abm intervals to introduce jitter --- technic/machines/switching_station.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/technic/machines/switching_station.lua b/technic/machines/switching_station.lua index 47d4fe8..ff4665e 100644 --- a/technic/machines/switching_station.lua +++ b/technic/machines/switching_station.lua @@ -251,7 +251,7 @@ end minetest.register_abm({ nodenames = {"technic:switching_station"}, label = "Switching Station", -- allows the mtt profiler to profile this abm individually - interval = 1, + interval = 1.1, chance = 1, action = function(pos, node, active_object_count, active_object_count_wider) if not technic.powerctrl_state then return end @@ -524,7 +524,7 @@ end minetest.register_abm({ label = "Machines: timeout check", nodenames = {"group:technic_machine"}, - interval = 1, + interval = 1.9, chance = 3, action = function(pos, node, active_object_count, active_object_count_wider) local meta = minetest.get_meta(pos)