main/postmarketos-zram: increase default zram factor/size to 150%
This "size"/factor/percentage represents the total amount of **uncompressed** data that is allowed to be written to the zram-backed swap device. It is **not** the amount of RAM to use for zram swap (as I had previously and erroneously thought.) What this means is that if we set the percent to 50% on a device with 3GB of RAM then up to 1.5GB of *uncompressed* data can be written to it, BUT since compression algos usually do better than a ratio of 1:1... less than 1.5GB of RAM will actually be occupied by this data when it is compressed. A 1.5:1 compression ratio seems relatively safe to assume, even if we use lz4 (which is less "good" at compressing than zstd), so I propose we set the size to 150%. Some distros (PureOS) set this higher (200%), but I think we should be somewhat conservative since we want to avoid any thrashing in case the compression ratio at runtime ends up being less than 2:1 for some reason. This does set a limit of 50% for devices with >32GB of RAM, to reduce overhead with using a larger amount of zram swap. The kernel documentation for zram suggests there's a 0.1% overhead, so if we let this amount get large then it could be tens or hundreds of MB of RAM "wasted." The amount I chose is kinda arbitrary, I think this can be improved later. At the very least, users can change this amount in the deviceinfo variable. Fixes #4250 Signed-off-by: Clayton Craft <craftyguy@postmarketos.org> Part-of: <https://gitlab.postmarketos.org/postmarketOS/pmaports/-/merge_requests/7754>
This commit is contained in:
parent
7aee3f6f58
commit
49b9e02ddf
2 changed files with 7 additions and 10 deletions
|
|
@ -1,6 +1,6 @@
|
|||
maintainer="Clayton Craft <clayton@craftyguy.net>"
|
||||
pkgname=postmarketos-zram
|
||||
pkgver=1
|
||||
pkgver=2
|
||||
pkgrel=0
|
||||
pkgdesc="zram swap configuration for postmarketOS"
|
||||
url="https://postmarketos.org"
|
||||
|
|
@ -27,6 +27,6 @@ package() {
|
|||
sha512sums="
|
||||
ca91be78a47c00f40f3e645f79a72b2cd7ba3f080e2feb256998bb121f64c0394041f2ed822ad307ac36e86398b8175b3284dc5097a7017947e520a304b0a37d postmarketos-zram-swap.initd
|
||||
5c1787bc2d597726113aaf3ea59229b5a56b8fc3446c78406a202e163a0b37ac564a87b2acc1c1f1a7dcdc18ff863c45e13aa687b93fa537c5ef000b9e8d6d19 postmarketos-zram-swap.service
|
||||
798e162f0393621144bfef843fa2f21f9cdfaaa4cd07d4d8b63499f8c3db27d6b9cbb901b43459e5378bd2bb6905f1e371ff915b8e439908944e8030eee7b48e zramstart
|
||||
cc8ae3a0a26aeac7015c5b66c08d76f7d7d4479f20b0876dc14368d6f4ff57a0132bac1f673c194d1b3e1df23660161486123f9691ee4d078a06f328d7246417 zramstart
|
||||
a70d2bcb26c1af42a71811a1c1cd2984808f5ce09d7af52b26824cf5c15c8a9c819691fc6290cf3028226fca39f6e7a495546c5573c582a14d5a8c7c65dbfe3e zramstop
|
||||
"
|
||||
|
|
|
|||
|
|
@ -8,19 +8,16 @@ set -e
|
|||
|
||||
get_size() {
|
||||
# Size defaults to:
|
||||
# - 75% of RAM for devices with 2GB of RAM or less
|
||||
# - 50% of RAM for devices with between 2GB and 6GB of RAM
|
||||
# - 25% of RAM for devices with greater 6GB of RAM
|
||||
# - 150% of RAM for devices with less than 32GB of RAM
|
||||
# - 50% of RAM for devices with greater than 32GB of RAM
|
||||
# This is loosely based on some data here:
|
||||
# https://gitlab.postmarketos.org/postmarketOS/pmaports/-/merge_requests/3752#note_1229631449
|
||||
# https://gitlab.postmarketos.org/postmarketOS/pmaports/-/issues/4250
|
||||
|
||||
local mem_size_mb size_pct
|
||||
mem_size_mb="$(LC_ALL=C free -m | awk '/^Mem:/{print $2}')"
|
||||
|
||||
if [ "$mem_size_mb" -le 2048 ]; then
|
||||
size_pct=75
|
||||
elif [ "$mem_size_mb" -gt 6144 ]; then
|
||||
size_pct=25
|
||||
if [ "$mem_size_mb" -le 32768 ]; then
|
||||
size_pct=150
|
||||
else
|
||||
size_pct=50
|
||||
fi
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue