On Sun, Jun 7, 2020, at 9:30 PM, David Kaufmann wrote:
On Sun, Jun 07, 2020 at 05:25:15PM -0600, Chris Murphy wrote:
>> 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. I've calculated with filling the zram device to the
max, so it will use the full 4G. (the 4G limit was arbitrarily chosen)
A 4G zram device is 4G apparent size. The amount of memory it takes will vary based on the
compression, but in no case take more than 4G memory. The max uncompressed data that can
be put in a 4G zram device is 4G of data.