Which is better for zram & pop os - set to 100% - 200% for zram

is it better to set zram to 200% rather then default 100% in the pop-zram.conf file

iv got 32gb in my current rig & my 2nd build has 64gb an the first will also soon have 64gb too

the default zram settings for pop os is 100%

but im i read this right that it can be set to 200% if so what are the ups an downs of doing so

That would depend on your workload. Zram is used like swap (just with a different priority by default). I use zram mostly during data processing (pandas/python) and I see compression ratios of around 1/4. That means that a full 32gb zram device takes up 8gb of ram. At that point your 32gb of ram would hold 56gb of uncompressed data.

However if you have less/more compressible data that changes. I expect data in RAM will always be quite compressible, the zram devs claim lower than 1/2 is very unlikely.

If you wouldn‘t expect to need more than that there won‘t be an advantage to setting it higher. There is no large drawback to large zram either, except that the kernel might tend to keep stuff around for longer if it sees a large swap space (though that behaviour is tunable too via swappiness and such).

If you really have a strong need for zram you can monitor the use via zramctl, and conclude from there. If not, 100% if probably fine.

Best zram setting is getting more ram in the first place. I like the concept, but from my experience, zram is only used when you run out of memory. Very bad time to suddenly compress stuff. Oh and check on the different compression algorithms. LZ4 is insanely fast while ZSTD really gets you the higher compression ratios. What to take? Entirely depends on how fast your cores are. But having ZSTD as default is a good decision by System76 (though I’d prefer lz4 on a laptop just because of CPU power consumption)

Can’t say anything about that “portion” thing, might be some pop os custom script. Never seen this parameter, although cache pressure and swappiness I used before to tune things.

1 Like

ok thanks for that , 3 questions above is my current settings

1 . that swap is in ram ,not to disk right
2 . when i edit image pixs in krita that are 10000 x 8000 @200dpi tiffs with a 500mg avg file size with 2 - 3
working layers my memory usage goes up to about 70% sometimes more an my available drops to
sometimes less hen 6gb with i have lower usage an more free if i set swapness higher or set zram to
150% or both ?

3 . would this also with downloading an loading games

these are my custom vm settings that for my do me well

sudo sysctl vm.swappiness=90
sudo sysctl vm.page-cluster=2
sudo sysctl vm.dirty_background_ratio=7
sudo sysctl vm.dirty_ratio=28
sudo sysctl vm.vfs_cache_pressure=125
sudo sysctl vm.max_map_count=64000
sudo sysctl vm.watermark_scale_factor=270
sudo sysctl vm.watermark_boost_factor=15000
sudo sysctl vm.zone_reclaim_mode=2
sudo sysctl vm.extfrag_threshold=270
sudo sysctl vm.dirty_expire_centisecs=500
sudo sysctl vm.dirty_writeback_centisecs=500
sudo sysctl vm.min_free_kbytes=200000

what do you think of this config , any suggested tweaks

  1. yes exactly
  2. That is what I would have expected. If zram gets used sooner, a larger portion of memory is compressed thus total use lower.
  3. Tuning is rather complicated in general and dependent on your workload. The most important variables are the compression algorithm and page-cluster. Page-cluster gives a tradeoff of bandwidth vs. latency (0 being lowest latency) and the algorithm gives a tradeoff speed vs. compression ratio (zstd is the best for higher compression, lzo-rle is fastest): See here, Also interesting is this thread of the pop os people.

In general most of this stuff really depends on your workload and you’ll need to benchmark it if you want it optimal. For gaming it probably rarely matters, but I would opt for lzo-rle with page-cluster=0 and same size as ram size and keep a medium swappiness (50-100 or so)

when you say “If zram gets used sooner” that means the swapness right my current swapness is set at 90

should i go higher then or lower then that

Yes that is swappiness (but not ONLY swappiness, other variables are relevant too). IIRC swappiness 0 will only start swapping if RAM is completely full – for higher values it starts swapping older or cache pages sooner.

1 Like

ok i get it thanks

also how do i enable zswap

do i just add zswap.enabled=1 to the pop_os-current.conf file an which is the right way

I don’t use popOS, but you can verify if zram is active by running swapon or zramctl and looking at the output.

htop has meters to show zram and also shows compression. Just run out of memory and you can see zram at work. I now have ZFS ARC shown there, but when using zram I always checked htop for a quick overview. You may have to add the meters via F2 setup menu though

1 Like

i need some advice

after goofing up what ever i did to disable pop os’s zram so much that the command zramctl didnt show any thing

i did this on both my laptop an tower , i know very noob but after finding a old post

that had these commands

sudo zramctl --reset /dev/zram0
sudo zramctl --find --size 8192M --algorithm zstd
sudo mkswap /dev/zram0
sudo swapon -p 1000 /dev/zram0

on my laptop as its got only 16gb of ram an for my tower

i did

sudo zramctl --reset /dev/zram0
sudo zramctl --find --size 16384M --algorithm zstd
sudo mkswap /dev/zram0
sudo swapon -p 1000 /dev/zram0

as its got 32gb

the first attempt on both devices re-activated zram for both just the way i wanted but

after re-boot neither stuck an had to do it over again , but after some tinkering or command

that i dont remember the laptop’s zram now stays after re-boot but i cant get it to stay on

my main tower pc , what do i add or change in or to this to make it stick on re-boot

sudo zramctl --reset /dev/zram0
sudo zramctl --find --size 16384M --algorithm zstd
sudo mkswap /dev/zram0
sudo swapon -p 1000 /dev/zram0

I believe that you need to use the conf files for zram if you want something to persistent after a reboot

1 Like

what an how do i do to make that so an were an what conf file

Should be the same file under /etc

https://wiki.archlinux.org/title/Zram