Why don't move to zram?

Hello, In base of the next article https://dev.to/archerallstars/lets-fine-tune-your-zram-aka-free-ram-in-opens..., which i found more practical zram for swappiness than the other alternatives. With how most users aren't settings the swap correctly or using the default partition of yast2 of 2 Gb when enabled swap or default template installation guided, it would be good to add to the default packages installed systemd-zram-services, which add the zramswapon with the recommendation from the article and at the same time disable by default swap creating when creating the partition layout in the installation process. This will create a zram of the same size of the ram of the user with compression improve the performance of the machine for those users with low ram, or with a lot of comsunption of ram.

On Thu, Jun 01, Walddys Emmanuel Dorrejo Céspedes wrote:
Hello,
In base of the next article https://dev.to/archerallstars/lets-fine-tune-your-zram-aka-free-ram-in-opens..., which i found more practical zram for swappiness than the other alternatives.
With how most users aren't settings the swap correctly or using the default partition of yast2 of 2 Gb when enabled swap or default template installation guided, it would be good to add to the default packages installed systemd-zram-services, which add the zramswapon with the recommendation from the article and at the same time disable by default swap creating when creating the partition layout in the installation process.
This will create a zram of the same size of the ram of the user with compression improve the performance of the machine for those users with low ram, or with a lot of comsunption of ram.
Using ZRAM and disabling SWAP doesn't make any sense at all. When is ZRAM usefull? In low-memory setup and with very slow harddisks. Do you need SWAP? It depends. Normally, you should have swap, because that's how the kernel is designed to work for. So disabling swap and using ZRAM will not solve this problem, but increase the likelyness, that the kernel calls OOM. And don't forget suspend to disk and similar technologies. In other scenarios (e.g. kubernetes), SWAP is for various reasons forbidden, and ZRAM would make it only worse. So SWAP makes sense, ZRAM makes sense, combining SWAP with ZRAM makes sense, having none of them makes sense, depending on your use case and hardware. The use case "ZRAM instead of SWAP" is very special and will clearly not fit most usecases. Thorsten -- Thorsten Kukuk, Distinguished Engineer, Senior Architect, Future Technologies SUSE Software Solutions Germany GmbH, Frankenstraße 146, 90461 Nuernberg, Germany Managing Director: Ivo Totev, Andrew Myers, Andrew McDonald, Martje Boudien Moerman (HRB 36809, AG Nürnberg)

but more for user case, domestic users are suffering by freeze when they do not have enough RAM and the SWAP 2GB does not adjust for the daily user needs, so implementing zram will be more beneficial for them and a little better image for openSUSE project, in reality at the beginning won't impact the performance of the systems, and neither latter, i have some DB server TW with zram and work perfectly when i have a lot of queries.

