<html><head></head><body data-blackberry-caret-color="#00a8df" style="background-color: rgb(255, 255, 255); line-height: initial;"><div style="width: 100%; font-size: initial; font-family: Calibri, 'Slate Pro', sans-serif; color: rgb(31, 73, 125); text-align: initial; background-color: rgb(255, 255, 255);">About the size of zram. Lubuntu and the zram-config package in ubuntu uses half of the physical memory. At least this is a more sane setting then setting it to use all available RAM. </div><div style="width: 100%; font-size: initial; font-family: Calibri, 'Slate Pro', sans-serif; color: rgb(31, 73, 125); text-align: initial; background-color: rgb(255, 255, 255);"><br></div><div style="width: 100%; font-size: initial; font-family: Calibri, 'Slate Pro', sans-serif; color: rgb(31, 73, 125); text-align: initial; background-color: rgb(255, 255, 255);">And of course you are right swappiness=0 does not mean it waits until ram is full to swap out. </div><div style="width: 100%; font-size: initial; font-family: Calibri, 'Slate Pro', sans-serif; color: rgb(31, 73, 125); text-align: initial; background-color: rgb(255, 255, 255);">Swappiness is only a variable to set the tendency of swapping out. It is only one little variable in an bigger calculation. The same goes for swappiness=100 it does not mean that it will swap out everything more or less directly. On a 2.5 GiB RAM Laptop for example and only browsing the web while listening to some music it started swapping at around 2.1 GiB of RAM filled. But this is not an rule it very much depends on what you run and what applications are running actively and what pages do they need. </div><div style="width: 100%; font-size: initial; font-family: Calibri, 'Slate Pro', sans-serif; color: rgb(31, 73, 125); text-align: initial; background-color: rgb(255, 255, 255);"><br></div><div style="width: 100%; font-size: initial; font-family: Calibri, 'Slate Pro', sans-serif; color: rgb(31, 73, 125); text-align: initial; background-color: rgb(255, 255, 255);">I keep it with Andrew Morton who said swapping out unused pages fast is better because why storing unused stuff in memory. He said and set his swappiness to 100 at a time swap still lived on Harddisk so you could argue that it will slow down responsiveness. But nowadays with zram available and all the other exciting technologies I guess this is an valid if not the best overall claim to test and try out. </div><div style="width: 100%; font-size: initial; font-family: Calibri, 'Slate Pro', sans-serif; color: rgb(31, 73, 125); text-align: initial; background-color: rgb(255, 255, 255);">(Btw.caching tweaks ala vfs_cache_pressure and dirty_ratio and dirty_background_ratio are the real performance tuning points when it comes to desktop responsiveness that can make the difference, but this is a whole other topic for that matter)</div><div style="width: 100%; font-size: initial; font-family: Calibri, 'Slate Pro', sans-serif; color: rgb(31, 73, 125); text-align: initial; background-color: rgb(255, 255, 255);"><br></div>                                                                                                                                     <div style="font-size: initial; font-family: Calibri, 'Slate Pro', sans-serif; color: rgb(31, 73, 125); text-align: initial; background-color: rgb(255, 255, 255);"></div>                                                                                                                                                                                        <table width="100%" style="background-color:white;border-spacing:0px;"> <tbody><tr><td colspan="2" style="font-size: initial; text-align: initial; background-color: rgb(255, 255, 255);">                                              <div id="_persistentHeader" style="border-style: solid none none; border-top-color: rgb(181, 196, 223); border-top-width: 1pt; padding: 3pt 0in 0in; font-family: Tahoma, 'BB Alpha Sans', 'Slate Pro'; font-size: 10pt;">  <div><b>Von: </b>JM</div><div><b>Gesendet: </b>Sonntag, 27. Oktober 2013 00:26</div><div><b>An: </b>Leszek Lesner</div><div><b>Cc: </b>lubuntu-users@lists.ubuntu.com; lubuntu-qa@lists.launchpad.net</div><div><b>Betreff: </b>Re: [Lubuntu-qa] ZRAM, vm.swappiness and the future</div></div></td></tr></tbody></table><div style="border-style: solid none none; border-top-color: rgb(186, 188, 209); border-top-width: 1pt; font-size: initial; text-align: initial; background-color: rgb(255, 255, 255);"></div><br><div id="_originalContent" style="">On Sat, 26 Oct 2013 20:37:04 +0200<br>Leszek Lesner <leszek.lesner@web.de> wrote:<br><br>> As some of you know there were some discussions on this mailinglist<br>> regarding zram and vm.swappiness.<br>> In this mail I want to write down all I know and learned about zram,<br>> vm.swappiness and its cooperation.<br>> This is intend as a help and a starting point for discussions for the<br>> next release of Lubuntu which will be an LTS.<br>> <br>> I have to thank Mélodie for the discussions about vm.swappiness which<br>> made me dig deeper and deeper into it.<br>> And I have to say I was wrong at least partly :P<br>> <br>> So before talking about ZRAM a small comprehensive introduction what it is.<br>> ZRAM is a compressed virtual swap device that lives in RAM. With this it<br>> is possible to use and store more memory<br>> that is physically available. It is used by Lubuntu in 13.10 by default.<br>> <br>> What is vm.swappiness ? That is a far more complicated thing to explain.<br>> Simply speaking it controls the balance between swapping out runtime<br>> memory,<br>> as opposed to dropping pages from the system page cache. It can have a<br>> value from 0 to 100.<br>> A lower value means that it will try not to swap out page cache but keep<br>> it in memory.<br>> A high value means try to more aggressively swap out unused page memory.<br>> <br>> A discussion was started if Lubuntu should lower down the vm.swappiness<br>> value or even set it down to 0<br>> to improve system performance and responsiveness.<br>> In my initial thought that I could give a universal answer on this topic<br>> but I was wrong.<br>> There a several scenarios we need to take a look at to see that there is<br>> not an universal answer on this.<br>> <br>> == The classical situation (before 13.10): ==<br>> * RAM + SWAP (on HDD)<br>> <br>> The RAM is backed up by a SWAP partition or SWAP file which is stored on<br>> a harddrive or ssd.<br>> As we all know disk i/o is a lot slower than RAM. On older machines and<br>> slower disks this could lead to noticable<br>> lags while swapping. But also on normal machines it is noticable. So for<br>> this scenario it would be nice to tell the<br>> kernel to avoid swapping as much as possible to avoid this bottleneck.<br>> A low vm.swappiness or even 0 is a good setting here as the kernel keeps<br>> filling the ram until it is almost full and then<br>> starts swapping out which could make the system laggy for a few seconds<br>> and while writing data to swap. So there is an unavoidable<br>> bottleneck here but there is also the possibility that with enough ram<br>> and a low memory footprint of the apps and desktop that<br>> the user will not reach the point of swapping.<br>> <br>> == The new modern situation (with 13.10¹): ==<br>> * RAM + ZRAM<br>> <br>> The RAM is backed up by a SWAP partition which is stored on a virtual<br>> compressed ram device. Under Lubuntu<br>> 13.10 this device can use half of the physically available memory.<br>> Writing and reading to and from RAM is a hell lot faster than to disk<br>> (even to an SSD). This means there is no bootlneck<br>> when the system swaps out to ZRAM with its default swappiness settings.<br>> Setting the swappiness lower here would make a change but<br>> a very minor only (noticable only via benchmarks). And lowering it here<br>> might lead to a faster reaching of the second<br>> bottleneck. So avoiding swapping and letting the RAM be filled and<br>> swapping late especially when RAM is very full will slow down the<br>> system and produces noticable lags. Those lags might be even harder in<br>> this case because the pages need to be compressed into RAM and<br>> when new pages need to be placed into RAM at the same time this might<br>> lead to a long cpu 100% compressing decompressing moving loop.<br>> Letting the swappiness at default (60) or even set it higher to 100<br>> would help avoid this bottleneck as swapping early would avoid<br>> RAM running full too fast.<br>> Whats the downside ?<br>> The CPU has to compress and decompress more often (don't worry even a<br>> Pentium 3 is very fast at it) and this causes more wake up times<br>> for the CPU. (perhaps a downside for those who want to save every little<br>> watt of there notebook battery)<br>> <br>> == The combination of both situations : ==<br>> * RAM + ZRAM + SWAP (on HDD)<br>> <br>> The RAM is backed up by ZRAM and a SWAP partition/file. This is an usual<br>> setting if you have very low RAM (like 256/512MB or 1 GB).<br>> By default ZRAM is as Swap device has a higher priority than the swap<br>> partition/file on hd. The swapping mechanism now works very clevely<br>> and swaps out first and by default early to zram first until its full.<br>> Then it will start swapping to hdd.<br>> This will lead us to our bottleneck nr.1 again but in contrast to the<br>> classical situation (scenario 1) it will get there a lot later :)<br>> So is there a possibility to avoid this bottleneck by changing the<br>> swappiness ? No not really.<br>> Swappiness low would lead too faster filling in memory which will lead<br>> (especially on low memory systems) lead to bootlneck 2 which tends<br>> to make the system a lot laggier than bottleneck 1.<br>> Setting swappiness higher here would be also only work until ZRAM is<br>> filled and than would lead to bottleneck 1 again.<br>> So overall I would recommend the default swappiness value here which<br>> tends to keep the system in a good balance between bottleneck 1 and 2.<br>> <br>> So all in all when you see this scenarios I have to say that the default<br>> value of swappiness 60 makes the most sense as the default value<br>> of lubuntu. Changing it for the next release is something I would not<br>> recommend.<br>> <br>> Seeing this one could ask wouldn't it be good to directly compress any<br>> data written to RAM ?<br>> And yes this is a possibility in the future with zcache (which is<br>> basically a backend for cleancache which is a whole framework around it).<br>> Zcache compresses every page cache written to RAM which will lead to<br>> more available free memory.<br>> And yes it is even possible to combine ZCache (Page Cache[Disk Cache and<br>> so on]) and ZRAM (Application memory) which<br>> could lead to even more available free RAM and might even make it<br>> possible to completely get rid of SWAP partitions/files on hdd.<br>> In the making is also frontswap which is basically speaking zram but<br>> without the necessity to give it a fixed size. So it can dynamically<br>> grow.<br>> <br>> So the future looks very promising when it comes to low ram management<br>> and we are on a good way.<br><br>Hi,<br><br>This is a great presentation. I must say I have not yet tried the distro on the eldest<br>machine of the house here, but I will as soon as possible and I will bring a detailed<br>feedback.<br><br>I still disagree with you on two points, is the level of swappiness, because my<br>experience shows that even when setup to 0 it will still start to swap to disk while a<br>little amount a RAM is still available, and the feeling for slowness starting when the<br>system starts swapping is quite present. (On a very old machine with very little RAM and<br>small CPU, poor Graphics, and on a very recent with lots of RAM and a good strong CPU).<br><br>Of course swapping to the compressed zram device is faster than swapping to disk! This<br>is the very interesting point about using zram. (I suppose my swap partitions are<br>really used only when putting the system to sleep/hibernation - but that concerns<br>machines with enough resource, such as dual cores with at least 2 GB Ram where the most<br>greedy application I use is probably Virtualbox with a light system running in it).<br><br>One point I didn't read about in your explanation is about the size of the ZRam swap<br>block device: the author or the program himself did suggest that 25% for a machine used<br>as a desktop would be the best setup, according to his tests, benchmarks, and given the<br>fact that other processes in the system already use some ram for their caching needs.<br><br>I am not sure I said it all the right way in the English language, however I hope there<br>isn't any big mistake. I will just invite you to also visit the brainstorming about ZRam<br>started on the launchpad, and where phillw invited me to post and where I develop the<br>suggests and point to another longer presentation of the experience I had so far with<br>ZRam:<br>https://blueprints.launchpad.net/lubuntu-brainstorming/+spec/zram-config<br><br>In the "long story" I point to at the end of my message on the above page, you will find<br>more about experience and links to the precise part of the compcache page where I get the<br>information related to Nitin Gupta, the author of Zram and the Compcache project. <br><br>Regards,<br>Mélodie<br><br><br></div></body></html>