The graph is on a logarithmic scale btw

Configuration Before series (ms) With series (ms)
1 vCPU 22.3 (21.6-22.6) 0.97 (0.72-1.4)
8 vCPUs 314 (97-2542) 7.0 (5.0-98)
  • Victor@lemmy.world
    link
    fedilink
    arrow-up
    4
    ·
    17 days ago

    I find it slightly counterproductive that this is a countermeasure against swapping to disk/“device”:

    You want to avoid swapping, which happens when RAM is full (right?), so you create a really fast operating swap thing in RAM, reducing the amount of operational RAM, thus inducing more swapping because there’s “less” “RAM”.

    Not to mention that the data is just moving from place to place inside RAM, just as it would’ve been sitting there before anyway. The only difference is the compression, I assume? Which is the main benefit? Otherwise it just feels like unnecessary shuffling of data back and forth.

    • Die4Ever@retrolemmy.comOP
      link
      fedilink
      English
      arrow-up
      3
      ·
      17 days ago

      In terms of performance, you actually don’t want to avoid swapping, you want your OS to be smart about swapping. Some type of swap space is probably always beneficial unless you have more RAM than storage lol. Swap is great for putting aside data that isn’t needed but can’t be freed, and prioritizing filesystem cache over some background service that isn’t doing anything. Even big servers often use some form of swap because swap can reduce disk reading. In some cases swap can even reduce disk writing, as counter intuitive as that sounds.

      Yea both zRAM and Zswap use good compression, typically around 3:1 ratio, and it’s still light on CPU usage, much faster than SSD swap.

      • Victor@lemmy.world
        link
        fedilink
        arrow-up
        1
        ·
        16 days ago

        I remember when I used to have swap enabled. It used to be very slow, back in the days when we used swap in mechanical drives. The computer would just freeze for a second while swapping, lol.

        So I’m having some trouble wrapping my head around why swapping would not be something you want to avoid—why it would be beneficial for performance. If you can prevent the need for swapping, that’s the best outcome, surely? The only solution to which would be to have enough pure RAM installed in the system.

        But I think I get you? You mean you “want” to swap when the memory runs out?

        • Die4Ever@retrolemmy.comOP
          link
          fedilink
          English
          arrow-up
          1
          arrow-down
          1
          ·
          16 days ago

          If you can prevent the need for swapping, that’s the best outcome, surely?

          It’s more complicated than that. If stuff in your disk needs faster access than old unused stuff in memory, swap can make the swap so that the stuff in your disk is cached better in memory. If you were able to cache your entire filesystem into RAM then your computer would be faster, but people don’t have that much RAM.

    • fozid@lem.radiantfig.fyi
      link
      fedilink
      English
      arrow-up
      2
      ·
      17 days ago

      That’s not how it works but yes, if you don’t need to swap, then that is better. Avoiding swapping though is also the wrong angle as depending on amount of ram, swapping can be beneficial, it just depends.

      • Victor@lemmy.world
        link
        fedilink
        arrow-up
        1
        ·
        17 days ago

        That’s not how it works, but I’m right? I guess I just don’t get it at all. 😅 Which just makes it all the more interesting I suppose. 😃

        • fozid@lem.radiantfig.fyi
          link
          fedilink
          English
          arrow-up
          3
          ·
          17 days ago

          Yeah, there is a lot to it. Firstly, if you have loads of ram, and don’t really use it, then discussing swap is pointless, just don’t have a swap device. If ram on your system is marginal for your workload, then swap is a must have as your system will gain performance by being able to swap, even if it is to an SSD. In that case your system will start swapping to ssd as it gets closer to being full. Zswap improves this by using the margin the system has in ram at which it would swap, to compress the pages in ram instead. So you don’t lose any usable ram with zswap. But you gain performance as compressing the pages in ram is faster than writing them to SSD. But it does eat some CPU load in doing this.

          • Victor@lemmy.world
            link
            fedilink
            arrow-up
            1
            ·
            16 days ago

            Ah, okay. I get it, I think. You’re still using the same amount of RAM but you’re spending some CPU cycles compressing its contents to make more room.

            Can you combine zswap with regular swap, like a swap device or swap file?

            • Die4Ever@retrolemmy.comOP
              link
              fedilink
              English
              arrow-up
              2
              ·
              16 days ago

              Zswap always(?) uses a swap file or disk partition. It does a smart job using both compressed memory and disk space as swap

              zRam does not use disk. Do not attempt combining zRam with any kind of swap on disk, it’s a horrible combination

    • thingsiplay@lemmy.ml
      link
      fedilink
      arrow-up
      2
      ·
      17 days ago

      To me the compression sounds like it would increase RAM (virtually speaking), without hitting performance too much. Otherwise it would use the SSD and io is generally much slower than RAM operations (and compression, decompression in memory only if its fast like this one). When I understand the benefit correctly.

      • Victor@lemmy.world
        link
        fedilink
        arrow-up
        2
        ·
        16 days ago

        Yeah I think I understand, too. You’re increasing the swapping by introducing an area in RAM that is no longer usable as regular RAM, but you’re also compressing, which “increases” the available RAM, so to speak. 😅 At the cost of CPU of course.