Skip to content

Commit

Permalink
consider only shrinkable ZFS ARC as cache on Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyam8 authored and BenBE committed May 30, 2022
1 parent 98cbdc6 commit 491c6f1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions linux/LinuxProcessList.c
Original file line number Diff line number Diff line change
Expand Up @@ -1922,6 +1922,7 @@ static inline void LinuxProcessList_scanZfsArcstats(LinuxProcessList* lpl) {

switch (buffer[0]) {
case 'c':
tryRead("c_min", &lpl->zfs.min);
tryRead("c_max", &lpl->zfs.max);
tryReadFlag("compressed_size", &lpl->zfs.compressed, lpl->zfs.isCompressed);
break;
Expand Down Expand Up @@ -1956,6 +1957,7 @@ static inline void LinuxProcessList_scanZfsArcstats(LinuxProcessList* lpl) {

lpl->zfs.enabled = (lpl->zfs.size > 0 ? 1 : 0);
lpl->zfs.size /= 1024;
lpl->zfs.min /= 1024;
lpl->zfs.max /= 1024;
lpl->zfs.MFU /= 1024;
lpl->zfs.MRU /= 1024;
Expand Down
9 changes: 7 additions & 2 deletions linux/Platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,13 @@ void Platform_setMemoryValues(Meter* this) {
this->values[4] = pl->availableMem;

if (lpl->zfs.enabled != 0 && !Running_containerized) {
this->values[0] -= lpl->zfs.size;
this->values[3] += lpl->zfs.size;
// ZFS does not shrink below the value of zfs_arc_min.
unsigned long long int shrinkableSize = 0;
if (lpl->zfs.size > lpl->zfs.min)
shrinkableSize = lpl->zfs.size - lpl->zfs.min;
this->values[0] -= shrinkableSize;
this->values[3] += shrinkableSize;
this->values[4] += shrinkableSize;
}
}

Expand Down
1 change: 1 addition & 0 deletions zfs/ZfsArcStats.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ in the source distribution for its full text.
typedef struct ZfsArcStats_ {
int enabled;
int isCompressed;
unsigned long long int min;
unsigned long long int max;
unsigned long long int size;
unsigned long long int MFU;
Expand Down

0 comments on commit 491c6f1

Please sign in to comment.