perf(vmap): Cache failed VMAP load attempts to prevent repeated retries

Problem: VMAP loading for maps without data (Boost Experience, phased zones,
newer dungeons) was retried on EVERY access, causing:
- Thousands of file access attempts per session
- Log spam with "Could not load VMAP" errors
- Server slowdown from repeated disk I/O

Solution: Added _vmapLoadFailed bitset to TerrainInfo that caches failed
VMAP load attempts, similar to existing _gridFileExists pattern for maps.

Changes:
- TerrainMgr.h: Added _vmapLoadFailed bitset
- TerrainMgr.cpp: Check bitset before load, cache failures, reduce log level

Maps affected: 1949, 1950 (8.0 Boost), 1554, 1557 (7.0 Boost), 1465 (Tanaan),
2648, 2649, 2662, 2669 (TWW dungeons), and others without VMAP data.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Signed-off-by: luis <[email protected]>
This commit is contained in:
agatho
2026-02-02 13:29:41 -03:00
committed by luis
co-authored by Claude Opus 4.5
parent 66ecfc7a2f
commit cfe60008d5
2 changed files with 10 additions and 1 deletions
+9 -1
View File
@@ -222,6 +222,12 @@ void TerrainInfo::LoadVMap(int32 gx, int32 gy)
if (!VMAP::VMapFactory::createOrGetVMapManager()->isMapLoadingEnabled())
return;
// PLAYERBOT FIX: Skip loading if we already know this tile failed
// Prevents repeated file access attempts and log spam for maps without VMAP data
// (e.g., Boost Experience maps, phased zones, newer dungeons)
if (_vmapLoadFailed[GetBitsetIndex(gx, gy)])
return;
switch (VMAP::VMapFactory::createOrGetVMapManager()->loadMap(sWorld->GetDataPath() + "vmaps", GetId(), gx, gy))
{
case VMAP::LoadResult::Success:
@@ -229,7 +235,9 @@ void TerrainInfo::LoadVMap(int32 gx, int32 gy)
break;
case VMAP::LoadResult::VersionMismatch:
case VMAP::LoadResult::ReadFromFileFailed:
TC_LOG_ERROR("maps", "Could not load VMAP name:{}, id:{}, x:{}, y:{} (vmap rep.: x:{}, y:{})", GetMapName(), GetId(), gx, gy, gx, gy);
// PLAYERBOT FIX: Cache the failure to prevent repeated load attempts
_vmapLoadFailed[GetBitsetIndex(gx, gy)] = true;
TC_LOG_DEBUG("maps", "VMAP not available name:{}, id:{}, x:{}, y:{} (vmap rep.: x:{}, y:{}) - will not retry", GetMapName(), GetId(), gx, gy, gx, gy);
break;
case VMAP::LoadResult::DisabledInConfig:
TC_LOG_DEBUG("maps", "Ignored VMAP name:{}, id:{}, x:{}, y:{} (vmap rep.: x:{}, y:{})", GetMapName(), GetId(), gx, gy, gx, gy);
+1
View File
@@ -115,6 +115,7 @@ private:
std::atomic<uint16> _referenceCountFromMap[MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS];
std::array<uint64, MAX_NUMBER_OF_GRIDS> _loadedGrids;
std::bitset<MAX_NUMBER_OF_GRIDS * MAX_NUMBER_OF_GRIDS> _gridFileExists; // cache what grids are available for this map (not including parent/child maps)
std::bitset<MAX_NUMBER_OF_GRIDS * MAX_NUMBER_OF_GRIDS> _vmapLoadFailed; // PLAYERBOT FIX: cache failed VMAP loads to prevent repeated attempts
static constexpr Milliseconds CleanupInterval = 1min;