Neon vm-monitor机制

Neon vm-monitor机制
核心逻辑1. 读的文件/sys/fs/cgroup/neon-postgres/memory.stat2. 取的字段active_anon inactive_anoncgroup.rs:1683. 不是瞬时值而是最近 5 个样本500ms的平均值cgroup.rs:113-1174. 阈值总内存 ×(1 - 0.15) 总内存的 85%runner.rs:99-1055. 比较当 avg_non_reclaimable threshold 时触发runner.rs:416触发后的动作向 agent 发送 UpscaleRequest 消息runner.rs:446不是直接扩容而是请求。实际是否扩容由 agent 决定。防抖机制两次 UpscaleRequest 之间至少间隔 1 秒runner.rs:423-432否则会静默跳过。一个关键区别你说的 inactive_anon active_anon 是对的但注意 memory.stat 里的值是字节数不是 MB。vm-monitor 读出来后不做转换直接相加比较。总结流程图memory.stat →active_anon inactive_anon↓每 100ms 采样一次保留最近 5 个样本↓计算 5 个样本的平均值 avg_non_reclaimable↓avg_non_reclaimable 总内存 ×0.85 ?↓是发送 UpscaleRequest 给 agent至少间隔 1 秒