On Thu, Jun 01, Walddys Emmanuel Dorrejo Céspedes wrote:
but more for user case, domestic users are suffering by freeze when they do not have enough RAM and the SWAP 2GB does not adjust for the daily user needs, so implementing zram will be more beneficial for them and a little better image for openSUSE project, in reality at the beginning won't impact the performance of the systems, and neither latter, i have some DB server TW with zram and work perfectly when i have a lot of queries.
If 2GB of SWAP are not enough, then you should really think about if the hardware really fits your workload. All of my desktop systems have about 13GB of swap or so (that's what YaST did suggest for suspend to disk), all of my servers have only 2GB swap, if they have swap at all (k8s). No desktop system is using more than 1GB swap, no server is using more than 32MB of swap. And some of the servers do really do memory consuming jobs like building Openstreetmap Maps for Garmin devices... ZRAM wouldn't make any sense in any of this scenarios. If it fits for you, fine. Just install the package. But that it fits for you does not mean it fits in a generic way for everybody else. But it has to do that if we would disable swap and install ZRAM by default. Thorsten -- Thorsten Kukuk, Distinguished Engineer, Senior Architect, Future Technologies SUSE Software Solutions Germany GmbH, Frankenstraße 146, 90461 Nuernberg, Germany Managing Director: Ivo Totev, Andrew Myers, Andrew McDonald, Martje Boudien Moerman (HRB 36809, AG Nürnberg)

On 2023-06-01 18:27, Thorsten Kukuk wrote:
On Thu, Jun 01, Walddys Emmanuel Dorrejo Céspedes wrote:
but more for user case, domestic users are suffering by freeze when they do not have enough RAM and the SWAP 2GB does not adjust for the daily user needs, so implementing zram will be more beneficial for them and a little better image for openSUSE project, in reality at the beginning won't impact the performance of the systems, and neither latter, i have some DB server TW with zram and work perfectly when i have a lot of queries.
If 2GB of SWAP are not enough, then you should really think about if the hardware really fits your workload. All of my desktop systems have about 13GB of swap or so (that's what YaST did suggest for suspend to disk), all of my servers have only 2GB swap, if they have swap at all (k8s). No desktop system is using more than 1GB swap, no server is using more than 32MB of swap. And some of the servers do really do memory consuming jobs like building Openstreetmap Maps for Garmin devices...
I have 64 gigs of ram, and 19 gigs of used swap :-D I hibernate this desktop machine often. I hibernated it last on the 28th, but clearly my workload hasn't needed to recover that memory in days, so it better stays out of my way in disk and frees ram for better needs (there are 14 gig free). Telcontar:~ # free -h total used free shared buff/cache available Mem: 62Gi 35Gi 13Gi 274Mi 14Gi 27Gi Swap: 99Gi 18Gi 81Gi Telcontar:~ # uptime 22:05:45 up 47 days 22:23, 2 users, load average: 0.87, 1.13, 1.00 Telcontar:~ #
ZRAM wouldn't make any sense in any of this scenarios. If it fits for you, fine. Just install the package. But that it fits for you does not mean it fits in a generic way for everybody else. But it has to do that if we would disable swap and install ZRAM by default.
Right. -- Cheers / Saludos, Carlos E. R. (from 15.4 x86_64 at Telcontar)

On Thu, 2023-06-01 at 15:41 +0000, Thorsten Kukuk wrote:
On Thu, Jun 01, Walddys Emmanuel Dorrejo Céspedes wrote:
This will create a zram of the same size of the ram of the user with compression improve the performance of the machine for those users with low ram, or with a lot of comsunption of ram.
Using ZRAM and disabling SWAP doesn't make any sense at all.
Right, I thought the same. And I haven't looked into zram enough to understand properly what it does and how it does it, so I may be talking nonsense. What I can report, though, is that I'm on a Desktop with a lot of RAM and no swap. I, apparently, often manage to eat all of it, and in fact I was experiencing quite a few OOM, with the consequence that the most RAM-hungry apps were being killed. I preferred this to the sluggishness of swap, so I didn't give up to adding it. Then, I decided to try zram. Well, no apps being killed any longer, under no load condition. It is the case that, when RAM pressure is really high, switching the focus to an app that has been in background for a while is a bit slow, as in, the app itself looks stuck for a few moments (but it's quick, and it's only that app, not the entire system, like it usually is with swap). But then everything starts working, with no OOMK involvement.
When is ZRAM usefull? In low-memory setup and with very slow harddisks.
Yeah, again, I thought the same. But it's actually working really really great in my large-memory setup and decent hard-disk. I'll try to collect more data and to understand better why it behaves like that, but I figured I'd share my experience. :-) Regards -- Dario Faggioli, Ph.D http://about.me/dario.faggioli Virtualization Software Engineer SUSE Labs, SUSE https://www.suse.com/ ------------------------------------------------------------------- <<This happens because _I_ choose it to happen!>> (Raistlin Majere)

On Fri, 2023-06-02 at 02:27 +0200, Dario Faggioli wrote:
What I can report, though, is that I'm on a Desktop with a lot of RAM and no swap. I, apparently, often manage to eat all of it, and in fact I was experiencing quite a few OOM, with the consequence that the most RAM-hungry apps were being killed. I preferred this to the sluggishness of swap, so I didn't give up to adding it.
Same here, on machines with 16+ GiB I stopped using swap some time ago. I only once had memory related issues and this was the time where I accidentally started all of my VMs so the memory usage exploded. Neither swap nor zram would have saved me there. Actually I was lying - I still have 32 GiB of swap on my laptop, but with swappiness=0 [1], so effectively no swap unless it is really really really really needed, e.g. if I would be doing hibernation (which I never did so far). Works fine for me, never had the urge to change that setup :-)
When is ZRAM usefull? In low-memory setup and with very slow harddisks.
Exactly. I run a NanoPi Neo [2] with zram where it makes sense because 512MB is really not a lot ... Difficult to tell performance metrics there, but my overall feeling is that it makes the system slightly slower, but it remains usable. Swap on a slow SD-Card would be definitely the worse option.
Yeah, again, I thought the same. But it's actually working really really great in my large-memory setup and decent hard-disk.
I'll try to collect more data and to understand better why it behaves like that, but I figured I'd share my experience. :-)
Regards
Thanks, you motivated me to do the same :-) Best, Felix [1] https://linuxize.com/post/how-to-change-the-swappiness-value-in-linux/ [2] https://wiki.friendlyelec.com/wiki/index.php/NanoPi_NEO#Hardware_Spec

