Add FadvDontNeed option to avoid double pagecache consumption#2095
Add FadvDontNeed option to avoid double pagecache consumption#2095ktock merged 1 commit intocontainerd:mainfrom
Conversation
cache/cache.go
Outdated
| #include <unistd.h> | ||
| #include <errno.h> | ||
| */ | ||
| import "C" |
There was a problem hiding this comment.
stargz snapshotter is imported from other projects as well so cgo should be avoided.
| Direct bool `toml:"direct" default:"true" json:"direct"` | ||
|
|
||
| // FadvDontNeed forcefully clean fscache pagecache for saving memory. Default is false. | ||
| FadvDontNeed bool `toml:"fadv_dontneed" json:"fadv_dontneed"` |
There was a problem hiding this comment.
performance numbers?
Could you please clarify if you would like me to provide additional performance metrics or if you're suggesting that I should include a note on potential performance impacts in the documentation? Forgive me, I'm not entirely sure I understood this comment.
There was a problem hiding this comment.
Sorry for the unclear comment, I meant, how big can we expect the memory saving improvement from this change in the actual workloads?
There was a problem hiding this comment.
Sorry for the unclear comment, I meant, how big can we expect the memory saving improvement from this change in the actual workloads?
In theory, this approach can save up to 50% of memory.
I created a test image containing a 1GB file. The container under test runs a sha512sum operation on this file:
nerdctl run --rm -it --snapshotter stargz $REGISTRY_NAME/$IMAGE_NAME:alpine-1G-esgz sha512sum /bigfile
Meanwhile, in another terminal, I monitored the system's memory information:
watch -n 1 'cat /proc/meminfo | grep -E "Cached"'
Here are the test results, showing a reduction close to 50%:
| fadv_dontneed | before | after | Cached |
|---|---|---|---|
| disable | 852,368 | 3,074,640 | 2,222,272 |
| enable | 852,060 | 2,022,852 | 1,170,792 |
Signed-off-by: abushwang <[email protected]>
Fixes #2093