mirror of
https://github.com/netblue30/firejail.git
synced 2026-05-15 14:16:14 -06:00
[GH-ISSUE #3132] [Feature?] Force process to spend most of its time in swap (zram, cgroups) #1965
Labels
No labels
LTS merge
LTS merge
bug
bug
converted-to-discussion
doc-todo
documentation
duplicate
enhancement
file-transfer
firecfg
firejail-in-firejail
firetools
graphics
help wanted
information_old
installation
invalid
modif
moved
needinfo
networking
notabug
notourbug
old-version
overlayfs
packaging
profile-request
pull-request
question
question_old
removal
runtime-permissions
sandbox-ipc
security
stale
wiki
wiki
wontfix
wordpress
workaround
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/firejail#1965
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ghost on GitHub (Jan 8, 2020).
Original GitHub issue: https://github.com/netblue30/firejail/issues/3132
I want to launch for example, a browser with firejail such that it would spend the majority of its time in swap (and even when used most of it will be in swap since not all its memory pages will be accessed).
My swap is zram which is exceptionally good at compressing text - which browser memory mostly consists of (tests showed a compression factor of 2.5 to 3 with lzo - cat /sys/block/zram0/mm_stat gives numbers to divide for compression factor : make sure some swap is used fist or else the initialized 0 swap doesn't contain meaningful numbers)
Edit: echo $(cat /sys/block/zram0/mm_stat | cut -d" " -f 1) / $(cat /sys/block/zram0/mm_stat | cut -d" " -f 2) | bc -l
So the intention is to force something that is known to be well compressible to be compressed first and delay further necessary compression/decompression of unknown memory - unless you are filling your memory with /dev/urandom it will probably still be nicely compressible but not as much.
Apparently cgroups can be used to limit the memory of processes somehow to achieve this effect. Is there an easy way to do it with firejail, if not then this is a feature request.
zram is ridiculously effective at multiplying your RAM and few desktop users seem to be aware of it. Android makes extensive use of it among other strapped for memory embedded systems, it's mostly arm contributors that were responsible for the kernel feature as I understand it.
For those interested: https://www.kernel.org/doc/Documentation/blockdev/zram.txt or https://www.kernel.org/doc/html/latest/admin-guide/blockdev/zram.html
Extremely easy to set up.
PS: If your kernel is sufficiently new use lzo-rle instead of lzo.
to check, after modprobe: cat /sys/block/zram0/comp_algorithm
also:
vm.overcommit_memory = 1
vm.swappiness = 100
vm.page-cluster = 0
@ghost commented on GitHub (Jan 8, 2020):
Found the answer elsewhere:
and
firejail --cgroup=/sys/fs/cgroup/memory/firejail_browser/tasks
It's certainly swapping so probably works.