You Run Out of RAM First
On a Proxmox host the thing you run out of is memory. Not cores, not disk. Every guest gets sized for its worst afternoon, most of that memory sits there cold the rest of the week, and the host still has to find all of it the moment the guest touches it.
Intel Optane is the nearest thing to RAM you can plug into an NVMe slot. One of the P4800X swap partitions in this post answered random 4 KiB reads at a queue depth of one in a median of 20 microseconds, 32 at the 99th percentile, with three guests swapping on it at the time. Intel has stopped making them and stopped supporting them1. As such they turn up second-hand.
So this post builds a memory tier out of two of them, under real guests, on a real host.
- Hot pages stay in RAM, up to a limit set per VM.
- Warm pages get compressed in RAM by zswap.
- Cold pages go to the Optane, as swap, at equal priority across both drives.
- A hookscript gives every opted-in VM its own limits, and it takes the RAM share from the VM’s balloon minimum.
On pve2 three Fisher-Price OS (Windows) guests that each think they have 10 GiB are running inside 6 GiB of host RAM apiece. Between half and 71% of what they have given up is sitting on the Optane. The rest is compressed in RAM or was never a real page at all.
The Kit, and Why It Is Swap Not DIMMs
There are two kinds of Optane and only one of them is in this box.
| Optane type | How the OS sees it | As memory |
|---|---|---|
| SSD: P4800X, P5800X, 900P, 905P | an NVMe block device | swap or a backing file, reached through page faults |
| PMem DIMMs: 100 and 200 series | memory in the DIMM slots | Memory Mode, or App Direct onlined as RAM |
The DIMMs need a Xeon Scalable board to sit in: Intel pairs the PMem 100 series with 2nd Gen Xeon Scalable and the 200 series with 3rd Gen2. pve2 is an AMD Ryzen 7 5700G with 58 GiB of DDR4, one socket and one NUMA node, so the DIMM half of this is cited and not tested. Every Optane in it is a P4800X 375 GB, formatted to 4 KiB logical blocks.
| pve2 | |
|---|---|
| CPU | AMD Ryzen 7 5700G, 16 threads, 1 NUMA node |
| RAM | 58 GiB |
| Proxmox VE | 9.2.26, kernel 7.0.14-28-pve, qemu-server 9.2.15, pve-container 6.1.18 |
| Swap | 2 × P4800X 375 GB, one partition each, priority 10 |
| VM disks | six more P4800X as FlashStore OSDs |
| Guests | 3 × Fisher-Price OS (Windows) 11, 10 GiB each; 1 Rocky Linux 10 container |
The 4 KiB format matters more than it looks. A guest page is 4 KiB and so is a logical block. One page out is one block written. Nothing has to be read first so that part of it can be changed.
The guests are Fisher-Price OS (Windows) on purpose. It is what a large share of customers actually run on Proxmox, and it is chatty and wasteful with memory, which is what a memory tier wants to be tested against.
It Will Not Tier Itself
Linux has an answer of its own for slow memory. Give a Linux guest a file-backed virtual NVDIMM, online it with daxctl reconfigure-device --mode=system-ram, and the kernel treats it as a CPU-less NUMA node in a lower tier and demotes cold pages into it. QEMU’s documentation covers the backing file and the unarmed flag that tells the guest the region cannot take persistent writes3. That is cited here, not tested.
The other guest has nothing like it. Microsoft’s own SNIA talk in September 2025 lays out what it has: slower memory exposed as a memory-only NUMA node, either General Purpose, where “No software changes required”, or Specific Purpose, allocated through new APIs, with “preview Windows builds available to try” and “Official support is TBD”4.
General Purpose fills the near node first, spills to the far one and leaves it there. It does not go round finding cold pages and pushing them down.
So can the guest be trusted to tier itself? It cannot. The host has to do it, at 4 KiB, without asking.
The kswapd Objection
The usual answer to “just use host swap” is that it falls over, and the reason given is kswapd.
That is half right. The kernel starts one kswapd per NUMA node that has memory: kswapd_run(nid) inside for_each_node_state(nid, N_MEMORY), a kernel thread named kswapd%d5. pve2 has one node, so it has one kswapd0, and when the whole host runs short that single thread is the queue every guest waits in. One thread. One queue.
The way round it is not to let the whole host run short.
Give each VM a memory.high and the reclaim happens somewhere else. When a task charges memory over its cgroup’s high limit, the kernel flags it, and on the way back to user space that task runs reclaim_high, which calls try_to_free_mem_cgroup_pages on its own cgroup6. The kernel’s own words for what happens past that line: the processes “are throttled and put under heavy reclaim pressure”7.
That moves the cost. It does not remove it. The thread that charges the page is a QEMU thread, often a vCPU, so the VM over its limit pays for its own reclaim inside its own run time. On pve2 one VM booting against a 5 GiB cap logged 3.6 million pages scanned by direct reclaim in its first minute, and kswapd0 scanned none of them.
That is the right place for the cost to land. The VM that wants more memory is the one that pays.
The fix for the stall is proactive reclaim: memory.reclaim takes a size and “is a simple interface to trigger memory reclaim in the target cgroup”7, so a small agent can push cold pages down before a vCPU ever reaches the limit. That agent is the next piece of work and is not in this post.
Why zswap and Not zram
The obvious build is zram at a high priority with the Optane under it. The kernel will use the higher priority first, and swapon(2) says what happens to areas that share one: “pages are allocated on a round-robin basis between them”8.
The trouble is what happens after. Whatever reaches zram first stays there until it is faulted back in or freed. zram fills with the first pages to go cold, which are not the coldest pages for long, and every later eviction goes straight past it to the Optane. Nothing ever moves down.
zswap sits in front of swap and does the opposite. It “evicts pages from compressed cache on an LRU basis to the backing swap device when the compressed pool reaches its size limit”9.
It also has per-cgroup controls, which zram as a block device never will. memory.zswap.max is a hard limit on a cgroup’s compressed pool, and zswap memory is charged to the VM it came from. memory.zswap.writeback decides whether that cgroup’s pages may go on to the swap device at all, and its default is already 17.
One correction to the kernel documentation while we are here. It says “By default, the zswap shrinker is disabled” and that it can be on at boot if CONFIG_ZSWAP_SHRINKER_DEFAULT_ON is selected9. The Proxmox kernel selects it. On 7.0.14-28-pve the shrinker is already Y, zswap itself is off, and the default compressor is lzo.
Building It on pve2
Two Optanes for swap
All eight Optanes in pve2 were FlashStore OSDs holding the VM disks. Two came out of the pool: marked out, drained until ceph osd safe-to-destroy 6 7 agreed, purged, and taken out of ceph.conf. The pool keeps two copies and its 81 GiB sits comfortably on the six left.
Then each drive got one GPT partition of the swap type and went into /etc/fstab at the same priority:
PARTUUID=8678bcc3-e0f4-4a51-84af-cf59871c9d8e none swap sw,pri=10,discard=pages 0 0
PARTUUID=bbf472a8-f785-461b-8e5c-ef533625a309 none swap sw,pri=10,discard=pages 0 0
NAME TYPE SIZE USED PRIO
/dev/nvme6n1p1 partition 349.3G 8.3G 10
/dev/nvme7n1p1 partition 349.3G 8.3G 10
Equal priority means round-robin, and that is what the counters show. With three guests running the two drives held 8,503 MiB and 8,546 MiB.
The 8 GiB pve-swap on the boot drive was switched off for the lab. At priority -1 it would only ever get pages once 700 GiB of Optane was full, but the boot drive takes no lab writes at all, so it is off rather than merely last.
zswap on
At runtime first, so a bad value costs a reboot and nowt else:
echo 1 > /sys/module/zswap/parameters/enabled
grep -r . /sys/module/zswap/parameters/
/sys/module/zswap/parameters/enabled:Y
/sys/module/zswap/parameters/shrinker_enabled:Y
/sys/module/zswap/parameters/max_pool_percent:20
/sys/module/zswap/parameters/compressor:lzo
/sys/module/zswap/parameters/accept_threshold_percent:90
There is no zpool parameter any more; zsmalloc is the only pool on this kernel. To keep it across a reboot, the same thing goes on the kernel command line as zswap.enabled=1, through /etc/kernel/cmdline and proxmox-boot-tool refresh on a systemd-boot node or /etc/default/grub and update-grub on a GRUB one.
The Hookscript
Proxmox has no memory tiering of its own, but every VM already runs in its own cgroup. The VM’s process is moved into a systemd scope named after its ID, so the files live under /sys/fs/cgroup/qemu.slice/<vmid>.scope, and PVE::QemuServer::CGroup returns exactly that path10. Proxmox’s documentation points hookscripts at “various phases of the guests lifetime”11; the source runs pre-start, post-start, pre-stop, post-stop, and post-pci-prepare for passthrough10. post-start is the first point the scope exists, so that is where the limits go.
Where it gets its numbers
A guest opts in with one line in its Notes, optane-tier, and everything else comes from the VM’s own config.
- The RAM share is the balloon minimum. In Proxmox
memory:is the most a VM can have andballoon:is the least it is promised;balloon: 0turns the device off11. When ballooning is on, the minimum is already the figure somebody decided the guest must always have, so the script uses it.dram=in the Notes line is only for a VM with ballooning off. - QEMU overhead is always 2 GiB. QEMU, its threads and the device emulation all sit in the same cgroup as the guest’s RAM, so the limit has to carry them as well.
Notes are stored as # lines at the top of the config. Proxmox writes them through encode_text, which escapes control characters, : and % and leaves = alone12, so optane-tier zswap=1G arrives as plain text.
| File | Formula | VM 104 |
|---|---|---|
memory.high | DRAM share + 2 GiB | 6144M |
memory.max | high + 1 GiB | 7168M |
memory.swap.max | memory − DRAM share + margin (2 GiB) | 8192M |
memory.zswap.max | zswap= from Notes, when given | 1024M |
The script
#!/bin/bash
#
# optane-tier.sh - Proxmox hookscript, puts per-guest memory limits on a VM or
# container so the host pushes its cold pages out to zswap and Optane swap.
#
# Opt a guest in with a line in its Notes:
#
# optane-tier zswap=1G VM with ballooning on, RAM share = balloon min
# optane-tier dram=4G zswap=1G VM with balloon: 0
# optane-tier zswap=512M high=90% container
#
# VM: high = share + 2G for QEMU, max = high + 1G, swap.max = memory - share + 2G
# CT: Proxmox already sets max and swap.max, we only lower high (default 90%)
#
# qm set <vmid> --hookscript local:snippets/optane-tier.sh
# journalctl -t optane-tier
vmid=$1
phase=$2
[ "$phase" = post-start ] || exit 0
log() {
logger -t optane-tier "$vmid: $*"
}
if [ -f /etc/pve/qemu-server/$vmid.conf ]; then
type=vm
conf=/etc/pve/qemu-server/$vmid.conf
cg=/sys/fs/cgroup/qemu.slice/$vmid.scope
elif [ -f /etc/pve/lxc/$vmid.conf ]; then
type=ct
conf=/etc/pve/lxc/$vmid.conf
cg=/sys/fs/cgroup/lxc/$vmid
else
exit 0
fi
# only the live config, not snapshots or [PENDING]
live=$(sed '/^\[/,$d' "$conf")
# a numeric option from the config, e.g. memory: 10240 or memory: current=10240
opt() {
echo "$live" | sed -nE "s/^$1: *(current=)?([0-9]+).*/\2/p"
}
# Notes are the '#' lines, url-encoded by Proxmox
notes=$(echo "$live" | sed -n 's/^#//p' | while read -r l; do printf '%b\n' "${l//%/\\x}"; done)
tier=$(echo "$notes" | grep -m1 -o 'optane-tier.*')
[ -n "$tier" ] || exit 0
# a key=value from the optane-tier line
arg() {
echo "$tier" | grep -oE "$1=[0-9]+[%GgMm]?" | head -1 | cut -d= -f2
}
# 4G / 512M / 512 -> MiB
mib() {
case $1 in
*[Gg]) echo $(( ${1%?} * 1024 )) ;;
*[Mm]) echo ${1%?} ;;
*) echo $1 ;;
esac
}
if [ ! -d "$cg" ]; then
log "no cgroup at $cg"
exit 0
fi
zswap=$(mib "$(arg zswap)")
mem=$(opt memory)
if [ $type = vm ]; then
if [ -z "$mem" ]; then
log "no memory: line in the config, nothing to do"
exit 0
fi
balloon=$(opt balloon)
dram=$(mib "$(arg dram)")
margin=$(mib "$(arg margin)")
margin=${margin:-2048}
# ballooning on: the minimum is what the guest always gets, so use that
if [ -n "$balloon" ] && [ "$balloon" -gt 0 ] && [ "$balloon" -lt "$mem" ]; then
[ -n "$dram" ] && [ "$dram" != "$balloon" ] && log "ignoring dram=$dram, using balloon minimum $balloon"
dram=$balloon
fi
if [ -z "$dram" ]; then
log "no balloon minimum and no dram=, nothing to do"
exit 0
fi
if [ "$dram" -ge "$mem" ]; then
log "share ${dram}M is not below memory ${mem}M, nothing to do"
exit 0
fi
high=$(( dram + 2048 ))
max=$(( high + 1024 ))
swap=$(( mem - dram + margin ))
share=$dram
else
mem=${mem:-512}
swap=$(opt swap)
swap=${swap:-512}
if [ "$swap" -eq 0 ]; then
log "container has no swap, nothing to do"
exit 0
fi
h=$(arg high)
case ${h:=90%} in
*%) high=$(( mem * ${h%\%} / 100 )) ;;
*) high=$(mib "$h") ;;
esac
[ "$high" -lt "$mem" ] || high=$(( mem * 90 / 100 ))
share=$mem
fi
[ -n "$zswap" ] && [ "$zswap" -ge "$share" ] && log "zswap ${zswap}M is not less than the RAM share ${share}M, it comes out of it"
free=$(awk '/^SwapFree/ { print int($2 / 1024) }' /proc/meminfo)
[ "$free" -lt "$swap" ] && log "only ${free}M of host swap free for a ${swap}M allowance, OOM risk"
if [ $type = vm ]; then
echo ${swap}M > $cg/memory.swap.max
echo ${max}M > $cg/memory.max
fi
echo ${high}M > $cg/memory.high
[ -n "$zswap" ] && [ -w $cg/memory.zswap.max ] && echo ${zswap}M > $cg/memory.zswap.max
zs=${zswap:+${zswap}M}
if [ $type = vm ]; then
log "memory ${mem}M share ${dram}M: high ${high}M max ${max}M swap.max ${swap}M zswap.max ${zs:-unset}"
else
log "memory ${mem}M swap ${swap}M: high ${high}M zswap.max ${zs:-unset}"
fi
exit 0
It lives in a snippets directory and gets attached per guest:
pvesm set local --content iso,import,vztmpl,backup,snippets # the whole list: --content replaces it
install -m 0755 optane-tier.sh /var/lib/vz/snippets/
qm set 104 --balloon 4096 --description "optane-tier zswap=1G" \
--hookscript local:snippets/optane-tier.sh
journalctl -t optane-tier
104: memory 10240M share 4096M: high 6144M max 7168M swap.max 8192M zswap.max 1024M
105: memory 10240M share 4096M: high 6144M max 7168M swap.max 8192M zswap.max 1024M
106: memory 10240M share 4096M: high 6144M max 7168M swap.max 8192M zswap.max 1024M
On a cluster the script wants to be on shared storage so every node that might start the VM has it. pve2 is one node, so local it is.
Turning ballooning on is not a live change
On a running VM with balloon: 0, qm set --balloon 4096 only lands in [PENDING], because the balloon device is added when QEMU starts. The script reads the live config above the first section header, so until a full stop and start it keeps using dram=. A reboot from inside the guest is not enough; it keeps the same QEMU process.
What Proxmox Already Writes, and When It Writes It Again
Two things are easy to assume about these files: that a container’s memory.high equals its memory.max, and that Proxmox puts a VM’s limits back whenever it touches the VM. The source says no to both.
| VM | Container | |
|---|---|---|
| Scope or cgroup | qemu.slice/<vmid>.scope | lxc/<ctid> |
memory.max | never written | Memory, at start |
memory.swap.max | never written | Swap, at start |
memory.high | never written | about 99.2% of Memory, at start |
| Rewritten while running | never | on every live Memory or Swap change |
For a VM the scope is created with a slice, a kill mode and CPU properties, and nothing in qemu-server writes a memory limit to it10. What the hookscript sets stays set until the VM stops.
A container is the opposite. Its memory.high comes from calculate_memory_constraints: “1016/1024 (~99.2%) of the ‘max’ hard limit clamped to 128 MiB max”13. That is 2,032 MiB on a 2 GiB container. Not equal.
A live change then goes through change_memory_limit, which writes memory.swap.max if Swap changed and, if Memory changed, writes memory.high and memory.max together14. Checked on container 200:
| CT 200 | memory.high |
|---|---|
pct start, Memory 2048 | 2,032 MiB, set by Proxmox |
hookscript at post-start | 1,843 MiB, 90% |
pct set 200 --swap 3072, live | 1,843 MiB, untouched |
pct set 200 --memory 2560, live | 2,540 MiB, back to 99.2% |
So on a container, change Memory and then run the hookscript by hand with post-start, or the soft limit is gone until the next start.
Where the Swap Really Is
The first reading after boot looks alarming. Three guests capped at 6 GiB and each had 5 to 6 GiB in swap within minutes. Most of that was never on the Optane.
The guest zeroes its free memory, and a page full of zeros is the one page the kernel does not bother writing. swap_writeout checks it first and marks the slot zero in the swap table, before zswap is even tried15; the cgroup counts it as swpout_zero, “zero-filled pages swapped out with I/O skipped”7. In the first minutes after boot the three guests sent 4.8 to 7.2 GiB of zeros out that way.
Most of those came back in as the guests used the memory, and a zero page faulted in comes back from the swap table, not from a drive. Once the guests had settled, the same counters said this:
| VM | In swap | Zero pages | In zswap | On the Optane | zswap ratio |
|---|---|---|---|---|---|
| 104 | 5,549 MiB | 301 MiB (5%) | 1,325 MiB (24%) | 3,923 MiB (71%) | 1.59:1 |
| 105 | 5,884 MiB | 1,126 MiB (19%) | 1,602 MiB (27%) | 3,156 MiB (54%) | 1.62:1 |
| 106 | 5,612 MiB | 820 MiB (15%) | 2,003 MiB (36%) | 2,789 MiB (50%) | 2.00:1 |
Two things follow.
swapon and memory.swap.current both count a zero page as a used slot. Neither number on its own tells you what the drive is carrying; the split above comes from memory.stat, as swpout_zero less swpin_zero for the zeros and zswapped for what zswap holds.
And three identical guests from one template do not compress alike. Earlier the same afternoon the same three read 3.05:1, 1.54:1 and 2.35:1; here they read 1.59:1, 1.62:1 and 2.00:1. One zswap= value for every VM is a guess. Measure each one, more than once.
How Low the Floor Can Go
The first run had VM 104 at balloon: 3072, which with the overhead is a 5 GiB cap.
It did not settle. Not even close. Idle, it pulled 1,039 MiB a minute back off the Optane, and the guest agent stopped answering while it did. At balloon: 4096, a 6 GiB cap, the same guest pulled nothing at all over two minutes.
| VM, idle after boot | Optane swap-in | zswap loads | Memory pressure, 60 s |
|---|---|---|---|
104, balloon: 3072, 60 s | 1,039 MiB | 241 MiB | not sampled |
104, balloon: 4096 | 0 | 0 | 0.12% |
105, balloon: 4096 | 293 MiB | 1,650 MiB | 4.29% |
106, balloon: 4096 | 0 | 3 MiB | 0.11% |
Microsoft’s own minimum for this guest is 4 GB16. That is not a coincidence. The balloon minimum is the figure that says what the guest must always have; set it below what the guest needs to idle and the tier spends its whole life shovelling the same pages up and down.
105 was still busy at the end of the window. It had been off for ten days, and it is the one to look at again.
Ballooning Will Rarely Move
The notes that started this said to keep ballooning on so the guest can choose what to page out itself. The balloon is on, and its minimum is now the RAM share. Whether it ever inflates is another matter.
pvestatd only asks guests to give memory back when the host is over its target. The target is the node’s ballooning-target, 80% unless set, and the goal is the host’s total times that percentage less what is in use17. Proxmox’s own documentation says the same: below the target it “will dynamically add memory to the guest up to the maximum”11.
With every guest held to its cgroup, the host does not get near 80%. pve2 sat at about 30 GiB free with all three running. So the cgroup does the reclaim and the balloon stays put. The guest never gets asked.
That is fine as far as the host is concerned. It is worth knowing if you were counting on the guest to do the choosing.
Containers: zswap On and Off
A container needs less from the script. Proxmox already writes its memory.max and memory.swap.max, so the Optane share is the container’s Swap setting and the script adds a soft memory.high and the zswap limit.
Container 200, Rocky Linux 10, Memory 2,560 MiB, Swap 3,072 MiB, soft limit 2,304 MiB, and a load that allocates 4 GiB in 64 MiB chunks, half repeated request lines and half random bytes, holds it for 30 seconds and then reads every page back:
| CT 200, 4 GiB into 2.5 GiB | zswap on, 512 MiB | zswap off |
|---|---|---|
| allocate 4 GiB | 20.2 s | 10.8 s |
| read every page back | 21.4 s | 16.2 s |
| zswap ratio | 2.04:1 | |
memory.high events | 16,454 | 13,312 |
| OOM kills | 0 | 0 |
zswap made this slower. On this load it would. The working set is bigger than the cap, so every page is compressed, held briefly and then written to the Optane anyway; half of them are random and do not compress at all. That is zswap’s worst case, and it is in here because it is a real one. A guest whose hot set fits in its share and whose cold set stays cold is the case zswap is for.
Six more runs of the same load with zswap on, three with lzo and three with zstd, alternating, each on a freshly restarted container, did not separate the two. Allocation took 16.4 to 20.9 s and the read-back 22.9 to 29.2 s whichever was set, and the ratio sat between 1.98:1 and 2.02:1 in all six. Half this load is random and the other half repeats one line, so any compressor gets the same answer. Real pages are in the next section.
Two of those six were killed by the OOM killer, one with each compressor. Both times the kernel’s own record has the container’s swap full to the kilobyte:
memory: usage 2837828kB, limit 2621440kB, failcnt 54380
swap: usage 3145728kB, limit 3145728kB, failcnt 1054
Memory cgroup out of memory: Killed process 55081 (python3) total-vm:4210740kB
On paper this load overflows Memory by about 1.7 GiB, and the 3 GiB Swap allowance still filled. The container’s Swap setting is a hard ceiling. Give it room to spare, not the arithmetic.
Not yet measured. The on and off runs are one each. Repeats, and the same load with a hot set that fits, are to run before these numbers are final.
lzo or zstd
zswap compresses every page on its own, 4 KiB at a time, so the fair test of a compressor is real guest pages fed through it one at a time. The QEMU monitor’s pmemsave copied four 256 MiB stretches of guest memory out of each of the three running guests, 1 GiB apiece, and every page was compressed with the settings the kernel uses: zstd at level 3, which is ZSTD_DEF_LEVEL in the kernel’s crypto driver18, and lzo1x-119. Zero-filled and same-filled pages were left out, because they never reach zswap, and a page that did not come out smaller than 4 KiB counts as rejected.
| 1 GiB of real pages | lzo | zstd | rejected, lzo → zstd | compress per page, lzo / zstd | decompress per page, lzo / zstd |
|---|---|---|---|---|---|
| VM 104 | 1.87:1 | 2.23:1 | 15.6% → 10.6% | 6.7 / 19.2 µs | 5.0 / 6.8 µs |
| VM 105 | 1.96:1 | 2.41:1 | 20.1% → 17.7% | 5.8 / 18.0 µs | 4.7 / 6.5 µs |
| VM 106 | 1.92:1 | 2.30:1 | 21.2% → 17.1% | 5.8 / 17.8 µs | 4.7 / 6.3 µs |
zstd gets a fifth more into the same pool, and it keeps more pages off the Optane altogether. It costs three times the CPU on the way in and about a third more on the way out. The timings are Python on one core, so they compare the two; they are not the kernel’s figures.
Is that CPU worth spending? On the way out of zswap, yes, easily. A zstd decompress at under 7 µs is a third of the Optane’s 20 µs median read, and every page zstd keeps in the pool is one that never needs that read. On the way in it costs a vCPU’s time when the guest is over its limit, and on a host already short of cores that is the one place lzo still wins.
Through zswap itself the answer points the same way, on a small sample. The three guests were restarted with each compressor in turn, twice, left six minutes to settle, then watched for three more and read from their own cgroups:
| zswap ratio, idle after boot | VM 104 | VM 105 | VM 106 |
|---|---|---|---|
| zstd, round 1 | 4.40:1 | 3.09:1 | 3.11:1 |
| lzo, round 1 | 2.90:1 | 3.50:1 | 3.71:1 |
| zstd, round 2 | 5.30:1 | 5.72:1 | 5.77:1 |
| lzo, round 2 | 3.32:1 | 3.45:1 | 4.12:1 |
zstd averaged 4.57:1 across the six against 3.50:1 for lzo, and lost two of the six pairs. An idle guest only puts 150 to 275 MiB of real pages through zswap in that time, and nothing reached or left the Optane in any of the three-minute windows, so this says little about cost. The gigabyte per guest above is the better measure of the ratio.
Not yet measured. The same comparison with the three guests under load, where the pool fills and the Optane gets used.
Three Guests Under Load
Not yet measured. A 5 GiB load inside all three guests at once, the same mix as the container, with host swap-in and guest paging sampled every two seconds; then the same with zswap off; then repeats of both. The guest agent on 105 and 106 is the prerequisite.
Double Paging
Double paging is the fault everyone mentions when host swap comes up. The paper that measured it calls it “an often-cited, if unsubstantiated, problem in multi-level scheduling of memory between virtual machines (VMs) and the hypervisor”, and could only show its cost on a synthetic benchmark20.
It goes like this. The host moves a cold page to the Optane. Later the guest runs short itself and picks that same page for its page file. The host has to read it back off the Optane so the guest can write it to the VM disk. One read and one write, for a page nobody actually wanted.
zswap changes the second half. Once the page has been read back, its next eviction goes into the zswap pool as the newest entry, and the pool writes back from the oldest end. So it does not ping-pong straight back to the Optane. What zswap cannot do is avoid the first read: if the page is on the Optane when the guest wants it, it comes off the Optane.
The guest keeps its own page file for good reason. The system commit limit “is the sum of physical memory and all page files combined”, and when commit charge reaches it “the system and processes might not get committed memory”21. A page file or a dedicated dump file “might still be required to back a system crash dump”21. On pve2 that page file is 640 MiB, system managed, on the VM disk on FlashStore.
So the design rule is to size the guest’s Memory for its own peak, so it rarely pages itself, and let the host handle what is cold.
Not yet measured. The signature to look for is the guest’s Pages Output/sec rising while the host’s swap-in for the same VM rises with it. That comparison runs with the three-guest load.
If the Optane Were in the DIMM Slots
Everything above uses the SSD, so every trip down a tier is a page fault and a 4 KiB block. Optane PMem is the same media on a DIMM, and it can sit under a guest three ways. None of this was tested; pve2 has no slot for it.
As swap. A PMem namespace is a block device, so mkswap takes it like the Optane partitions above. ndctl’s sector mode exists because PMem, “given that it is byte addressable, does not support sector atomicity”, and puts a Block Translation Table in front of it22, which “provides atomic sector update semantics”23. Swap does not need that. Its contents are thrown away at every boot, so a torn sector on power loss costs nothing, and the table is one more lookup on every page. It works, and it is still the swap path: a fault, a slot, a copy through the block layer.
As a memory node. A devdax namespace reconfigured with daxctl reconfigure-device --mode=system-ram comes up as ordinary RAM on a CPU-less NUMA node of its own24. With /sys/kernel/mm/numa/demotion_enabled set, reclaim moves pages from the fast tier to the slow one instead of swapping them, and “This migration is performed before swap if an eligible numa node is present”25. No fault, no block layer. The page is copied from one kind of memory to another, and the guest reads it in place afterwards.
That is the route that fits this post, because the hookscript does not change. Reclaim inside a cgroup has demoted as well as reclaimed since a 2022 commit that put it back26, so the same memory.high that pushes a VM’s cold pages into zswap and onto the Optane would push them onto the PMem node first. The tiers become DRAM, then PMem, then zswap and the Optane under that.
Memory Mode. Set in the firmware, it hides PMem behind DRAM: “the CPU memory controller sees all of the Intel Optane PMem 200 series as volatile system memory (without persistence)”2. Nothing to configure in Linux and nothing per VM either. The DRAM is a cache the host does not control, and it is the whole host or nothing.
PMem went the same way as the SSDs. The 100 series reached end of life on 29th June 2023 and end of interactive support on 30th June 2025; the 200 series reached end of life on 26th June 20241.
What Was Not Tested
| Status | |
|---|---|
| Optane PMem as swap, as a memory node or in Memory Mode | cited, in the section above; needs a 2nd or 3rd Gen Xeon Scalable board |
| Linux guest with a file-backed vNVDIMM as RAM | cited from the QEMU documentation3 |
| Live migration | needs a second node. Pre-copy reads every page, so swapped pages come back in on the source first |
| HA recovery | needs a cluster. The hookscript reapplies limits at every start, but the script must exist on every node |
Proactive reclaimer driven by memory.pressure | next piece of work |
zswap.enabled=1 from the kernel command line | not rebooted with it yet |
Memory You Already Paid For
None of this is new. Swap is older than most of the people who will tell you not to use it, and cgroups have been in the kernel long enough that Proxmox puts every guest in one without being asked.
What is new is that it has stopped being a bad idea. Swap earned its reputation on spinning disks, where a page fault cost ten milliseconds and one queue served the whole machine. Neither is true here. The drive answers in microseconds, and the queue is per VM because we told the kernel to make it per VM.
So the question is not whether host swap is respectable. It is what the RAM you are buying is actually doing. Most of it, most of the time, is holding pages nobody has touched since Tuesday, and the price of a DIMM slot does not care whether the page in it is hot.
The drives that do this job went end of life in March 2024. Intel has walked away from them, the second-hand market is full of them, and they will do this work for years yet. There is no subscription to it, no licence and no feature flag. It is a kernel parameter, two lines in fstab and a hundred-odd lines of shell, and it is yours.
Intel — Discontinued Intel Optane products and support options — P4800X Series (2.5in) “EOL: March 22, 2024 / EOIS: December 31, 2024”; P5800X Series “EOL: March 22, 2024 / EOIS: December 31, 2025”; Optane Persistent Memory 100 Series “EOL: June 29, 2023”, “EOIS: June 30, 2025”; 200 Series “EOL: June 26, 2024”; “Products that have reached their End of Interactive Support (EOIS) no longer have technical support available through Intel Customer Support.” ↩︎ ↩︎
Intel — Intel Optane Persistent Memory 200 Series product brief — PMem 100 series with “2nd Generation Intel® Xeon® Scalable processors on 2S/4S/8S platform”, PMem 200 series with “3rd Generation Intel Xeon Scalable processors”; “In Memory Mode, the CPU memory controller sees all of the Intel Optane PMem 200 series as volatile system memory (without persistence).” ↩︎ ↩︎
QEMU — docs/nvdimm.txt — a vNVDIMM backed by
memory-backend-filewithmem-path; “When using other types of backends, it’s suggested to set ‘unarmed’ option of ‘-device nvdimm’ to ‘on’, which sets the unarmed flag of the guest NVDIMM region mapping structure.” ↩︎ ↩︎Microsoft — CXL Memory in Windows, SNIA SDC 2025 — General Purpose memory as a “Memory-only Non-Uniform Memory Architecture (NUMA) node”, “No software changes required”; Specific Purpose memory allocated through new APIs; VMs can be given either; “preview Windows builds available to try”; “Official support is TBD”. ↩︎
Linux kernel source — mm/vmscan.c —
kswapd_run(int nid)creates the thread withkthread_create_on_node(kswapd, pgdat, nid, "kswapd%d", nid), andkswapd_init()calls it insidefor_each_node_state(nid, N_MEMORY). ↩︎Linux kernel source — mm/memcontrol.c — a charge over the high limit adds to
current->memcg_nr_pages_over_highand callsset_notify_resume(current);reclaim_high()then callstry_to_free_mem_cgroup_pages()on the cgroup and its parents. ↩︎Linux kernel documentation — Control Group v2 —
memory.high: “the processes of the cgroup are throttled and put under heavy reclaim pressure. Going over the high limit never invokes the OOM killer”;memory.reclaim: “This is a simple interface to trigger memory reclaim in the target cgroup”;memory.zswap.max: “If a cgroup’s zswap pool reaches this limit, it will refuse to take any more stores”;memory.zswap.writeback: “The default value is “1"”;swpout_zero: “Number of zero-filled pages swapped out with I/O skipped due to the content being detected as zero.” ↩︎ ↩︎ ↩︎ ↩︎swapon(2) — Linux manual page — “Higher numbers mean higher priority. If two or more areas have the same priority, and it is the highest priority available, pages are allocated on a round-robin basis between them.” ↩︎
Linux kernel documentation — zswap — “Zswap evicts pages from compressed cache on an LRU basis to the backing swap device when the compressed pool reaches its size limit”; “By default, the zswap shrinker is disabled”; it “can be enabled at the boot time if CONFIG_ZSWAP_SHRINKER_DEFAULT_ON is selected”. ↩︎ ↩︎
Proxmox qemu-server — src/PVE/QemuServer.pm —
enter_systemd_scope($vmid, ...)for the VM process;exec_hookscriptforpre-start,post-start,pre-stop,post-stopandpost-pci-prepare; theballoonoption, “The balloon driver is enabled by default, unless it is explicitly disabled by setting the value to zero”;#lines parsed as the description. The scope path is insrc/PVE/QemuServer/CGroup.pm,"qemu.slice/$vmid.scope/". ↩︎ ↩︎ ↩︎Proxmox VE documentation — QEMU/KVM Virtual Machines — “When setting the minimum memory lower than memory, Proxmox VE will make sure that the minimum amount you specified is always available to the VM, and if RAM usage on the host is below a certain target percentage, will dynamically add memory to the guest up to the maximum memory specified. The target percentage defaults to 80%”; hookscripts are “called during various phases of the guests lifetime”. ↩︎ ↩︎ ↩︎
Proxmox pve-common — src/PVE/ParseUtils.pm —
encode_textescapes “all control and hi-bit characters, ‘:’ and ‘%’”. ↩︎Proxmox pve-container — src/PVE/LXC/Config.pm —
calculate_memory_constraints: “Set the high to 1016/1024 (~99.2%) of the ‘max’ hard limit clamped to 128 MiB max”; a live Memory or Swap change callschange_memory_limit. ↩︎Proxmox pve-common — src/PVE/CGroup.pm —
change_memory_limitwritesmemory.swap.maxwhen given, andmemory.highthenmemory.maxwhen the memory size is given. ↩︎Linux kernel source — mm/page_io.c — “Use the swap table zero mark to avoid doing IO for zero-filled folios”;
is_folio_zero_filled()is checked beforezswap_store(). ↩︎Microsoft — Windows 11 specifications — system requirements, RAM: “4 gigabytes (GB)”. ↩︎
Proxmox pve-manager — PVE/Service/pvestatd.pm —
auto_ballooning: “try to keep host memory usage at a certain percentage (= target), default is 80%”,$config->{'ballooning-target'} // 80. ↩︎Linux kernel source — crypto/zstd.c —
#define ZSTD_DEF_LEVEL 3, used forzstd_get_params(ZSTD_DEF_LEVEL, ZSTD_MAX_SIZE). ↩︎Linux kernel source — crypto/lzo.c — compression is
lzo1x_1_compress_safe(). ↩︎Arya, Baskakov and Garthwaite — Tesseract: Reconciling Guest I/O and Hypervisor Swapping in a VM, VEE 2014 — “Double-paging is an often-cited, if unsubstantiated, problem in multi-level scheduling of memory between virtual machines (VMs) and the hypervisor”; “We present results using a synthetic benchmark that show, for the first time, the cost of the double-paging problem.” ↩︎
Microsoft Learn — Introduction to the page file — “The system commit memory limit is the sum of physical memory and all page files combined”; “If the system commit charge reaches the system commit limit, the system and processes might not get committed memory”; “a page file or a dedicated dump file might still be required to back a system crash dump.” ↩︎ ↩︎
ndctl — ndctl-create-namespace — “sector”: “persistent memory, given that it is byte addressable, does not support sector atomicity”, “(also known as “safe” or “btt” mode)”; “devdax”: “The device-dax character device interface is a statically allocated / raw access analogue of filesystem-dax”. ↩︎
Linux kernel documentation — BTT, Block Translation Table — “The Block Translation Table (BTT) provides atomic sector update semantics for persistent memory devices, so that applications that rely on sector writes not being torn can continue to do so.” ↩︎
ndctl — daxctl-reconfigure-device —
daxctl reconfigure-device --mode=system-ramhot-plugs the device as system RAM on its owntarget_node, onlined as movable “so that kernel data doesn’t make it into this memory”. ↩︎Linux kernel ABI — /sys/kernel/mm/numa/demotion_enabled — “Allowing page migration during reclaim enables these systems to migrate pages from fast tiers to slow tiers when the fast tier is under pressure. This migration is performed before swap if an eligible numa node is present in cpuset.mems for the cgroup”. ↩︎
Linux kernel commit 3f1509c57b1b — Revert “mm/vmscan: never demote for memcg reclaim” — Johannes Weiner, May 2022; a later commit message summarises it: since this revert “the proactive reclaim interface memory.reclaim does both reclaim and demotion”. ↩︎