• Buddahriffic@lemmy.world
    link
    fedilink
    arrow-up
    2
    ·
    13 minutes 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
    0
    ·
    18 hours 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.

    • Brkdncr@lemmy.world
      link
      fedilink
      arrow-up
      0
      ·
      22 hours 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.

      • WhyJiffie@sh.itjust.works
        link
        fedilink
        English
        arrow-up
        0
        ·
        12 hours ago

        but that’s not what’s happening. processes do actually get removed from RAM, and when they are needed they are very slow until they are loaded back. the system thinks it’s more valuable to have that memory be filesystem cache

  • Zenorbi@lemmy.world
    link
    fedilink
    arrow-up
    1
    ·
    2 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.

  • provectus@lemmy.ml
    link
    fedilink
    English
    arrow-up
    0
    ·
    2 days ago

    Then what is the setup if my computer only has 4GB of memory for daily driving? Just curious because swap partitions are what I normally do on limited resource machines.

    • mlg@lemmy.world
      link
      fedilink
      English
      arrow-up
      0
      ·
      2 days ago

      Dunno how well zswap handles at that size, but the point is that is compresses swap into RAM, so it would use a max of 819.2M for a total of 2457.6M of swap space. If you need more, then by all means, use a swap file or partition lol.

      Actually linux easily supports multiple and tiered swap mounts, so you could even go zswap + ssd swap + hdd swap, or a cheapo “burn at your own risk” usb flash swap lol.

      • WhyJiffie@sh.itjust.works
        link
        fedilink
        English
        arrow-up
        1
        ·
        20 minutes ago

        so it would use a max of 819.2M for a total of 2457.6M of swap space.

        calling it total is a bit of a stretch. that’s the best case scenario, when the contents compress well.

        also, zswap might not be a good idea on that system. if it only has 4 GB RAM, it likely has a CPU tht is slower and has only a couple cores, and the modern web is cpu heavy enough as it is

  • Jul@piefed.blahaj.zone
    link
    fedilink
    English
    arrow-up
    0
    ·
    2 days ago

    There are good use cases for swap. I work with very performance sensitive memory hogging applications that tend to process in bursts as incoming batched data arrives. We also have a lot of required background “security” applications.

    Having the idle applications move out to swap so that a significant amount of free RAM to allow for the active, real-time applications to expand into is a major boon. RAM is expensive now, so it’s become even more critical to not waste it.

    But even in self-hosting at home I take advantage of it since I have a limited number of servers with limited RAM and a bunch of applications and/or docker containers running, many of which don’t need to be active at all times, but if they were all active, would have trouble with the limited RAM. Swap allows for inactive applications to free up RAM for the active ones and leave enough available at all times to allow an application to quickly spin up new jobs.

    Anyway, sure, for a simple desktop computer without a bunch of junk background applications running for “security” or whatever, and an overabundance of RAM installed, it’s probably not useful. But for high performance, memory hungry applications with lots of background stuff running, it can be a big help.

    That said, there are use cases where the opposite is useful and using a RAM drive is better than writing to disk for cache and temporary logs when you have enough RAM. My opnsense router for instance uses a RAM drive to store cache and logs (logs are mirrored to the NAS for long term storage, so just the local copy is lost on reboot). That system has enough RAM and I’d rather reduce disk wear, and I don’t plan to add too many other applications to that server that it would run low.