I have been setting up Zram, Swap, Swappiness and EasyOOM daemon on 16gb ram boxes, or lower. Someone asked me about 32gb of ram, or more, and I’m unsure. Wondering if others have experimented with this!

  • ISO@lemmy.zip
    link
    fedilink
    arrow-up
    6
    ·
    24 hours ago

    Alright, I will only reply to you, since you raised a fair question.

    First of all, I must admit that I thought what was linked was an earlier similar writing, but the general theme is still the same.

    The problem with the writing is that it focuses on use-cases like Android and some servers, but doesn’t take into account other use-cases. It also seems to come with the assumption that setup is done by the distributor only, or if it’s done by the user, it’s a configure-and-forget situation.

    What he represents is:

    • Limited RAM space
    • Swap will always/often happen (outside of (z)ram)
    • Single tier of non-RAM swap
    • Non-ram swap is significantly slower
    • OOM can be preferable over (outside of ram) swapping
    • Swapped out pages stay where they are until they are required by their process (important).

    Now let’s look at a possible modern workstation setup:

    • Large RAM size
    • Swap is rarely hit, especially if set up with zram.
    • Multiple swap tiers beyond zram/zswap
      • Intel Optane disk used as a super-fast zram write-back device, or a high-priority swap
      • Fast NVME disk used as a second tier swap disk
      • Large HDD swap partition used as a third tier swap disk
    • The biggest consideration is avoiding worst case latency, i.e. hitting HDD swap.
    • Killing processes MUST be avoided, unless exceptional circumstances are hit where the kernel’s OOM would kick in anyway. This holds true even when HDD swap starts getting used.
    • When unusual loads are observed, swapped pages can be moved around by the user (or a tool), by turning swap devices off and on. This is how you can empty the HDD swap partition for example.

    This last point in particular should make it clear why his “imagination” was rather limited in his LRU inversion section.

    • Atemu@lemmy.ml
      link
      fedilink
      arrow-up
      2
      ·
      8 hours ago

      Swap is rarely hit, especially if set up with zram.

      This is not a good thing btw. Any unused anonymous page takes up space that could instead be used for file-backed pages that make your system faster.

      Multiple swap tiers beyond zram/zswap

      Swap is not tiered storage!

      Priorities control order of preference, not tiers. If you run out of space on a higher priority, it will not move that swap’s data to a lower priority swap. It will keep all of it exactly where it is and new data will hit the lower prio swap instead, no matter how hot it is.

      Intel Optane

      Cool tech but it’s dead and was quite niche even when it was alive.

      zram write-back device

      Not a thing you actually want to use for swap. It’s not an automatic writeback that is integrated into the Linux MM in any way. (Probably has some use-case for non-swap zram purposes though.)

      Large HDD swap partition used as a third tier swap disk

      This makes no sense at all unless you are extremely space-constrained on the NVMe and absolutely must not OOM – even if progress stalls to an absolute crawl.

      swapped pages can be moved around by the user (or a tool), by turning swap devices off and on.

      This is neither feasible nor desirable. You don’t have enough granularity to do anything useful by doing so.
      Even if you had, it’d work against the MM because it resurrects pages as “hot” that have been cold for a long time.
      In any situation where swap is important, making the kernel think cold pages are hot is the very last thing you want.


      I too wish it were but tiered/transcedental memory is not a thing in Linux and these hacks do not change that fact; they merely look similar if you don’t look close enough.

      I cannot think of a single use-case where this would be preferable to a decently sized physical swap with zswap XOR just zram swap (if physical swap is infeasible).

      • ISO@lemmy.zip
        link
        fedilink
        arrow-up
        1
        ·
        2 hours ago

        This is not a good thing btw. Any unused anonymous page takes up space that could instead be used for file-backed pages that make your system faster.

        Can you expand here. I think my attempt at brevity in this part wasn’t helpful.

        Swap is not tiered storage!

        I meant tiered with priorities only, yes.

        Cool tech but it’s dead and was quite niche even when it was alive.

        We are not talking about the original purpose of Optane as supported on Windows. It’s just a (perhaps somewhat outdated) example of a storage device “smaller but faster than your average SSD storage”, which is very much not did tech.

        Not a thing you actually want to use for swap

        Depends on the use-case. But yes, this can also be used as the fastest disk tier/priority of normal swap devices, which is why I mentioned both.

        This makes no sense at all unless you are extremely space-constrained on the NVMe and absolutely must not OOM – even if progress stalls to an absolute crawl.

        Why would you want to see killed processes when you go back to your workstation, in the 1/10000th scenario where something runs amok pushing memory usage to unexpected high levels? When you can simply investigate the reason behind the rare occurrence, then move all the pages off the slowest devices immediately with swapoff?

    • dreugeworst@lemmy.ml
      link
      fedilink
      arrow-up
      1
      ·
      14 hours ago

      Intel optane? is there even any advantage left for optane compared with a fast, modern nvme disk?

      • ISO@lemmy.zip
        link
        fedilink
        arrow-up
        1
        ·
        13 hours ago

        It was just an example of a “smaller+faster than your average SSD”.

        and I was mentioning something similar to my setup instead of an imaginary use-case.