Make limiting of the reflow liquids queue size optional

If liquid_queue_purge_time == 0 then disable the queue size limiting and make this the default setting
Additionally, liquid_loop_max now defaults to 100000
This commit is contained in:
Craig Robbins 2014-12-23 09:25:18 +10:00
parent 0c37d48082
commit 7b93408884
3 changed files with 21 additions and 23 deletions

@ -99,10 +99,11 @@
# Enable a bit lower water surface; disable for speed (not quite optimized) # Enable a bit lower water surface; disable for speed (not quite optimized)
#new_style_water = false #new_style_water = false
# Max liquids processed per step # Max liquids processed per step
#liquid_loop_max = 10000 #liquid_loop_max = 100000
# The time (in seconds) that the liquids queue may grow beyond processing # The time (in seconds) that the liquids queue may grow beyond processing
# capacity until an attempt is made to decrease its size by dumping old queue items # capacity until an attempt is made to decrease its size by dumping old queue
#liquid_queue_purge_time = 30 # items. A value of 0 disables the functionality.
#liquid_queue_purge_time = 0
# Update liquids every .. recommend for finite: 0.2 # Update liquids every .. recommend for finite: 0.2
#liquid_update = 1.0 #liquid_update = 1.0
# Enable nice leaves; disable for speed # Enable nice leaves; disable for speed

@ -276,8 +276,8 @@ void set_default_settings(Settings *settings)
settings->setDefault("movement_gravity", "9.81"); settings->setDefault("movement_gravity", "9.81");
//liquid stuff //liquid stuff
settings->setDefault("liquid_loop_max", "10000"); settings->setDefault("liquid_loop_max", "100000");
settings->setDefault("liquid_queue_purge_time", "30"); settings->setDefault("liquid_queue_purge_time", "0");
settings->setDefault("liquid_update", "1.0"); settings->setDefault("liquid_update", "1.0");
//mapgen stuff //mapgen stuff

@ -1624,8 +1624,6 @@ void Map::transformLiquids(std::map<v3s16, MapBlock*> & modified_blocks)
u32 loopcount = 0; u32 loopcount = 0;
u32 initial_size = m_transforming_liquid.size(); u32 initial_size = m_transforming_liquid.size();
u32 curr_time = getTime(PRECISION_MILLI);
/*if(initial_size != 0) /*if(initial_size != 0)
infostream<<"transformLiquids(): initial_size="<<initial_size<<std::endl;*/ infostream<<"transformLiquids(): initial_size="<<initial_size<<std::endl;*/
@ -1638,11 +1636,11 @@ void Map::transformLiquids(std::map<v3s16, MapBlock*> & modified_blocks)
u32 liquid_loop_max = g_settings->getS32("liquid_loop_max"); u32 liquid_loop_max = g_settings->getS32("liquid_loop_max");
u32 loop_max = liquid_loop_max; u32 loop_max = liquid_loop_max;
// std::cout << "transformLiquids(): loopmax initial=" #if 0
// << loop_max * m_transforming_liquid_loop_count_multiplier;
// If liquid_loop_max is not keeping up with the queue size increase /* If liquid_loop_max is not keeping up with the queue size increase
// loop_max up to a maximum of liquid_loop_max * dedicated_server_step. * loop_max up to a maximum of liquid_loop_max * dedicated_server_step.
*/
if (m_transforming_liquid.size() > loop_max * 2) { if (m_transforming_liquid.size() > loop_max * 2) {
// "Burst" mode // "Burst" mode
float server_step = g_settings->getFloat("dedicated_server_step"); float server_step = g_settings->getFloat("dedicated_server_step");
@ -1653,9 +1651,7 @@ void Map::transformLiquids(std::map<v3s16, MapBlock*> & modified_blocks)
} }
loop_max *= m_transforming_liquid_loop_count_multiplier; loop_max *= m_transforming_liquid_loop_count_multiplier;
#endif
// std::cout << " queue sz=" << m_transforming_liquid.size()
// << " loop_max=" << loop_max;
while(m_transforming_liquid.size() != 0) while(m_transforming_liquid.size() != 0)
{ {
@ -1913,9 +1909,17 @@ void Map::transformLiquids(std::map<v3s16, MapBlock*> & modified_blocks)
updateLighting(lighting_modified_blocks, modified_blocks); updateLighting(lighting_modified_blocks, modified_blocks);
/* /* ----------------------------------------------------------------------
* Queue size limiting * Manage the queue so that it does not grow indefinately
*/ */
u16 time_until_purge = g_settings->getU16("liquid_queue_purge_time");
if (time_until_purge == 0)
return; // Feature disabled
time_until_purge *= 1000; // seconds -> milliseconds
u32 curr_time = getTime(PRECISION_MILLI);
u32 prev_unprocessed = m_unprocessed_count; u32 prev_unprocessed = m_unprocessed_count;
m_unprocessed_count = m_transforming_liquid.size(); m_unprocessed_count = m_transforming_liquid.size();
@ -1928,13 +1932,6 @@ void Map::transformLiquids(std::map<v3s16, MapBlock*> & modified_blocks)
m_queue_size_timer_started = true; m_queue_size_timer_started = true;
} }
u16 time_until_purge = g_settings->getU16("liquid_queue_purge_time");
time_until_purge *= 1000; // seconds -> milliseconds
// std::cout << " growing for: "
// << (m_queue_size_timer_started ? curr_time - m_inc_trend_up_start_time : 0)
// << "ms" << std::endl;
// Account for curr_time overflowing // Account for curr_time overflowing
if (m_queue_size_timer_started && m_inc_trending_up_start_time > curr_time) if (m_queue_size_timer_started && m_inc_trending_up_start_time > curr_time)
m_queue_size_timer_started = false; m_queue_size_timer_started = false;