Re: Fedora 33 System-Wide Change proposal: swap on zram

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Jun 7, 2020 at 7:31 PM David Kaufmann <astra@xxxxxxxx> wrote:
>
> Yes, its a quite boring example, but I've included it for completeness
> as a border case. This is just the few megabytes it needs preallocated,
> whilst swap is not in use at all.

12KiB when not in use?

$ swapon
NAME       TYPE      SIZE USED PRIO
/dev/zram0 partition 3.8G   0B   -2
$ zramctl
NAME       ALGORITHM DISKSIZE DATA COMPR TOTAL STREAMS MOUNTPOINT
/dev/zram0 lzo-rle       3.9G   4K   74B   12K       4 [SWAP]
$

 And for the zram module:

zram                   28672  1


>
> >> At 150% memory usage assuming a 2:1 compression ratio this would mean:
> >> - disk swap:
> >>   has to write 4G to disk initially, and for reading swap another 4G
> >>   (12G total traffic - 4G initial, 4G swapping out and 4G swapping in)
> >> - zram, assuming 4G zram swap:
> >>   has to write 8G to zram initially, and for reading the data swap 16G
> >>   (24G total traffic - 8G initial, 8G swapping out and 8G swapping in)
> >
> > swap contains anonymous pages, so I'm not sure what you mean by
> > initial. Whether these pages are internet or typed in or come from
> > persistent storage - it's a wash between disk or zram swap so it can
> > be ignored.
>
> I was calculating it from the viewpoint of data, e.g. paging out a
> certain amount of data, and paging it in again. "Initial" would be the
> amount of data when paging in.
> What is definitely different is that I thought of 1 or 2 processes
> eating away memory, but not of many thrashing swap. For those it is
> definitely not possible to recover from it once thrashing has started.
>
> > Also I don't understand any of your math,how you start with a 4G zram
> > swap but have 8G. I think you're confused. The cap of 4GiB is the
> > device size. The actual amount of RAM it uses will be less due to
> > compression. The zram device size is not the amount of memory used.
> > And in no case is there a preallocation of memory unless the zram
> > device is used. It is easy to get confused, by the way. That was my
> > default state for days upon first stumbling on this.
>
> I assumed a 2:1 compression rate, so the zram swap holds 8G of data in a
> 4G zram device.

That's not how it works. A /dev/zram0 device size of 4G, means a swap
device size of 4G, and at a 2:1 compression means memory usage is 2G.

If the compression ratio is 1:1, then memory usage is 4G
If the compression ratio is 4:1, then memory usage is 1G


There are more options in sysfs to tweak the behavior of the zram
device, including an option to specifically limit memory use. This is
not used by zram-generator. And I haven't done any testing of it,
because while it could be useful for other applications, I think it
could be bad if there's a hard limit of memory reached before the swap
device is full. I have no idea what kernel behavior is like if swap
claims to be 4G but then just stops accepting writes at 3G. I think it
could mean kernel panic or just bad news. So I haven't gone down this
road.


> > earlyoom will kill in such a case even if you can't. It's configurable
> > and intentionally simplistic, based on memory and swap free
> > percentage.
>
> I don't have any experience with it, as I use the time from slowdown
> until OOM to try to manage the issue myself, usually successful.
> But as mentioned above, I might have a specialized usecase, so my
> experience might not reflect the average users' experience.

earlyoom is enabled by default in Fedora Workstation 32.


-- 
Chris Murphy
_______________________________________________
devel mailing list -- devel@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/devel@xxxxxxxxxxxxxxxxxxxxxxx




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Fedora Announce]     [Fedora Users]     [Fedora Kernel]     [Fedora Testing]     [Fedora Formulas]     [Fedora PHP Devel]     [Kernel Development]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Gimp]     [Yosemite News]

  Powered by Linux