diff --git a/TileGenerator.cpp b/TileGenerator.cpp index c1594b2..c68cd33 100644 --- a/TileGenerator.cpp +++ b/TileGenerator.cpp @@ -1908,6 +1908,50 @@ void TileGenerator::renderMap() } if (progressIndicator && eraseProgress) cout << std::setw(50) << "" << "\r"; + + if (m_generateNoPrefetch) { + double queryFactor = 1.0 * m_db->getBlocksQueriedCount() / m_db->getBlocksReadCount(); + if (verboseStatistics >= 4) { + std::cout << std::fixed << std::setprecision(2); + std::cout << "disable-blocklist-prefetch statistics:" << std::endl + << " Query factor: " << queryFactor << std::endl; + } + if (!(m_silenceSuggestions & SUGGESTION_PREFETCH) && queryFactor >= 10) { + std::cout << std::fixed << std::setprecision(2); + std::cout << "NOTE: amount of database blocks queried exceeds amount read by a factor " << queryFactor << "." << std::endl + << " This makes --disable-blocklist-prefetch rather inefficient. Consider disabling it, or" << std::endl + << " adjusting the vertical limits (e.g. --min-y=" << m_YMinMapped * 16 << " --max-y=" << m_YMaxMapped*16+15 << ")" << std::endl; + } + } + else { + double blocksFractionMapped = 1.0 * m_db->getBlocksReadCount() / m_worldBlocks; + long long worldVolumeMapped = (m_xMax-m_xMin+1) * (m_zMax-m_zMin+1) * (m_YMaxMapped-m_YMinMapped+1); + + if (verboseStatistics >= 4) { + std::cout << std::fixed << std::setprecision(2); + std::cout << "disable-blocklist-prefetch statistics:" << std::endl + << " World size (1M Blocks): " << m_worldBlocks / 1000.0 / 1000 + << " (" << MIN_NOPREFETCH_VOLUME / 1000.0 / 1000 << " .. " + << MAX_NOPREFETCH_VOLUME / 1000.0 / 1000 << ")" << std::endl + << " Fraction of world blocks mapped: " + << 100 * blocksFractionMapped << "% (limit: 10%)" << std::endl + << " Volume mapped: " + << worldVolumeMapped / 10000.0 << "% (" << worldVolumeMapped << ")" << std::endl; + } + + if (!(m_silenceSuggestions & SUGGESTION_PREFETCH) + && m_worldBlocks >= MIN_NOPREFETCH_VOLUME + && blocksFractionMapped < 0.1 + && worldVolumeMapped < MAX_NOPREFETCH_VOLUME) { + std::cout << "NOTE: Mapping speed may improve using the option --disable-blocklist-prefetch," + << " combined with vertical limits (" << m_YMinMapped * 16 << " .. " << m_YMaxMapped*16+15 << ")" << std::endl; + if (m_backend == "leveldb") { + std::cout << " The option --database-format=" << (m_recommendedDatabaseFormat != "" ? m_recommendedDatabaseFormat : "mixed") + << " is also required for the (current) leveldb backend." << std::endl + << " Use --verbose=2 or --database-format=query for details" << std::endl; + } + } + } } Color TileGenerator::computeMapHeightColor(int height) diff --git a/TileGenerator.h b/TileGenerator.h index d9ede27..9a40c8a 100644 --- a/TileGenerator.h +++ b/TileGenerator.h @@ -55,6 +55,7 @@ #define HEIGHTSCALESIZE 60 #define SUGGESTION_ALL 0xffffffff +#define SUGGESTION_PREFETCH 0x00000001 class TileGenerator { diff --git a/doc/manual.rst b/doc/manual.rst index 284343e..c74a747 100644 --- a/doc/manual.rst +++ b/doc/manual.rst @@ -282,7 +282,7 @@ Feedback / information options: * ``--version`` : Print version ID of minetestmapper * ``--verbose[=]`` : Report world and map statistics (size, dimensions, number of blocks) * ``--verbose-search-colors[=n]`` : Report which colors files are used and/or which locations are searched - * ``--silence-suggestions all`` : Do not bother doing suggestions + * ``--silence-suggestions all,prefetch`` : Do not bother doing suggestions * ``--progress`` : Show a progress indicator while generating the map Miscellaneous options @@ -1056,7 +1056,7 @@ Detailed Description of Options .. image:: images/drawscale-both.png .. image:: images/sidescale-interval.png -``--silence-suggestions all`` +``--silence-suggestions all,prefetch`` ...................................... Do not print usage suggestions of the specified types. @@ -1064,6 +1064,8 @@ Detailed Description of Options if that may be advantageous. This option disables such messages. :all: Silence all existing (and future) suggestions there may be. + :prefetch: Do not make suggestions a about the use of --disable-blocklist-prefetch, + and adjustment of --min-y and --max-y when using --disable-blocklist-prefetch. ``--sqlite-cacheworldrow`` .......................... @@ -1775,7 +1777,7 @@ More information is available: .. _--origincolor: `--origincolor `_ .. _--output: `--output `_ .. _--playercolor: `--playercolor `_ -.. _--silence-suggestions: `--silence-suggestions all`_ +.. _--silence-suggestions: `--silence-suggestions all,prefetch`_ .. _--scalecolor: `--scalecolor `_ .. _--scalefactor: `--scalefactor 1:`_ .. _--height-level-0: `--height-level-0 `_ diff --git a/mapper.cpp b/mapper.cpp index 7007116..24dc8d8 100644 --- a/mapper.cpp +++ b/mapper.cpp @@ -125,7 +125,7 @@ void usage() " --tilecenter ,|world|map\n" " --scalefactor 1:\n" " --chunksize \n" - " --silence-suggestions all\n" + " --silence-suggestions all,prefetch\n" " --verbose[=n]\n" " --verbose-search-colors[=n]\n" " --progress\n" @@ -883,6 +883,8 @@ int main(int argc, char *argv[]) } else if (flag == "all") generator.setSilenceSuggestion(SUGGESTION_ALL); + else if (flag == "prefetch") + generator.setSilenceSuggestion(SUGGESTION_PREFETCH); else { std::cerr << "Invalid flag to '" << long_options[option_index].name << "': '" << flag << "'" << std::endl; usage();