Handle larger OS page sizes in VM eviction#527
Draft
adsharma wants to merge 1 commit into
Draft
Conversation
Contributor
Author
|
Too risky for the 0.17.0 release. Let's get this in after the release goes out. |
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.
Fixes #526.
Summary
This changes VM eviction to distinguish Ladybug logical frame size from the operating system discard granularity. A build with 4 KiB database pages can run on a kernel with a larger page size, such as 16 KiB, without calling
madviseon a non-OS-page-aligned 4 KiB frame.VMRegionnow detects the runtime OS page size and tracks resident logical frames per discard granule. The buffer manager charges the granule size only when the first logical frame in that granule becomes resident, and frees it only when the last logical frame in the granule is evicted.Root cause
The old VM region layout addressed frames as
region + frameIdx * LBUG_PAGE_SIZEand evicted each frame withmadvise(frame, LBUG_PAGE_SIZE, MADV_DONTNEED). On a 16 KiB kernel page system, only every fourth 4 KiB frame begins on an OS page boundary, somadvisecan fail for the other frames.Aligning the
madviserange outward would be unsafe because the surrounding 16 KiB OS page can contain neighboring logical frames that are still resident or dirty. This change waits until all logical frames in the discard granule are evicted before releasing the underlying OS page.