feat(init): report workingset_refault_file so the host can right-size this VM#13
Merged
Merged
Conversation
… this VM The VM's memory is elastic — it boots with only part of its RAM online and the rest is hot-plugged in as the workload needs it. That sizing decision is made on the host, from the pressure signals this guest reports. Postgres reports none of them. It is page-cache-bound and reads with read(), not mmap, so when its working set outgrows RAM it does not swap, takes no major faults, and never stalls on reclaim. Measured on a real VM (1.8 GB working set, 735 MiB RAM, scanning continuously): PSI some.avg10 0.00 swap_out 0 major faults/tick 0 Every memory-pressure signal reads zero while the database re-reads its data from disk continuously, so the VM is never grown. Report `workingset_refault_file` from /proc/vmstat alongside PSI in the existing GuestResourceStats (0xA2) frame. A refault is a file page we evicted from the page cache and then had to read back — precisely "the working set does not fit". Measured on the same VM, under identical load: working set FITS (150 MB table) 0 refaults/sec (1002 full scans) working set EXCEEDS (1.8 GB table) 29,002 refaults/sec A healthy database doing a thousand full scans a minute refaults zero times, so the counter cleanly separates "busy" from "starved". It also cannot false-report on streaming reads: a single pass over a large table evicts pages but never re-reads them, producing no refaults at all. The field is optional on the wire, so a host that doesn't consume it is unaffected. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…e test The frame-stability test exists precisely to stop this payload drifting from instd's decoder, and adding a field broke it — it never compiled in the earlier run because `cargo test --bins` doesn't build beyond-pg-init's tests. Extend it rather than just repair it: assert the refault key REACHES the host (it is the only signal that sees this VM outgrow its RAM), assert it is omitted entirely when the kernel doesn't export the counter (rather than sent as a bogus 0, which the host would read as 'no refaults'), and cover the /proc/vmstat parse.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The VM's memory is elastic — it boots with only part of its RAM online and the rest is hot-plugged in as the workload needs it. The host makes that sizing decision from the pressure signals this guest reports.
Postgres reports none of them. It is page-cache-bound and reads with
read(), notmmap, so when its working set outgrows RAM it does not swap, takes no major faults, and never stalls on reclaim.Measured on a real VM (1.8 GB working set, 735 MiB RAM, scanning continuously):
some.avg10swap_outEvery memory-pressure signal reads zero while the database re-reads its data from disk continuously. So the VM never grows, and the DB thrashes indefinitely.
What
Report
workingset_refault_filefrom/proc/vmstatalongside PSI in the existingGuestResourceStats(0xA2) frame.A refault is a file page we evicted from the page cache and then had to read back — precisely "the working set does not fit."
Measured on the same VM under identical load:
A healthy database doing a thousand full scans a minute refaults zero times, so the counter cleanly separates "busy" from "starved". It also can't false-report on streaming reads: a single pass over a large table evicts pages but never re-reads them, so it produces no refaults at all.
The field is optional on the wire, so a host that doesn't consume it is unaffected.
🤖 Generated with Claude Code