On 2023-06-02 02:27, Dario Faggioli wrote:
On Thu, 2023-06-01 at 15:41 +0000, Thorsten Kukuk wrote:
On Thu, Jun 01, Walddys Emmanuel Dorrejo Céspedes wrote:
This will create a zram of the same size of the ram of the user with compression improve the performance of the machine for those users with low ram, or with a lot of comsunption of ram.
Using ZRAM and disabling SWAP doesn't make any sense at all.
Right, I thought the same. And I haven't looked into zram enough to understand properly what it does and how it does it, so I may be talking nonsense.
What I can report, though, is that I'm on a Desktop with a lot of RAM and no swap. I, apparently, often manage to eat all of it, and in fact I was experiencing quite a few OOM, with the consequence that the most RAM-hungry apps were being killed. I preferred this to the sluggishness of swap, so I didn't give up to adding it.
Then, I decided to try zram. Well, no apps being killed any longer, under no load condition. It is the case that, when RAM pressure is really high, switching the focus to an app that has been in background for a while is a bit slow, as in, the app itself looks stuck for a few moments (but it's quick, and it's only that app, not the entire system, like it usually is with swap). But then everything starts working, with no OOMK involvement.
When is ZRAM usefull? In low-memory setup and with very slow harddisks.
Yeah, again, I thought the same. But it's actually working really really great in my large-memory setup and decent hard-disk.
I'll try to collect more data and to understand better why it behaves like that, but I figured I'd share my experience. :-)
Regards
And this is why I'm seriously considering making zram enabled by default on Aeon Seems like a good choice for the pure desktop OS we're building there, even if Thorsten's points do likely hold true for both the server and the more broad "anything goes" distros.

Dne 02. 06. 23 v 10:32 Richard Brown napsal(a):
On 2023-06-02 02:27, Dario Faggioli wrote:
On Thu, 2023-06-01 at 15:41 +0000, Thorsten Kukuk wrote:
On Thu, Jun 01, Walddys Emmanuel Dorrejo Céspedes wrote:
This will create a zram of the same size of the ram of the user with compression improve the performance of the machine for those users with low ram, or with a lot of comsunption of ram.
Using ZRAM and disabling SWAP doesn't make any sense at all.
Right, I thought the same. And I haven't looked into zram enough to understand properly what it does and how it does it, so I may be talking nonsense.
What I can report, though, is that I'm on a Desktop with a lot of RAM and no swap. I, apparently, often manage to eat all of it, and in fact I was experiencing quite a few OOM, with the consequence that the most RAM-hungry apps were being killed. I preferred this to the sluggishness of swap, so I didn't give up to adding it.
Then, I decided to try zram. Well, no apps being killed any longer, under no load condition. It is the case that, when RAM pressure is really high, switching the focus to an app that has been in background for a while is a bit slow, as in, the app itself looks stuck for a few moments (but it's quick, and it's only that app, not the entire system, like it usually is with swap). But then everything starts working, with no OOMK involvement.
When is ZRAM usefull? In low-memory setup and with very slow harddisks.
Yeah, again, I thought the same. But it's actually working really really great in my large-memory setup and decent hard-disk.
I'll try to collect more data and to understand better why it behaves like that, but I figured I'd share my experience. :-)
Regards
And this is why I'm seriously considering making zram enabled by default on Aeon
Seems like a good choice for the pure desktop OS we're building there, even if Thorsten's points do likely hold true for both the server and the more broad "anything goes" distros.
Agree with Richard. I love zram on desktop computer. I had 16GB and traditional swap on slow SSD (semi broken firmware) and I was forced to buy another 16GB for my development machine. With new notebook, again starting with 16GB only, I tried zram, which I saw as new thing in Fedora workstation. And since then my machine works great with that "low" memory. Zram is default not only on Fedora workstation, but AFAIK macOs uses similar technology, memory compression. I heard from macos users, that theirs computers need less ram than others and it did not make sense for me at that time, but now I agree.

like a lot of expert said, i have a PostgreSQL with 330GB of ram, why it escalate to this size, because the server itself it was hanging up, Tumbleweed Last Snapshot (soon move to Aeon), each time this hang happened i was not getting OOM sadly and have to hard reset sometimes, thanks to btrfs i didn't get corrupted files, but implementing zram have solve my dailies issue and have better experience working with heaving RAM loads with affecting performance of the app.

