Skip to content
Permalink
Browse files

Allow the ABM time budget to be configurable.

  • Loading branch information
lhofhansl committed Aug 18, 2020
1 parent 7242de1 commit 649211bf272df2dc7057347992c2653cf1c3a6fb
Showing with 9 additions and 2 deletions.
  1. +4 −0 builtin/settingtypes.txt
  2. +1 −0 src/defaultsettings.cpp
  3. +1 −0 src/environment.cpp
  4. +1 −0 src/environment.h
  5. +2 −2 src/serverenvironment.cpp
@@ -1282,6 +1282,10 @@ active_block_mgmt_interval (Active block management interval) float 2.0
# Length of time between Active Block Modifier (ABM) execution cycles
abm_interval (ABM interval) float 1.0

# The time budget allowed for ABMs to execute on each step
# (as a fraction of the ABM Interval)
abm_time_budget (ABM time budget) float 0.2 0.1 0.9

# Length of time between NodeTimer execution cycles
nodetimer_interval (NodeTimer interval) float 0.2

@@ -403,6 +403,7 @@ void set_default_settings(Settings *settings)
settings->setDefault("dedicated_server_step", "0.09");
settings->setDefault("active_block_mgmt_interval", "2.0");
settings->setDefault("abm_interval", "1.0");
settings->setDefault("abm_time_budget", "0.2");
settings->setDefault("nodetimer_interval", "0.2");
settings->setDefault("ignore_world_load_errors", "false");
settings->setDefault("remote_media", "");
@@ -36,6 +36,7 @@ Environment::Environment(IGameDef *gamedef):
m_cache_active_block_mgmt_interval = g_settings->getFloat("active_block_mgmt_interval");
m_cache_abm_interval = g_settings->getFloat("abm_interval");
m_cache_nodetimer_interval = g_settings->getFloat("nodetimer_interval");
m_cache_abm_time_budget = g_settings->getFloat("abm_time_budget");

m_time_of_day = g_settings->getU32("world_start_time");
m_time_of_day_f = (float)m_time_of_day / 24000.0f;
@@ -147,6 +147,7 @@ class Environment
float m_cache_active_block_mgmt_interval;
float m_cache_abm_interval;
float m_cache_nodetimer_interval;
float m_cache_abm_time_budget;

IGameDef *m_gamedef;

@@ -1354,8 +1354,8 @@ void ServerEnvironment::step(float dtime)
std::shuffle(output.begin(), output.end(), m_rgen);

int i = 0;
// The time budget for ABMs is 20%.
u32 max_time_ms = m_cache_abm_interval * 1000 / 5;
// determine the time budget for ABMs
u32 max_time_ms = m_cache_abm_interval * 1000 * m_cache_abm_time_budget;
for (const v3s16 &p : output) {
MapBlock *block = m_map->getBlockNoCreateNoEx(p);
if (!block)

0 comments on commit 649211b

Please sign in to comment.
You can’t perform that action at this time.