From 6f9d3843112ea04dd159984af4470fa8456b18f0 Mon Sep 17 00:00:00 2001 From: Kahrl Date: Sun, 2 Jun 2013 17:38:53 +0200 Subject: Replace c55.me links --- minetest.conf.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'minetest.conf.example') diff --git a/minetest.conf.example b/minetest.conf.example index 1f9780f40..af75438ff 100644 --- a/minetest.conf.example +++ b/minetest.conf.example @@ -8,7 +8,7 @@ # Uncomment settings by removing the preceding #. # # Further documentation: -# http://c55.me/minetest/wiki/doku.php +# http://wiki.minetest.com/ # # NOTE: This file might not be up-to-date, refer to the # defaultsettings.cpp file for an up-to-date list: -- cgit v1.2.3 From e988df0fbdd9d568889a28640c189ae022e99f8e Mon Sep 17 00:00:00 2001 From: Kahrl Date: Sun, 2 Jun 2013 15:35:29 +0200 Subject: Add and implement setting max_clearobjects_extra_loaded_blocks. Now Environment::clearAllObjects() unloads unused blocks in an interval defined by max_clearobjects_extra_loaded_blocks (default 4096). --- minetest.conf.example | 4 ++++ src/defaultsettings.cpp | 1 + src/environment.cpp | 39 +++++++++++++++++++++++++++++++++++++++ src/map.cpp | 25 +++++++++++++++++++++++++ src/map.h | 8 +++++++- 5 files changed, 76 insertions(+), 1 deletion(-) (limited to 'minetest.conf.example') diff --git a/minetest.conf.example b/minetest.conf.example index af75438ff..4fd443db7 100644 --- a/minetest.conf.example +++ b/minetest.conf.example @@ -254,6 +254,10 @@ #max_block_send_distance = 10 # From how far blocks are generated for clients (value * 16 nodes) #max_block_generate_distance = 6 +# Number of extra blocks that can be loaded by /clearobjects at once +# This is a trade-off between sqlite transaction overhead and +# memory consumption (4096=100MB, as a rule of thumb) +#max_clearobjects_extra_loaded_blocks = 4096 # Interval of sending time of day to clients #time_send_interval = 5 # Length of day/night cycle. 72=20min, 360=4min, 1=24hour, 0=day/night/whatever stays unchanged diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index f270a47aa..d2bed7ed8 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -175,6 +175,7 @@ void set_default_settings(Settings *settings) settings->setDefault("max_simultaneous_block_sends_server_total", "20"); settings->setDefault("max_block_send_distance", "9"); settings->setDefault("max_block_generate_distance", "7"); + settings->setDefault("max_clearobjects_extra_loaded_blocks", "4096"); settings->setDefault("time_send_interval", "5"); settings->setDefault("time_speed", "72"); settings->setDefault("server_unload_unused_data_timeout", "29"); diff --git a/src/environment.cpp b/src/environment.cpp index 83ae59014..ab6a6d3d3 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -945,6 +945,16 @@ void ServerEnvironment::clearAllObjects() m_active_objects.erase(*i); } + // Get list of loaded blocks + std::list loaded_blocks; + infostream<<"ServerEnvironment::clearAllObjects(): " + <<"Listing all loaded blocks"<listAllLoadedBlocks(loaded_blocks); + infostream<<"ServerEnvironment::clearAllObjects(): " + <<"Done listing all loaded blocks: " + < loadable_blocks; infostream<<"ServerEnvironment::clearAllObjects(): " <<"Listing all loadable blocks"<::iterator i = loaded_blocks.begin(); + i != loaded_blocks.end(); ++i) + { + v3s16 p = *i; + MapBlock *block = m_map->getBlockNoCreateNoEx(p); + assert(block); + block->refGrab(); + } + + // Remove objects in all loadable blocks + u32 unload_interval = g_settings->getS32("max_clearobjects_extra_loaded_blocks"); + unload_interval = MYMAX(unload_interval, 1); u32 report_interval = loadable_blocks.size() / 10; u32 num_blocks_checked = 0; u32 num_blocks_cleared = 0; @@ -987,7 +1011,22 @@ void ServerEnvironment::clearAllObjects() <<" in "<unloadUnreferencedBlocks(); + } } + m_map->unloadUnreferencedBlocks(); + + // Drop references that were added above + for(std::list::iterator i = loaded_blocks.begin(); + i != loaded_blocks.end(); ++i) + { + v3s16 p = *i; + MapBlock *block = m_map->getBlockNoCreateNoEx(p); + assert(block); + block->refDrop(); + } + infostream<<"ServerEnvironment::clearAllObjects(): " <<"Finished: Cleared "< *unloaded_blocks) +{ + timerUpdate(0.0, -1.0, unloaded_blocks); +} + void Map::deleteSectors(std::list &list) { for(std::list::iterator j = list.begin(); @@ -3409,6 +3414,26 @@ void ServerMap::listAllLoadableBlocks(std::list &dst) } } +void ServerMap::listAllLoadedBlocks(std::list &dst) +{ + for(std::map::iterator si = m_sectors.begin(); + si != m_sectors.end(); ++si) + { + MapSector *sector = si->second; + + std::list blocks; + sector->getBlocks(blocks); + + for(std::list::iterator i = blocks.begin(); + i != blocks.end(); ++i) + { + MapBlock *block = (*i); + v3s16 p = block->getPos(); + dst.push_back(p); + } + } +} + void ServerMap::saveMapMeta() { DSTACK(__FUNCTION_NAME); diff --git a/src/map.h b/src/map.h index 31001e4c3..530d81e7a 100644 --- a/src/map.h +++ b/src/map.h @@ -279,6 +279,12 @@ public: void timerUpdate(float dtime, float unload_timeout, std::list *unloaded_blocks=NULL); + /* + Unloads all blocks with a zero refCount(). + Saves modified blocks before unloading on MAPTYPE_SERVER. + */ + void unloadUnreferencedBlocks(std::list *unloaded_blocks=NULL); + // Deletes sectors and their blocks from memory // Takes cache into account // If deleted sector is in sector cache, clears cache @@ -433,8 +439,8 @@ public: void endSave(); void save(ModifiedState save_level); - //void loadAll(); void listAllLoadableBlocks(std::list &dst); + void listAllLoadedBlocks(std::list &dst); // Saves map seed and possibly other stuff void saveMapMeta(); void loadMapMeta(); -- cgit v1.2.3 From b1ebd9f79c63cf78b0e0fb2ea6f52d82cdfb95b6 Mon Sep 17 00:00:00 2001 From: PilzAdam Date: Sat, 8 Jun 2013 23:42:46 +0000 Subject: Add a setting for max loop count per step in liquid update --- minetest.conf.example | 8 +++++++- src/defaultsettings.cpp | 1 + src/map.cpp | 8 ++++++-- 3 files changed, 14 insertions(+), 3 deletions(-) (limited to 'minetest.conf.example') diff --git a/minetest.conf.example b/minetest.conf.example index 4fd443db7..4306740e9 100644 --- a/minetest.conf.example +++ b/minetest.conf.example @@ -93,11 +93,17 @@ #new_style_water = false # Constant volume liquids #liquid_finite = false +# Max liquids processed per step +#liquid_loop_max = 1000 # Update liquids every .. recommend for finite: 0.2 #liquid_update = 1.0 -# When finite liquid: relax flowing blocks to source if level near max and N nearby source blocks, more realistic, but not true constant. values: 0,1,2,3,4 : 0 - disable, 1 - most aggresive +# Relax flowing blocks to source if level near max and N nearby +# source blocks, more realistic, but not true constant. +# values: 0,1,2,3,4 : 0 - disable, 1 - most aggresive +# (for finite liquids) #liquid_relax = 2 # Optimization: faster cave flood (and not true constant) +# (for finite liquids) #liquid_fast_flood = 1 # Underground water and lava springs, its infnity sources if liquid_finite enabled #underground_springs = 1 diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index 71c283241..ffaa7a3c7 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -209,6 +209,7 @@ void set_default_settings(Settings *settings) //liquid stuff settings->setDefault("liquid_finite", "false"); + settings->setDefault("liquid_loop_max", "1000"); settings->setDefault("liquid_update", "1.0"); settings->setDefault("liquid_relax", "2"); settings->setDefault("liquid_fast_flood", "1"); diff --git a/src/map.cpp b/src/map.cpp index 7439076d3..001ae1609 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -1651,10 +1651,12 @@ void Map::transformLiquidsFinite(std::map & modified_blocks) // List of MapBlocks that will require a lighting update (due to lava) std::map lighting_modified_blocks; + u16 loop_max = g_settings->getU16("liquid_loop_max"); + while (m_transforming_liquid.size() > 0) { // This should be done here so that it is done when continue is used - if (loopcount >= initial_size || loopcount >= 1000) + if (loopcount >= initial_size || loopcount >= loop_max) break; loopcount++; /* @@ -1993,10 +1995,12 @@ void Map::transformLiquids(std::map & modified_blocks) // List of MapBlocks that will require a lighting update (due to lava) std::map lighting_modified_blocks; + u16 loop_max = g_settings->getU16("liquid_loop_max"); + while(m_transforming_liquid.size() != 0) { // This should be done here so that it is done when continue is used - if(loopcount >= initial_size || loopcount >= 10000) + if(loopcount >= initial_size || loopcount >= loop_max) break; loopcount++; -- cgit v1.2.3