• Zenorbi@lemmy.world
    link
    fedilink
    arrow-up
    16
    ·
    27 days ago

    I used to be this guy. We have huge amount of memory in our storage server. Why would we need swap? Well, once the system started killing programs I read up on swap and how the system handles its caches, especially ZFS ARC.

    Short version is that while the system can evict its caches syncronously, it can only async notify ZFS that it should also shrink its caches, but the out-of-memory killer will start killing before ZFS and its kernel counterpart can start to free up memory.

    A tiny bit of swap completely solved this, since swapping is sync for the kernel and the OOM killer will wait for it.

    • j3tt@lemmy.world
      link
      fedilink
      arrow-up
      1
      ·
      26 days ago

      I sometimes cannot do hibernate when I did a scrub on my ZFS. But the first try always frees up the swap and so the second attempts works every time.

  • topperharlie@lemmy.world
    link
    fedilink
    arrow-up
    8
    arrow-down
    1
    ·
    26 days ago

    Everyone defending swap like crazy in the comments… so let me give a counter argument specifically for desktop:

    Many years ago I stopped using swap on all my computers (I exclusively use linux) and the reason is: every time anything regarding interactivity went to swap, my system would freeze and literally become unusable for a really long time until I killed something. Since I got tired if that behaviour I decided I prefer for random shit to die but my computer still be usable.

    It wasn’t very often, but I don’t get OOM killer often either (as in I don’t remember the last time it happened and I use linux every day for both work and fun), and the freezing situation was way more annoying, to the point I sometimes ended up cold switching off the computer. I’m surprised on how many people run out of memory constantly. I guess you all are just using linux for servers and have crazy processing of infinite data…

  • Blue_Morpho@lemmy.world
    link
    fedilink
    arrow-up
    7
    ·
    27 days ago

    “Unresizeable block device at end of disk”

    Classically the swap partition was located at the physical middle of the drive so that on average, no matter where the heads where, the swap partition wasn’t far away

    • InnerScientist@lemmy.world
      link
      fedilink
      arrow-up
      1
      ·
      26 days ago

      Also “unresizeable” as if you can’t just swapoff and just delete and recreated it anywhere (update the path in fstab) and then swapon again.

    • Brkdncr@lemmy.world
      link
      fedilink
      arrow-up
      5
      ·
      26 days ago

      Saving ram to swap can be done with minimal impact. Helpful when you run out of memory and that 2gb app idling can be dumped right away instead of waiting for it to be copied to swap.

    • droans@lemmy.world
      link
      fedilink
      arrow-up
      2
      ·
      26 days ago

      Because you just taught your computer how to be lazy. “oH lOoK aT mE i’M sWaP mEmOrY”

  • Buddahriffic@lemmy.world
    link
    fedilink
    arrow-up
    6
    arrow-down
    1
    ·
    25 days ago

    The trick is to first create a RAM disk. Then put the swap file on there and it’s about as fast as RAM. Then, with the new memory you have created, make another RAM disk. Yep, then make more swap space on there.

    I have solved both the memory and SSD availability issues with this infinite RAM and disk space trick.

  • sumsinj@lemmy.world
    link
    fedilink
    arrow-up
    4
    ·
    26 days ago

    I dislike swap solely because it gets used and when I accidentally open the same file twice then I regularly encounter problems with swap files when opening the file again later.

  • RustyNova@lemmy.world
    link
    fedilink
    arrow-up
    4
    ·
    26 days ago

    I don’t really need swap until I need to compile blender… Need somewhere around 64Gb (with compression) to deal with the peaks

  • mazzilius_marsti@lemmy.world
    link
    fedilink
    arrow-up
    3
    ·
    26 days ago

    unfortunately with S0ix being forced on all modern laptops, zram is the only logical choice. With s3 sleep at least i can say i need swap because i need hibernation…With S0ix? Dont bother.

  • basic_user@lemmy.world
    link
    fedilink
    arrow-up
    1
    ·
    27 days ago

    Have a PC with 16gb ram that lives up to the overwatch game system reqs. When I installed it and launched it, it began building some sort of cache. A one time job. During that chache my os would force close steam to prevent an oom crash. I then added 16gb swap and during the owerwatch cache job the used phys ram would max out at 12gb I think and the swap sent up to 10gb. So a 22gb ram job. Yikes. Thanks swap ram 👍