hakavlad / le9-patch

[PATCH] mm: Protect the working set under memory pressure to prevent thrashing, avoid high latency and prevent livelock in near-OOM conditions
Creative Commons Zero v1.0 Universal
188 stars 9 forks source link

Testing #4

Open hakavlad opened 3 years ago

hakavlad commented 3 years ago

Put here your results and experience.

tim77 commented 3 years ago

webkit2gtk3 compilation https://youtu.be/U6PbtA1gZvI

ValdikSS commented 3 years ago

I have an old Core2 Duo E4600/2GB RAM/SATA II HDD PC running Linux Mint XFCE 20.2 64 bit.

Case 1

Upon opening many tabs in Firefox, when the RAM consumption reached its max, swapping process was slow and mild thrashing occurred, making system very slow and unresponsive at times, but it did not hang for very long. Switching between running applications took tens of seconds, during which either a blank/black window with no content was present or it took time to just show the application window. Starting new application (xfce calculator, very lightweight) took about 15 seconds. 3 times the mouse pointer froze for 3-6 seconds.

Case 2

Upon opening many tabs in Firefox, when the RAM consumption reached its max, swapping process was fast (it's zram), but due to file cache eviction and slow HDD, switching between applications took a long time and starting new applications also took up to 3 times more than with free RAM. The system was responsive all the time, but uncomfortably slow.

Case 3

Basically the same as in Case 2.

Case 4

Upon opening many tabs in Firefox, the RAM consumption reached about 1.4 GB, then the system started swapping to zram. Switching between applications was as fast as with free RAM. Starting new applications took not much longer than with free RAM (maybe several seconds longer, still much faster than in case 1/2).

Even under VERY heavy RAM load the system was very responsive, although running new applications took much longer (≈2 times), but not as long as in Case 1/2.

The video shows the following applications running simultaneously:

Almost 3 GB in zram swap, so almost 5 GB of real RAM usage with 2 GB of physical RAM. For me, that's an impressive result.

https://user-images.githubusercontent.com/3054729/125176628-a6f49180-e1dd-11eb-834e-6e94776c27bf.mp4

Here's my small note, with ready-to-use LiveCD with le9: https://notes.valdikss.org.ru/linux-for-old-pc-from-2007/en/

ValdikSS commented 3 years ago

There are people who suggest to tune vm.swappiness option. Indeed, you can set it to 200 to give full priority to swapping anonymous pages instead of dropping file cache, but it's not that precise and does not keep enough amount of file cache in near-full RAM cases. It makes things better a bit overall, and is definitely a good choice for SSD, but on HDD it doesn't help that much.

polarathene commented 3 years ago

Indeed, you can set it to 200 to give full priority to swapping anonymous pages instead of dropping file cache, but it's not that precise and does not keep enough amount of file cache in near-full RAM cases.

You don't have to set it all the way to 200, IIRC the docs advise around 133? Depends on context of workloads, but I think there is some merit to not being overly aggressive even if you have zram for swap only.

switching between applications took a long time and starting new applications also took up to 3 times more than with free RAM. Almost 3 GB in zram swap, so almost 5 GB of real RAM usage with 2 GB of physical RAM.

Just wanted to add that if you're too aggressive with zram, in the context of it being filled up it negatively impact responsiveness.

Even when not performing desktop tasks, eg running some long running computation that's heavy on resource usage I have noticed performance suffer when the ratio of RAM allocated to zram is too much, heavy overhead from swap thrashing.

Thus it can be helpful to give the system a bit more breathing room under memory pressure. My tests were on 1GB VPS machines however where 3GB of ZRAM would not necessarily be reached but use up to around 700MB compressed (averaging 2GB uncompressed), but regardless of compressor used, if the amount of RAM ZRAM allocated was lowered and the workload not likely to OOM, it was often notably faster.

I believe due to that scenario I observed disk swap paired with zswap as being more performant. The latency of disk access when required was less of a hit than compressed swap in RAM taking too much. I believe zswap started to suffer after 20-30 percent memory pool size with that workload, otherwise was faster than zram.


I don't know much about le9 yet, but assume it's better handling that situation and will have to measure it some time.

The workload scenario I had could complete in about 10 seconds with 2GB of RAM, but on 1GB system was 2 minutes IIRC, memory load was around 2GB total uncompressed. If I find time to measure again, I will do it again and see how le9 affects it :)

hakavlad commented 3 years ago

the docs advise around 133?

133 in docs is just an example:

For example, if the random IO against the swap device is on average 2x faster than IO from the filesystem, swappiness should be 133 (x + 2x = 200, 2x = 133.33).

https://github.com/torvalds/linux/blob/master/Documentation/admin-guide/sysctl/vm.rst#swappiness

I think that zram is much more than 2 times faster than HDD in most cases.

if you're too aggressive with zram, in the context of it being filled up it negatively impact responsiveness

zram disksize = 4 * MemTotal. No responsiveness issues: https://www.youtube.com/watch?v=1uhcZwuvXLI (with le9).

reneleonhardt commented 3 years ago

zram disksize = 4 * MemTotal. No responsiveness issues: https://www.youtube.com/watch?v=1uhcZwuvXLI (with le9).

Amazing job, just saw it on Phoronix, hope you get lots of testing and reviewing so it can be mainlined soon, millions of computers finally perfectly usable again! 👍

gottaeat commented 3 years ago

if those who ran tests of their own could give this question a read, i'd be very grateful, thank you.

backslashxx commented 10 months ago

Running this on Mi A2 Lite currently. Android 13 / Linux 4.9. Works really nice. Device has 4GB (around 3.5GB usable), ZRAM enabled, 1:1. System keeps up with heavy memory pressure.

image

video6179467927507438481.webm