Using zswap instead of zram

Forum Forums New users New Users and General Questions Using zswap instead of zram

  • This topic has 19 replies, 6 voices, and was last updated May 22-9:51 pm by banned.
Viewing 4 posts - 16 through 19 (of 19 total)
  • Author
    Posts
  • #37592
    Member
    rayluo
      Helpful
      Up
      0
      ::

      First your swap partition is small compared to amount of ram you have. Generally, it’s recommended for a laptop to have a swap partition that is least a bit bigger than the amount of ram you have (2 gigs) so you can use the hibernation function. Generally, larger is better. I think a swap partition in the 2.2 to 4 gigs range is perfectly reasonable if you have space on the hard drive or you can make some space by shrinking another partition.

      Yes I know the conventional wisdom of having a swap with 2x of the size of ram. My setup has a 256MB swap partition which is on by default, but I also have several swapfiles, 1 gig per file, located in my hard disk, so that I can “sudo swapon /path/to/one-gig-swapfile”, “sudo swapon /path/to/one-more-gig” on demand. More swap did not seem to make a difference when thrashing happens. And again, personally I have that habit of turning off swap, dating back to my Windows XP days. (PS: It turns out Jennings described my habit better than I could do 🙂 in his 9th slide: “In the memory thrashing case, some would prefer to run their systems swap-less and have their workload fall victim to the Out Of Memory (OOM) killer rather than take the non-deterministic latency and performance degradation that I/O introduces”. And that was also the reasoning behind my question in my another thread “can antiX/Linux be still responsive even when running out of memory”.)

      The second and more important reason is discussed by Jennings in his presentation. Since zswap is a cache it has to be able to address a corresponding address in the swap device. In other words each Mb of cache needs a Mb of swap space it can address and then write to if/when needed. If it doesn’t have that swap space then the zswap cache stops growing and may never reach the allocation limit you set

      Good point! I’ll watch that presentation and also enlarge my swap. Interestingly though, in my day 1 experiment, zswap seemed to still make a difference despite with only 256 MB swap.

      #37726
      Member
      mroot
        Helpful
        Up
        0
        ::

        edited—— corrected link

        Ah, I see your mainly using swap files instead of partitions. I looked at the z3fold allocator you were talking about earlier in the thread. It looks like it has some advantages. I found an entry on kernel.org talking about z3fold and how it compares to the default allocator zbud.

        here is the link:

        https://www.kernel.org/doc/html/latest/vm/z3fold.html

        I also think z3fold would allow you to use a compression algorithm with a compression ratio as high as 3:1, something like zstandard.

        • This reply was modified 2 years, 10 months ago by mroot.
        #59821
        Member
        banned
          Helpful
          Up
          0
          ::

          Something doesn’t work.

          With:

          
          echo 1 > /sys/module/zswap/parameters/enabled
          

          I can activate zswap and

          
          grep -R . /sys/module/zswap/parameters
          dmesg | grep -i zswap
          

          show me

          
          root@antix1:/home/antix# grep -R . /sys/module/zswap/parameters
          /sys/module/zswap/parameters/enabled:Y
          /sys/module/zswap/parameters/max_pool_percent:20
          /sys/module/zswap/parameters/zpool:zbud
          /sys/module/zswap/parameters/compressor:lzo
          root@antix1:/home/antix# dmesg | grep -i zswap
          [    5.163930] zswap: loaded using pool lzo/zbud
          

          So it basically works. But when I edit etc / default / grub on

          
          # If you change this file, run 'update-grub' afterwards to update
          # /boot/grub/grub.cfg.
          # For full documentation of the options in this file, see:
          #   info -f grub -n 'Simple configuration'
          
          GRUB_DEFAULT="0"
          GRUB_TIMEOUT="-1"
          GRUB_DISTRIBUTOR="<code>grep PRETTY_NAME /etc/lsb-release | cut -d= -f2 | cut -d\ -f2 2> /dev/null || echo Debian</code>"
          GRUB_CMDLINE_LINUX_DEFAULT="quiet zswap.enabled=1 zswap.compressor=lz4"
          GRUB_CMDLINE_LINUX=""
          
          # Uncomment to enable BadRAM filtering, modify to suit your needs
          # This works with Linux (no patch required) and with any kernel that obtains
          # the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
          #GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"
          
          # Uncomment to disable graphical terminal (grub-pc only)
          #GRUB_TERMINAL="console"
          
          # The resolution used on graphical terminal
          # note that you can use only modes which your graphic card supports via VBE
          # you can see them in real GRUB with the command 
          vbeinfo'
          #GRUB_GFXMODE="640x480"
          
          # Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
          #GRUB_DISABLE_LINUX_UUID="true"
          
          # Uncomment to disable generation of recovery mode menu entries
          GRUB_DISABLE_RECOVERY="true"
          
          # Uncomment to get a beep at grub start
          #GRUB_INIT_TUNE="480 440 1"
          
          GRUB_DISABLE_OS_PROBER="false"
          #GRUB_BACKGROUND="/usr/share/wallpaper/grub/back.png"
          
          GRUB_DISABLE_LINUX_RECOVERY="true"
          export GRUB_COLOR_NORMAL="light-gray/black"
          export GRUB_COLOR_HIGHLIGHT="white/black"
          

          and run

          
          
          sudo update-grub
          echo lz4 >> /etc/initramfs-tools/modules
          echo lz4_compress >> /etc/initramfs-tools/modules
          update-initramfs -u
          

          and reboot, the zswap is still NOT activated. I get

          
          
          root@antix1:/home/antix# cat /sys/module/zswap/parameters/enabled
          N
          root@antix1:/home/antix# dmesg | grep -i zswap
          [    5.163930] zswap: loaded using pool lzo/zbud
          

          When I look at /boot/grub/grub.cfg, I can’t find anything with zswap there.

          I have a Muliboot installation with antiX-19.3, Devuan and TinyCore. So with boot menu.

          When I first time ran this line

          
          
          update-initramfs -u
          

          a message told me to remove cryptsetup-initrams. I did and it also removed cryptsetup

          
          cryptsetup: WARNING: The initramfs image may not contain cryptsetup binaries 
              nor crypto modules. If that's on purpose, you may want to uninstall the 
              'cryptsetup-initramfs' package in order to disable the cryptsetup initramfs 
              integration and avoid this warning.
          
          • This reply was modified 1 year, 11 months ago by banned.
          • This reply was modified 1 year, 11 months ago by banned.
          • This reply was modified 1 year, 11 months ago by banned.
          Attachments:
          #59879
          Member
          banned
            Helpful
            Up
            0
            ::

            Ok, it worked 🙂

            The problem was with the handling of Grub-Customizer. You have to insert the kernel parameters directly into the boot code and NOT in “general settings”, because this has no effect on the boot codes of the individual installed distros. I don’t know exactly what the relevant field is good for.

          Viewing 4 posts - 16 through 19 (of 19 total)
          • You must be logged in to reply to this topic.