Hello, I'll add my voice against of zram enabled by default. Prime95 is very often used to stress test CPU and RAM. With zram enabled, when running Prime95 with default options what happens on my system is that it locks up... apparently. Yet there's still HDD light activity. This bit confuses me since zram is swap in RAM... Anyway, with zram disabled, Prime95 attempts to run, GUI locks up and then suddenly it works again and on the console it says it was Killed. Looking at dmesg it looks like oom-killer did it. Interesting bits: 109.726360] process 'user/Downloads/p95v308b17.linux64/mprime' started with executable stack [ 127.444304] Timer invoked oom-killer: gfp_mask=0x140cca(GFP_HIGHUSER_MOVABLE|__GFP_COMP), order=0, oom_score_adj=100 [ 127.444309] CPU: 3 PID: 3204 Comm: Timer Not tainted 6.3.4-1-default #1 openSUSE Tumbleweed dbcadc94672ad614b62b9948e5ed1c48b9a634a1 [ 127.444311] Hardware name: Gigabyte Technology Co., Ltd. Z390 GAMING X/Z390 GAMING X-CF, BIOS F10 11/05/2021 [ 127.444312] Call Trace: [ 127.444314] <TASK> [ 127.444316] dump_stack_lvl+0x43/0x60 [ 127.444320] dump_header+0x4a/0x240 [ 127.444323] oom_kill_process+0xf9/0x190 [ 127.444325] out_of_memory+0x227/0x540 [ 127.444327] __alloc_pages_slowpath.constprop.0+0xc76/0xdc0 [ 127.444332] __alloc_pages+0x329/0x350 [ 127.444335] folio_alloc+0x17/0x50 [ 127.444337] __filemap_get_folio+0x15d/0x340 [ 127.444340] filemap_fault+0x135/0x910 [ 127.444342] ? filemap_map_pages+0x15a/0x640 [ 127.444345] __do_fault+0x30/0x130 [ 127.444347] do_fault+0x1b9/0x410 [ 127.444349] __handle_mm_fault+0x68d/0x1020 [ 127.444353] handle_mm_fault+0x11a/0x310 [ 127.444355] do_user_addr_fault+0x1ba/0x710 [ 127.444358] exc_page_fault+0x6a/0x150 [ 127.444361] asm_exc_page_fault+0x22/0x30 [ 127.444363] RIP: 0033:0x5612719224ee [ 127.444382] Code: Unable to access opcode bytes at 0x5612719224c4. [ 127.444382] RSP: 002b:00007fe97f5bd2a0 EFLAGS: 00010202 [ 127.444384] RAX: 000000000000006e RBX: 00007fe98e2caf78 RCX: 00007fe98e2cafc8 [ 127.444385] RDX: 0000000000000000 RSI: 0000000000000000 RDI: 00007fe98e2caf78 [ 127.444386] RBP: 00007fe97f5bd388 R08: 0000000000000005 R09: 000000000000017e [ 127.444387] R10: 00007fe98e2caf78 R11: 0000000000000246 R12: 00000000252af680 [ 127.444388] R13: 00007fe97f5bd330 R14: 00007fe98e2cafa8 R15: 000000000000007e [ 127.444391] </TASK> [ 127.444651] oom-kill:constraint=CONSTRAINT_NONE,nodemask=(null),cpuset=/,mems_allowed=0,global_oom,task_memcg=/user.slice/user-1000.slice/user@1000.service/app.slice/app-org.gnome.Terminal.slice/vte-spawn-ca8f92d0-1839-4bad-a351-930ba9eb1930.scope,task=mprime,pid=4393,uid=1000 [ 127.444666] Out of memory: Killed process 4393 (mprime) total-vm:30069164kB, anon-rss:28304824kB, file-rss:256kB, shmem-rss:0kB, UID:1000 pgtables:55540kB oom_score_adj:200 [ 129.603466] oom_reaper: reaped process 4393 (mprime), now anon-rss:0kB, file-rss:256kB, shmem-rss:0kB I've also seen the GUI lockup when Steam was doing some patching on a bigger game with zram enabled. I'm using MicroOS with Gnome.
participants (8)
-
Carlos E. R.
-
Daniel Noga
-
Dario Faggioli
-
Felix Niederwanger
-
Richard Brown
-
Silviu C.
-
Thorsten Kukuk
-
Walddys Emmanuel Dorrejo Céspedes