Files
Ryan Phillips c57813afc3 exclude monotonic memory counters from StatsEq comparison
When cgroup v2 memory.high is active (MemoryQoS beta, on by default in
1.37), the kernel continuously increments reclaim counters (Pgscan,
Pgsteal, WorkingsetRefault*) and MemoryEvents.High in memory.stat.
cadvisor's StatsEq uses reflect.DeepEqual on the full MemoryStats
struct,
so these ever-changing counters prevent housekeeping from backing off
beyond the minimum 1s interval.

The result is ~8x more housekeeping ticks per container than necessary,
causing +40% allocation churn (bufio.Scanner reads of cgroup files, gRPC
buffer pool allocations for CRI calls, cascading volume manager
reconciliation).

Replace the reflect.DeepEqual(a.Memory, b.Memory) call with a
field-by-field comparison that only checks usage-level fields (Usage,
RSS, Cache, WorkingSet, etc.) and ignores monotonic counters, PSI, and
event fields. This allows cadvisor to back off to longer housekeeping
intervals when actual memory usage is stable.

Measured on a 109-pod local cluster (master @ a3589c024aa):
- Before fix: MemoryQoS=ON allocates ~11.3 MB/s (+39% vs OFF)
- After fix:  MemoryQoS=ON allocates ~7.0 MB/s (-13% vs OFF)
2026-10-12 14:03:58 -04:00
..