Install Steam
login
|
language
简体中文 (Simplified Chinese)
繁體中文 (Traditional Chinese)
日本語 (Japanese)
한국어 (Korean)
ไทย (Thai)
Български (Bulgarian)
Čeština (Czech)
Dansk (Danish)
Deutsch (German)
Español - España (Spanish - Spain)
Español - Latinoamérica (Spanish - Latin America)
Ελληνικά (Greek)
Français (French)
Italiano (Italian)
Bahasa Indonesia (Indonesian)
Magyar (Hungarian)
Nederlands (Dutch)
Norsk (Norwegian)
Polski (Polish)
Português (Portuguese - Portugal)
Português - Brasil (Portuguese - Brazil)
Română (Romanian)
Русский (Russian)
Suomi (Finnish)
Svenska (Swedish)
Türkçe (Turkish)
Tiếng Việt (Vietnamese)
Українська (Ukrainian)
Report a translation problem
https://github.com/CryoByte33/steam-deck-utilities/issues/179
vm.swappiness = 1
Name Type size used priority
/dev/zram0 partitition 5.8g 288k 100
/home/swapfile file 16g 0b -2
Mem: total 11gi, used 3.3gi, free 713mi, shared 436mi, buffers 238 mi, cashe 8gi, available 8.2gi
Swap: 21gi, 288ki, free 21gi
dirty_ratio = 20
dirty_background_ratio = 10
Could you give the output of the following commands as well?
Name/algorithm/disksize/data/compr/total/streams/mountpoint
/dev/zram0 zstd 5.8G 4K 64B 20K 8 [swap]
OK. Thanks!
Now that we have the full picture... It's time to add my personal opinion. :)
Let's say your assumptions are not quite right.
1. Swappiness parameter is used for all virtual memory any kind of swap, that includes zram. Swap items are used, as required, by priority.
https://docs.kernel.org/admin-guide/sysctl/vm.html
https://www.kernel.org/doc/gorman/html/understand/understand014.html
That being said, the Kernel docs must be taken with a grain of salt for swappiness values suggestions. They are talking more about servers and highly specific systems rather than personal computers. So that example with swappiness over 100 is not for you.
Funny enough, for the issue regarding vm.swappiness set 100 on SteamDeck (which is one problem you don't have exactly, because, on your SteamDeck, it's set to 1), one GitHub user used the formula in the Kernel docs and ended up to the conclusion that swapinness needs to be 198, which is absurd. Then again, reddit techies are testing zram performance with swappiness 200, very sensible /s. Later Edit: Not to be misunderstood, for testing purposes, to force kernel to do a lot of swapping, this is fine, but it may lead readers thinking this is a normal value to use on a normal system.
Probably, the devs working at Valve skimmed through the same text, saw zram and 100 in the same sentence, and said, bam! That's it! 100! Let's gooooo!
2. zram is great. It is used from Small Board Computing like Raspberry Pis to fully blown PCs to improve performance, not making it worse. It is the best thing that ever happened to swapping. The only logical reason to have a swap file on a storage device on a personal computer in 2024/2025 is if you want to hibernate.
Now, let's analyze the numbers posted.
Firstly, vm.swappiness is way too low. When you have multiple processes fighting for the same amount of RAM, the system might work too hard hard evicting pages from RAM to swap and sending them back again to RAM over and over because that value is at the limit of saying don't use swap at all, better kill the process.
Secondly, you have only 11-12GiB available as system memory, that means your GPU is probably using around 4GiB of RAM as video memory (a.k.a. VRAM). If you don't play some games that just don't work with less VRAM, you can free up 1-2GiB. I think you can set up VRAM from SteamDeck UEFI > UMA Frame buffer size. 2GiB should be more than enough for VRAM. If VRAM is not used, it can't be used as normal system virtual memory.
Third point, zram. The zram value seems to be set for about half the RAM available as system virtual memory. Very important note that this size is not used by default. The operating system is using as little as it's needed. So, opposed to VRAM, zram is not actual using 6GiB of system memory. And on top of that, everything is compressed to over 2.5x, no matter the compression algorithm used. 6GiB might be a little too much though (especially with Valve's default swappiness of 100). Seems like Valve picked zstd as the compression alghorithm which offers the highest compression, but it also has the worst latency and IOPS, which on a mobile device with limited power is not quite right; we want to make everything snappy, even if we don't get the best compression. So lzo-rle and lz4 are the best contenders. Fedora, for example, uses lzo-rle.
Dirty_* params are fine for the amount of memory.
Final thoughts:
a. Ditch the swap file if you don't use hibernation.
b. Set swappiness to 20. I don't know how cryo-utilities does it, if you want to use that tool, use it.
If you want to set up swappiness the right way... there are enough articles on the web. The only thing to look for is the default swappiness configuration made by Valve (should be in /etc/sysctl.d/). If their config file starts with 20-, your config should be 21- or more, to overwrite what Valve is setting by default, and, of course, not changing their own file that might be ovewritten by an update.
https://www.freedesktop.org/software/systemd/man/latest/sysctl.d.html#Configuration%20Directories%20and%20Precedence
c. Set zram to 4 GiB. You could try lower (3, 2), if you still have issues. The thing with zram is that it can be set in different ways. I'm not sure how Steam Deck is setting up zram at boot. Considering Steam Deck is based on Arch Linux, Valve should have set it up with one of the methods described here: https://wiki.archlinux.org/title/zram#Usage_as_swap. I can only guess that they've used zram-generator, as it's also been used by other distros. Look for the conf file. If it's not at /etc/systemd/zram-generator.conf, it might be at /usr/lib/systemd/zram-generator.conf, /usr/local/lib/systemd/zram-generator.conf, /run/systemd/zram-generator.conf (https://man.archlinux.org/man/zram-generator.conf.5. Of course, as with swappiness, if you want to keep Valve's zram, but make it secondary, create a new zram config in zram-generator.conf.d/ (check the link above) and set its swap-priority to 200. Compression algorithm should be lzo-rle or lz4. You should end up with something like this:
Even though I won't recommend it, if you still want to remove zram, you've got the solution just above: delete the zram-generator.conf made by Valve.
Here's a table with viable values you can try before purging zram from your SteamDeck. :)
Later Edit: I don't know how SteamDeck immutable system works, Fedora's immutable spin uses os-tree on /usr and root (/), but not on /etc and /var, which means configuration and data files can be created or edited. In case SteamOS works differently and you can't set up the config files required, there's another way to set these settings at runtime by using the kernel ins and outs, but it's more tedious and not quite the way things should be done under GNU/Linux, especially if you have a service that works as intended for a specific task.
- fixed wrong use of "virtual memory" in this context, "swap" is the right word:
- for testing purposes 200 value is fair, but I wouldn't use it on a normal system, added some explanation on that:
- added an additional explanation on zram conf file content:
- a few insignificant text format changes and typos fixes
Anyway, let me know if any of this worked for you. I really hope it does and you don't disable the zram. :)
Root rights are fine. I didn't mentioned because I thought you may know a few things about GNU/Linux. Configuration files that are installed with a package may use root as owner. Immutable system is a different story, but editing files owned by root is fine. To change this file just use sudo with your preferred text editor, or what you can find in SteamDeck.
In SteamDeck Desktop Mode, because it's KDE, you should find KWrite as a text editor, which can open files and ask for elevation when you try to save a file owned by other users, similar to Windows.
Later Edit: A little more explanations on the rights. /etc is the usual place configuration files of system applications are installed, the configs that are not local to a user. That's why even writing anything to /etc requires root elevation. It's pretty much like the Program Files or, even better, ProgramData in Windows. So even if you make another conf file there and let Valve's config alone, you will still need to use either the root user when creating and/or editing the file or sudo command using a "sudoers"/"wheel" user (I am speaking about default systems here, going down the rabbit whole, there can be users that can use sudo, but they are limited to which commands they can use sudo with - for example, this might be useful for a service application that runs with its own user and needs some access to a list of commands that require elevated rights).
Edit: i create file in etc. with 200 priority, and (idk what is this but copy paste "fs-type = swap" from zram0 file). So, now in lsblk | grep zram its zram0 and zram1. But command swapon -s shows only /dev/zram1 (with 100 priority(why(?)) and swap file. So, i did it? Or this is something i don't understand.
Pss. Another problem that I'm trying to outline is that the deck has stopped taking up more memory in applications where 16GB of RAM is not enough. Let's say earlier, the deck could take memory from a swap file as much as 20 GB in total. Now he does not go beyond the borders. I also think, why is that? Because of the -2 priority?
When you didn't posted the config path, I assumed it was in /etc. If it's in /usr, it makes sense it doesn't work being edited. As mentioned in one of my posts. Immutable distros (I've mentioned Fedora) keep /usr and root (/ locked with os-tree. Of course, there's a hack to edit that, but I don't want to mention hacks, neither for editing not for freezing any files.
I don't know why zram0 disappeared or why the priority is set to 100.
Also, you don't need fs-type, by default it's swap for zram.
I've posted some links. Please click on them and read the documentation if you don't understand what an option, a parameter means.
Sorry, but I think you're post is missing some info. I can't just see the whole picture from the fragments. Please post the conf files with their paths and all the outputs on the following commands.
Also, make sure you rebooted the Steam Deck or reloaded the service (forgot to mention them). Reload & Start without reboot.
In Kernel, prio is defined as int, so it should be able to take even lower negative numbers, yet man swapon talks about valid values from -1 to 32767.
Now, I don't want to go into the details of the system memory used by applications and swap, but there are two distinct things. Apps don't know about swap, and apps run only in system virtual memory, not in swap. Thanks Microsoft for calling everything "virtual memory". What I can only guess is that the zram is getting a little full, and the minimum system memory to be used by a certain app is just too small to run a big bunch of it, maybe the app just has very big sets of data that just don't fit in. There's also the possibility that the app itself is checking how much memory is available and just quits by default.
Swap is NOT RAM (or system memory, or real accessible virtual memory for the apps).
Anyway, please post the outputs. Also, I was thinking, you could try to create the conf file in /etc with zram0 instead of zram1 as definition. I haven't tested, but maybe zram-generator will overwrite the parameters, keeping the newest options defined for zram0. This way you would end up with just one zram with the wanted parameters.
Later Edit: Yes, it's working.
Later Edit 2: First off, always post the outputs so I can see what's going on. Last post, you said you ran lsblk and swapon, but not zramctl.
Secondly, if everything looks OK, tell me how does SD feel? Snappier than with the previous zram definition? Snappier than without zram at all? Please do some tests with games that fit the memory limitation. Give me some output of free -hw, swapon -s and zramctl while playing. I want to see how much zram is actually occupied. Then, we'll look at the apps that don't start. Maybe they'll start now, maybe. Or just shrink the zram a bit (3584, 3072)? Just save everything you do in a file and post it here.
Ps. I will try to disable the swap file completely in the near future, leaving only zram.
Pss. When I was playing Hogwarts, the memory was used like this: with 1GB of swap and 4GB of zram, both were filled up almost immediately after starting the level. Having increased the swap file to 16GB, of course, not all of it was filled. But by disabling zram, the swap was used for 4-6 GB and each filling with data was accompanied by the strongest statters.(actually, it's worth saying that I don't know how to track what's happening in real time, so I just minimized game window to enter commands into the console)
Sry, I can't check all the commands thoroughly yet. I'll try to do it soon.