mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-24 08:00:14 +00:00
Add dynamic memory-based asset caching and aggressive loading
- Add MemoryMonitor class for dynamic cache sizing based on available RAM - Increase terrain load radius to 8 tiles (17x17 grid, 289 tiles) - Scale worker threads to 75% of logical cores (no cap) - Increase cache budget to 80% of available RAM, max file size to 50% - Increase M2 render distance: 1200 units during taxi, 800 when >2000 instances - Fix camera positioning during taxi flights (external follow mode) - Add 2-second landing cooldown to prevent re-entering taxi mode on lag - Update interval reduced to 33ms for faster streaming responsiveness Optimized for high-memory systems while scaling gracefully to lower-end hardware. Cache and render distances now fully utilize available VRAM on minimum spec GPUs.
This commit is contained in:
parent
27d0496894
commit
c047446fb7
12 changed files with 198 additions and 19 deletions
51
src/core/memory_monitor.cpp
Normal file
51
src/core/memory_monitor.cpp
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
#include "core/memory_monitor.hpp"
|
||||
#include "core/logger.hpp"
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <sys/sysinfo.h>
|
||||
|
||||
namespace wowee {
|
||||
namespace core {
|
||||
|
||||
MemoryMonitor& MemoryMonitor::getInstance() {
|
||||
static MemoryMonitor instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
void MemoryMonitor::initialize() {
|
||||
struct sysinfo info;
|
||||
if (sysinfo(&info) == 0) {
|
||||
totalRAM_ = static_cast<size_t>(info.totalram) * info.mem_unit;
|
||||
LOG_INFO("System RAM detected: ", totalRAM_ / (1024 * 1024 * 1024), " GB");
|
||||
} else {
|
||||
// Fallback: assume 16GB
|
||||
totalRAM_ = 16ull * 1024 * 1024 * 1024;
|
||||
LOG_WARNING("Could not detect system RAM, assuming 16GB");
|
||||
}
|
||||
}
|
||||
|
||||
size_t MemoryMonitor::getAvailableRAM() const {
|
||||
struct sysinfo info;
|
||||
if (sysinfo(&info) == 0) {
|
||||
// Available = free + buffers + cached
|
||||
return static_cast<size_t>(info.freeram) * info.mem_unit;
|
||||
}
|
||||
return totalRAM_ / 2; // Fallback: assume 50% available
|
||||
}
|
||||
|
||||
size_t MemoryMonitor::getRecommendedCacheBudget() const {
|
||||
size_t available = getAvailableRAM();
|
||||
// Use 80% of available RAM for caches (very aggressive), but cap at 90% of total
|
||||
size_t budget = available * 80 / 100;
|
||||
size_t maxBudget = totalRAM_ * 90 / 100;
|
||||
return budget < maxBudget ? budget : maxBudget;
|
||||
}
|
||||
|
||||
bool MemoryMonitor::isMemoryPressure() const {
|
||||
size_t available = getAvailableRAM();
|
||||
// Memory pressure if < 20% RAM available
|
||||
return available < (totalRAM_ * 20 / 100);
|
||||
}
|
||||
|
||||
} // namespace core
|
||||
} // namespace wowee
|
||||
Loading…
Add table
Add a link
Reference in a new issue