Skip to content

Commit

Permalink
Allow the ABM time budget to be configurable.
Browse files Browse the repository at this point in the history
  • Loading branch information
lhofhansl committed Aug 18, 2020
1 parent 7242de1 commit 649211b
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 2 deletions.
4 changes: 4 additions & 0 deletions builtin/settingtypes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions src/defaultsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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", "");
Expand Down
1 change: 1 addition & 0 deletions src/environment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/environment.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions src/serverenvironment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 649211b

Please sign in to comment.