mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Add more Prometheus metrics (#12274)
This commit is contained in:
parent
c2898f53bc
commit
f5a8593b11
10 changed files with 225 additions and 120 deletions
28
src/map.cpp
28
src/map.cpp
|
@ -336,6 +336,7 @@ void Map::timerUpdate(float dtime, float unload_timeout, u32 max_loaded_blocks,
|
|||
u32 saved_blocks_count = 0;
|
||||
u32 block_count_all = 0;
|
||||
|
||||
const auto start_time = porting::getTimeUs();
|
||||
beginSave();
|
||||
|
||||
// If there is no practical limit, we spare creation of mapblock_queue
|
||||
|
@ -377,6 +378,7 @@ void Map::timerUpdate(float dtime, float unload_timeout, u32 max_loaded_blocks,
|
|||
}
|
||||
}
|
||||
|
||||
// Delete sector if we emptied it
|
||||
if (all_blocks_deleted) {
|
||||
sector_deletion_queue.push_back(sector_it.first);
|
||||
}
|
||||
|
@ -395,6 +397,7 @@ void Map::timerUpdate(float dtime, float unload_timeout, u32 max_loaded_blocks,
|
|||
}
|
||||
}
|
||||
block_count_all = mapblock_queue.size();
|
||||
|
||||
// Delete old blocks, and blocks over the limit from the memory
|
||||
while (!mapblock_queue.empty() && (mapblock_queue.size() > max_loaded_blocks
|
||||
|| mapblock_queue.top().block->getUsageTimer() > unload_timeout)) {
|
||||
|
@ -425,6 +428,7 @@ void Map::timerUpdate(float dtime, float unload_timeout, u32 max_loaded_blocks,
|
|||
deleted_blocks_count++;
|
||||
block_count_all--;
|
||||
}
|
||||
|
||||
// Delete empty sectors
|
||||
for (auto §or_it : m_sectors) {
|
||||
if (sector_it.second->empty()) {
|
||||
|
@ -432,7 +436,11 @@ void Map::timerUpdate(float dtime, float unload_timeout, u32 max_loaded_blocks,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
endSave();
|
||||
const auto end_time = porting::getTimeUs();
|
||||
|
||||
reportMetrics(end_time - start_time, saved_blocks_count, block_count_all);
|
||||
|
||||
// Finally delete the empty sectors
|
||||
deleteSectors(sector_deletion_queue);
|
||||
|
@ -1218,7 +1226,12 @@ ServerMap::ServerMap(const std::string &savedir, IGameDef *gamedef,
|
|||
m_savedir = savedir;
|
||||
m_map_saving_enabled = false;
|
||||
|
||||
m_save_time_counter = mb->addCounter("minetest_core_map_save_time", "Map save time (in nanoseconds)");
|
||||
m_save_time_counter = mb->addCounter(
|
||||
"minetest_map_save_time", "Time spent saving blocks (in microseconds)");
|
||||
m_save_count_counter = mb->addCounter(
|
||||
"minetest_map_saved_blocks", "Number of blocks saved");
|
||||
m_loaded_blocks_gauge = mb->addGauge(
|
||||
"minetest_map_loaded_blocks", "Number of loaded blocks");
|
||||
|
||||
m_map_compression_level = rangelim(g_settings->getS16("map_compression_level_disk"), -1, 9);
|
||||
|
||||
|
@ -1594,6 +1607,13 @@ void ServerMap::updateVManip(v3s16 pos)
|
|||
vm->m_is_dirty = true;
|
||||
}
|
||||
|
||||
void ServerMap::reportMetrics(u64 save_time_us, u32 saved_blocks, u32 all_blocks)
|
||||
{
|
||||
m_loaded_blocks_gauge->set(all_blocks);
|
||||
m_save_time_counter->increment(save_time_us);
|
||||
m_save_count_counter->increment(saved_blocks);
|
||||
}
|
||||
|
||||
void ServerMap::save(ModifiedState save_level)
|
||||
{
|
||||
if (!m_map_saving_enabled) {
|
||||
|
@ -1601,7 +1621,7 @@ void ServerMap::save(ModifiedState save_level)
|
|||
return;
|
||||
}
|
||||
|
||||
u64 start_time = porting::getTimeNs();
|
||||
const auto start_time = porting::getTimeUs();
|
||||
|
||||
if(save_level == MOD_STATE_CLEAN)
|
||||
infostream<<"ServerMap: Saving whole map, this can take time."
|
||||
|
@ -1662,8 +1682,8 @@ void ServerMap::save(ModifiedState save_level)
|
|||
modprofiler.print(infostream);
|
||||
}
|
||||
|
||||
auto end_time = porting::getTimeNs();
|
||||
m_save_time_counter->increment(end_time - start_time);
|
||||
const auto end_time = porting::getTimeUs();
|
||||
reportMetrics(end_time - start_time, block_count, block_count_all);
|
||||
}
|
||||
|
||||
void ServerMap::listAllLoadableBlocks(std::vector<v3s16> &dst)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue