Tookmund / Swapspace

A fork of Jeroen T. Vermeulen's excellent dynamic swap space manager
GNU General Public License v2.0
139 stars 13 forks source link

Feature/optionally trust mem available #36

Closed rotdrop closed 2 years ago

rotdrop commented 2 years ago

Optionally just use /proc/meminfo MemAvailable

MemTotal:       30773580 kB
MemFree:        10416436 kB
MemAvailable:   15917164 kB
Buffers:             124 kB
...

instead of computing an estimate based on buffers and cached pages.

Tookmund commented 2 years ago

Given the context as presented in the commit introducing MemAvailable I think it would make the most sense to simply detect the presence of MemAvailable and use it in preference to our own calculations instead of introducing another configuration option.

rotdrop commented 2 years ago

Given the context as presented in the commit introducing MemAvailable I think it would make the most sense to simply detect the presence of MemAvailable and use it in preference to our own calculations instead of introducing another configuration option.

Well, I tried to be kind to the rest of the code-basis ;) I can recode the patch accordingly, but I do not know when yet, I'll post any new suggestions here.

Tookmund commented 2 years ago

I appreciate you taking the least invasive approach first and bringing this feature to my attention!

This project simply doesn’t take advantage of a lot of features like this due to its age (pretty sure this didn’t exist when Swapspace was first written), and we’ve already had one known bug in our implementation: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=691128 Replacing it with a kernel-generated value seems like the best approach when it’s available, though I would like to retain the current calculations as a fallback.

Tookmund commented 2 years ago

A slightly-modified version of this PR has now been included in v1.18-beta2 60bfc53c42bfa5e9d8843abc96fb8c0e93ea5f11 There's still some testing and release management that needs to happen on my end, but once it's released I'll close this PR. Thanks for the patch!

Tookmund commented 2 years ago

Committed as 36384ee548cf749f75c5e5d85708030d63818918 and b206267f69188c6d106bbb2aef7ea90a9f871d2f