-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent Linux Page Cache from hoarding 294GB - 394GB RAM on Execution Nodes #2336
Merged
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
732c9eb
Advise Linux to evict a checkpoint from page cache
fxamacker 6e39e32
Advise Linux to evict all checkpoints at startup
fxamacker bb354a8
Tidy go.mod
fxamacker 15cdac5
Use build tag requiring Linux on EN for fadvise
fxamacker dd7d955
Skip uneeded checks for logger being nil
fxamacker d303663
Merge branch 'master' into fxamacker/drop-file-cache-using-sys
fxamacker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package wal | ||
|
||
import ( | ||
"runtime" | ||
|
||
"golang.org/x/sys/unix" | ||
) | ||
|
||
// fadviseNoLinuxPageCache advises Linux to evict | ||
// a file from Linux page cache. This calls unix.Fadvise which | ||
// in turn calls posix_fadvise with POSIX_FADV_DONTNEED. | ||
// If GOOS != "linux" then this function does nothing. | ||
// CAUTION: If fsync=true, this will call unix.Fsync which | ||
// can cause performance hit especially when used inside a loop. | ||
func fadviseNoLinuxPageCache(fd uintptr, fsync bool) error { | ||
return fadviseSegmentNoLinuxPageCache(fd, 0, 0, fsync) | ||
} | ||
|
||
// fadviseSegmentNoLinuxPageCache advises Linux to evict the | ||
// file segment from Linux page cache. This calls unix.Fadvise | ||
// which in turn calls posix_fadvise with POSIX_FADV_DONTNEED. | ||
// If GOOS != "linux" then this function does nothing. | ||
// CAUTION: If fsync=true, this will call unix.Fsync which | ||
// can cause performance hit especially when used inside a loop. | ||
func fadviseSegmentNoLinuxPageCache(fd uintptr, off, len int64, fsync bool) error { | ||
if runtime.GOOS != "linux" { | ||
return nil | ||
} | ||
turbolent marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
// Optionally call fsync because dirty pages won't be evicted. | ||
if fsync { | ||
_ = unix.Fsync(int(fd)) // ignore error because this is optional | ||
} | ||
|
||
// Fadvise under the hood calls posix_fadvise. | ||
// posix_fadvise doc from man page says: | ||
// "posix_fadvise - predeclare an access pattern for file data" | ||
// "The advice applies to a (not necessarily existent) region | ||
// starting at offset and extending for len bytes (or until | ||
// the end of the file if len is 0) within the file referred | ||
// to by fd. The advice is not binding; it merely constitutes | ||
// an expectation on behalf of the application." | ||
return unix.Fadvise(int(fd), off, len, unix.FADV_DONTNEED) | ||
} |
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
evictFileFromLinuxPageCache
callsposix_fadvise
under the hood. Andposix_fadvise
docs say that it's not binding advice and merely constitutes an expectation on behalf of the application.In benchnet tests, the file is always removed from Linux page cache after calling
evictFileFromLinuxPageCache
.