Files
pulse/internal/monitoring/memory_reclaimable.go
T
rcourtman f62f35e24d memory: restore the v5 reclaimable-cache split end-to-end
v5 modeled memory as used | cache | free (Memory.Cache, 'reclaimable
buff/cache') and the memory bar's tooltip carried a 'Shown in Proxmox'
row explaining why Pulse's percentage reads lower than the Proxmox UI's
cache-inclusive number — a recurring support question. The v6 rebuild
deleted the field from the backend model, so the split and the
reconciliation vanished product-wide. Flagged by the Proxmox overview
parity audit.

Backend: re-add Memory.Cache; split it out via a shared
splitReclaimableMemory helper at the node resolver (node status reports
truly-free directly) and the VM builder (when guest meminfo reported
free pages); transport as proxmox.memoryCache on unified resources
alongside swap/balloon; mock mode populates plausible cache for nodes
and VMs.

Frontend: cache prop on StackedMemoryBar with the v5 muted-amber
segment between active and balloon, tooltip rows for reclaimable cache,
truly-free Free (balloon-capped), and the 'Shown in Proxmox'
reconciliation; guest and node memory adapters normalize free to
truly-free at the boundary; guest and node drawers grow a Reclaimable
cache row; the Proxmox nodes table passes cache and node swap through.
2026-06-11 19:42:40 +01:00

22 lines
853 B
Go

package monitoring
import "github.com/rcourtman/pulse-go-rewrite/internal/models"
// splitReclaimableMemory splits the reclaimable page cache out of a memory
// snapshot whose Free currently holds "available" (Total - Used, with Used
// already excluding cache). trulyFree is the node/guest-reported free page
// count; when it is known and smaller than Free, the gap is reclaimable
// buff/cache and the snapshot becomes used | cache | free, which is what the
// frontend memory bar needs to reconcile Pulse's percentage with the
// cache-inclusive number the Proxmox UI shows.
func splitReclaimableMemory(memory *models.Memory, trulyFree uint64) {
if memory == nil || trulyFree == 0 {
return
}
if memory.Free <= 0 || int64(trulyFree) >= memory.Free {
return
}
memory.Cache = memory.Free - int64(trulyFree)
memory.Free = int64(trulyFree)
}