zfs(openzfs): cap the default ARC at half of RAM for app coexistence - #1487
Draft
gburd wants to merge 1 commit into
Draft
zfs(openzfs): cap the default ARC at half of RAM for app coexistence#1487gburd wants to merge 1 commit into
gburd wants to merge 1 commit into
Conversation
On OSv the ARC and the application share one physical address space. The existing arc_default_max() for a guest with >= 1 GiB of RAM returns MAX(allmem*5/8, allmem-1GiB), which on a large guest is nearly all of RAM (for example ~31 GiB of a 32 GiB guest). A memory-hungry application such as PostgreSQL, with several GiB of shared_buffers plus many concurrent backends, then has almost no headroom, and a burst (a large checkpoint stacking dirty ARC buffers on top of the backends working set) drives the guest out of memory and aborts it. Since OSv ZFS_MODULE_PARAM is a no-op (zfs_arc_max cannot be set at boot), cap the computed default at half of RAM for guests with more than 2 GiB, so the application always keeps at least half the guest memory. Small guests are unchanged (their fractions already leave room). A future zfs_arc_max wired to the boot cmdline could override this. Follow-on to the OpenZFS keystone (cloudius-systems#1423) and the runtime data pool (cloudius-systems#1478). Signed-off-by: Greg Burd <greg@burd.me>
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.
Draft / follow-on to #1423 and #1478.
On OSv the ARC and the application share one physical address space.
arc_default_max()for a guest with >= 1 GiB of RAM returnsMAX(allmem*5/8, allmem-1GiB), which on a large guest is nearly all of RAM (about 31 GiB of a 32 GiB guest). A memory-hungry application such as PostgreSQL (multi-GiB shared_buffers plus many concurrent backends) then has almost no headroom, and a checkpoint burst stacking dirty ARC buffers on top of the backends' working set drives the guest OOM and aborts it. This showed up as an OOM at high concurrency on a 32 GiB guest.Since
ZFS_MODULE_PARAMis a no-op on OSv (zfs_arc_maxcannot be set at boot), this caps the computed default at half of RAM for guests with more than 2 GiB, so the application always keeps at least half the guest's memory. Small guests are unchanged.Draft because the proper long-term fix is to wire
zfs_arc_maxto the boot cmdline so this becomes an overridable default rather than a hard cap; kept as a draft PR so the tuning is not lost while the maintainer reviews the ZFS follow-on stack. Edits the trackedmodules/open_zfs/osv/module/os/osv/zfs/arc_os.cdirectly (the OSv platform layer is now source files on master, not a numbered patch).