perf(mining): sample system RAM at most once a second
The Mining tab's memory bar read used system RAM and the wallet's own memory on the UI thread every frame: synchronous OS queries, on Linux an open and parse of /proc/meminfo and /proc/self/status per frame. Both are now sampled at most once a second; the first frame after more than a second idle resamples at once. Total RAM was already cached and daemon RAM already comes from a background sampler. The used-RAM and wallet-memory readings in the bar and its tooltip now refresh at most once a second; what they show is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -307,9 +307,20 @@ void RenderMiningEarnings(App* app, const WalletState& state, const MiningInfo&
|
||||
|
||||
// ---- Memory bar — centered in remaining space below details ----
|
||||
{
|
||||
double totalRAM = dragonx::util::Platform::getTotalSystemRAM_MB();
|
||||
double usedRAM = dragonx::util::Platform::getUsedSystemRAM_MB();
|
||||
double selfRAM = dragonx::util::Platform::getSelfMemoryUsageMB();
|
||||
double totalRAM = dragonx::util::Platform::getTotalSystemRAM_MB(); // cached inside Platform
|
||||
// Used/self RAM are synchronous OS reads (/proc/meminfo + /proc/self/status on Linux): sample them at
|
||||
// most once a second, not every frame. The first frame after >1 s idle resamples immediately.
|
||||
static double s_usedRAM = 0.0, s_selfRAM = 0.0;
|
||||
static int64_t s_ramSampledMs = 0;
|
||||
static bool s_ramSampled = false;
|
||||
if (!s_ramSampled || IntervalElapsed(nowMs, s_ramSampledMs, 1000)) {
|
||||
s_usedRAM = dragonx::util::Platform::getUsedSystemRAM_MB();
|
||||
s_selfRAM = dragonx::util::Platform::getSelfMemoryUsageMB();
|
||||
s_ramSampledMs = nowMs;
|
||||
s_ramSampled = true;
|
||||
}
|
||||
double usedRAM = s_usedRAM;
|
||||
double selfRAM = s_selfRAM;
|
||||
double daemonRAM = app->getDaemonMemoryUsageMB();
|
||||
// Include xmrig memory when pool mining
|
||||
double xmrigRAM = state.pool_mining.memory_used / (1024.0 * 1024.0); // bytes -> MB
|
||||
|
||||
Reference in New Issue
Block a user