You are not logged in.
I'm playing with cgroups to limit the amount of ram available to firefox.
By now, i managed to make it stick with 1GB of ram, then it starts to swap.
While firefox is swapping, the rest of the system slows down a lot, so i'm using zram and the problem is mitigated.
My next step is to try zswap instead.
In my use case, it would give me the advantage of not preallocate a fixed amount of ram, as it manages it dynamically till a maximum you can set.
Finally the question.
Since I rely on the fact that i limit the RSS available to firefox so that when it reaches that values it starts to use the swap in my actual zram; and since zswap does use an intermediary pool to keep compressed pages instead, how limiting the RSS via cgroups would behave?
Does zswap intermediate pool count as VmRSS or VmSwap ?
Thanks!
Last edited by kokoko3k (2019-08-30 11:26:03)
Help me to improve ssh-rdp !
Retroarch User? Try my koko-aio shader !
Offline
I think i've solved that.
I discovered /sys/fs/cgroup/memory/browsers/memory.stat, it is very useful to monitor cgroups; in my case:
#cat /sys/fs/cgroup/memory/browsers/memory.stat |grep -i 'rss\|swap'
rss 760328192
[..]
swap 0you see rss is under 1GB (my upper limit).
while testing zswap, as soon as RSS touches the upper limit, the swap value increases, and so reports "swapon -s"
But /sys/kernel/debug/zswap/stored_pages is still 0.
That means that even if nothing is swapped on disk, the system manages the process as they already swapped, so it just works. Wonderful.
-edit-
If anyone is interested, that's my way to use a browser now:
# echo 1 > /sys/module/zswap/parameters/enabled #load zswap
# echo lz4 > /sys/module/zswap/parameters/compressor #lz4 seems better
# echo z3fold > /sys/module/zswap/parameters/zpool #allow up to 3x page compression
# cgcreate -a koko:koko -t koko:koko -g memory:browsers #make cgroup
echo "2G" | sudo tee -a /sys/fs/cgroup/memory/browsers/memory.limit_in_bytes #limit to 2GB ram
echo 1 > /sys/fs/cgroup/memory/browsers/memory.swappiness #make it swap only when really needed
cgexec -g memory:/browsers /bin/firefox #start firefox into the cgroupOther useful things:
#Monitor compression ratio:
watch 'perl -E "say $(cat /sys/kernel/debug/zswap/stored_pages) * 4096 / $(cat /sys/kernel/debug/zswap/pool_total_size)"'
#Monitor zswap stats
sudo watch grep -R . /sys/kernel/debug/zswap/
#Monitor memory used by browser
watch "cat /sys/fs/cgroup/memory/browsers/memory.stat |grep -i 'rss\|swap'"Last edited by kokoko3k (2019-08-30 11:37:46)
Help me to improve ssh-rdp !
Retroarch User? Try my koko-aio shader !
Offline