-
-
Notifications
You must be signed in to change notification settings - Fork 248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Zram can be configured more optimally by using lz4 instead of zstd1 #1570
Comments
Thanks! Will be digging into this more, but for now: |
This should help a lot with understanding and tweaking various Virtual Memory settings @KyleGospo : https://gist.github.com/ahydronous/7ceaa00df96ef99131600edd4c2c73f2 |
QuestionWhat is (more) preferred?
My answerFocus on lower latency without regression in bandwidth efficiency. What are the best configuration values?That generally depends on each PC configuration & usage scenario. With the current approach, we cannot satisfy every usage scenario & PC configuration, because custom values are statically written only once during boot. ExamplesIt is desirable to want more ZRAM swapiness during heavy usage scenario (bandwidth efficiency), It is desirable to want ZSTD ZRAM compression for low-RAM configurations (bandwidth efficiency), etc, feel free to show more examples. ImplementationI looked through @ahydronous's gist & I applied all values from there (except swapiness, where I use 180), to my custom image. Here's how that looks: Memory tweaks: Dirty centisecs: You can notice that MaxPerfWiz tries to adjust some dynamic memory values to be as ideal as possible for all configurations, like
This can be improved further. Tuned can also dynamically change |
As Bazzite is now shipping with TuneD, I took the liberty of creating a configuration for it with the values linked above; based on the TuneD balanced profile, for testing purposes. Do note that these values are relevant to this hardware specific setup - so, 16GB of RAM and a CPU with 16 threads:
|
Would it be possible to use a TuneD profile to adapt things like the algorithm and swappiness based on system specs? |
I believe the way dynamic tuning works with TuneD might be coded into it directly, can't seem to find any word on configuring it. It's mainly meant for things like changing the CPU governor and things of that sort that change with system load, from what I gather. |
Describe the bug
Zram is currently configured to use zstd1, which is suboptimal
What did you expect to happen?
I've spent an inordinate amount of time optimizing zram on my system.
Benchmarks on
zstd-1
vslz4
https://www.reddit.com/r/Fedora/comments/mzun99/new_zram_tuning_benchmarks/
An explanation of vm.swappiness
https://docs.kernel.org/admin-guide/sysctl/vm.html#swappiness
https://stackoverflow.com/questions/72544562/what-is-vm-swappiness-a-percentage-of
Overcommitting memory (zram being bigger than RAM size) is good
https://issuetracker.google.com/issues/227605780
Gathered wisdoms
IOPS benchmark on Samsung 970 EVO Plus 1TB
Compression ratios on mixed data
This is very relevant for the Deck, because <12GB is right where in a lot of scenarios the benefits of extra memory from
zstd1
start to outstrip the latency benefits oflz4
.Valve probably has a lot of profiled data, but as far as I've been able to tell, even the heaviest games don't go much over 4GB of VRAM.
Swappiness
Swappiness can be derived via formula. On kernel.org, they state
You can reduce that to
(yx = 200 -x)
, wherey
is filesystem-to-swap IO ratio.With the 970 Evo Plus as example again, we have aforementioned read IOPS values.
970EVO vs. lz4 = 15 300 / 2 030 000 = 0.008
, so0.008
is our ratio.We plug that in,
0.008x = 200 -x = 198.4
, and we getvm.swappiness=198
.Page clusters
These are logarithmic. With zram, you get noticeable latency improvements with 1 page,
vm.page-cluster=0
Writeback device (backing swap partition)
https://www.kernel.org/doc/html/v5.9/admin-guide/blockdev/zram.html#writeback
Remember how I mentioned still needing a swapfile?
Here is where it gets slightly more convoluted.
cron
or perhaps asystemd
service. This will also need a writeback limit set to prevent wearing out SSDs, especially the 64GB eMMC Deck.Two links about configuring page eviction with writeback:
RFE: Actually use the writeback device systemd/zram-generator#164
https://android.googlesource.com/platform/frameworks/base/+/master/services/core/java/com/android/server/ZramWriteback.java
Extra
There is also secondary algorithm recompression, although I have not yet tried this out and it is only in the newer kernels.
https://www.kernel.org/doc/html/latest/admin-guide/blockdev/zram.html#recompression
Output of
rpm-ostree status
No response
Hardware
No response
Extra information or context
No response
The text was updated successfully, but these errors were encountered: