• azimir@lemmy.ml
    link
    fedilink
    arrow-up
    0
    ·
    25 days ago

    I have a small home server that I occasionally push through huge batch processing jobs. During the pushes, I might collide with other projects that use a pretty big chunk of the RAM. So, to make sure it’s never a killer (just a major slow down), I made a 32GB swap file. If I need it, it’s there and disk is hella cheap.

    This machine has never had a GUI installed. No browsers to complain about, just plain old data processing, stats models, and old skool computing.

    Now, my worst case scenario was building a C++ program on a raspberry pi gen 1. That has 256MB of RAM. g++ ran out building, so I NFS mounted a huge disk from my desktop machine and made the swap file there. The build took a while… but the program ran fine after the week long build, no swap needed.

    • cannedtuna@lemmy.worldOP
      link
      fedilink
      English
      arrow-up
      0
      ·
      25 days ago

      Used a website to make the windows since I was on mobile. Thought it looked too plain w/o the window decorations, but yeah. I mean there’s so many distros and themes, who’s to say it couldn’t be Linux. I’ve seen KDE reskinned to look like OSX

      • alecsargent@lemmy.zip
        link
        fedilink
        arrow-up
        0
        ·
        25 days ago

        It’s fine, I really like MacOS X too. To be fair those window decorations looks real nice as demos.

    • zitrone 🍋@europe.pub
      link
      fedilink
      arrow-up
      0
      ·
      25 days ago

      right real linux user do everything in the tty and maybe put something in the framebuffer if they want to view an image or similar

  • topperharlie@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    24 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…

      • topperharlie@lemmy.world
        link
        fedilink
        arrow-up
        0
        ·
        24 days ago

        yep it was HDD, but with the low amount of times I have any OOM issue, I’m way more worried about NVMe flash burning than a random process being killed once every blue moon.

        In fact I didn’t mention, but since the advent of flash drives what I’ve done is trying to locate heavy disk writing apps and find alternatives for them, amid disabling many logs.

        For swap, it hunts me to think some automatic process I don’t have control over will burn those sweet erase cycles without me noticing just because someone programmed it poorly. I’m way more happy knowing I have some control over it.

    • JamesBoeing737MAX@sopuli.xyz
      link
      fedilink
      English
      arrow-up
      0
      ·
      24 days ago

      Or shotcut. I once ran it on 8GB, minimal arch with no swap. Well.

      And I’m not even trying to build android on my new relatively modern laptop. It won’t work.

  • OwOarchist@pawb.social
    link
    fedilink
    English
    arrow-up
    0
    ·
    25 days ago

    Yes, swap partitions are shit.

    The real hotness is swap drives.

    Just the use that your old 64GB SSDs were waiting for!

    (Fun fact: in Linux, if you have multiple swap partitions mounted, the kernel will automatically use striping (like RAID) in order to read and write from them as fast as possible. If you have multiple small SSDs used for swap, the read/write speed from swap can actually become pretty fast.)

      • OwOarchist@pawb.social
        link
        fedilink
        English
        arrow-up
        0
        ·
        24 days ago

        You’re going to run into issues with your motherboard’s SATA or NVME (or PCIE) controller throughput well before you get close to actual RAM speeds.

        Once you reach that bottleneck, the speed won’t increase anymore when you add more drives. The motherboard architecture just doesn’t support accessing any kind of storage device at that speed.

      • Axolotl@feddit.it
        link
        fedilink
        arrow-up
        0
        ·
        24 days ago

        I did a (very) quick search and they should just sum up, so for example a raid of 2 sata SSD with 64gb that can reach 500MB/s will have a total speed of 1GB/s,
        DDR3 ram can get up to 17GB/s so we would need 34 drives to get DDR3 speeds (not very fast BUT you would be the person with most ““RAM”” in the city without being a data center)

  • 87Six@lemmy.zip
    link
    fedilink
    arrow-up
    0
    ·
    25 days ago

    All I know is that I had 16GB RAM and 4GB swap and I used to get crashes sometimes.

    Set that fucker to 32GB out of spite, now no crashes. No idea why that helped. But I guess I do have like 15 tabs open on the regular (web dev)

      • tal@lemmy.today
        link
        fedilink
        English
        arrow-up
        0
        ·
        25 days ago

        I don’t recall that, but IIRC it does need to be a minimum of installed RAM if you want to be able to hibernate, since then you write out the contents of your memory to swap. That makes having at least as much swap as RAM a good rule of thumb for many systems.

        IIRC kernel crash dumps also make use of swap in a similar way, though I assume that in most sane scenarios, it’s not going to actually require as much swap as physical memory, because you won’t have all of your physical memory allocated to the kernel.

        On non-exotic Linux systems, I always make sure to have more swap than physical RAM.

        • rumschlumpel@feddit.org
          link
          fedilink
          arrow-up
          0
          ·
          25 days ago

          I don’t recall that, but IIRC it does need to be a minimum of installed RAM if you want to be able to hibernate, since then you write out the contents of your memory to swap.

          IF RAM used + swap used don’t exceed total swap space. Yeah, sometimes I run into that. Usually solved by killing webbrowsers, which suggests that most of the swap space is filled with unused webpages…

        • j3tt@lemmy.world
          link
          fedilink
          arrow-up
          0
          ·
          24 days ago

          I use 1.5-2x the swap on new installations these days. I want hibernate to always work.

          • Klajan@lemmy.zip
            link
            fedilink
            arrow-up
            0
            ·
            24 days ago

            I use the same, but I think to be super conservative It should be 1.5x + VRAM

    • JasonDJ@lemmy.zip
      link
      fedilink
      English
      arrow-up
      0
      ·
      25 days ago

      15 tabs? Those are rookie numbers. Unless you mean “before 8:07 Monday morning”.

    • treadful@lemmy.zip
      link
      fedilink
      English
      arrow-up
      0
      ·
      25 days ago

      But I guess I do have like 15 tabs open on the regular (web dev)

      Minor league shit.

    • adarza@lemmy.ca
      link
      fedilink
      arrow-up
      0
      ·
      25 days ago

      that’s what trixie’s netinst defaults to when i set up new desktops using encrypted lvm… root and swap volumes inside that, unlocking together at boot. my use doesn’t hit swap much, so it’s nbd. i just leave it like it is. only where an installer doesn’t support encrypted swap partitions do i use a file or ram-based swap instead.

      • dan@upvote.au
        link
        fedilink
        arrow-up
        0
        ·
        25 days ago

        It’s not as bad with LVM since LVM is more flexible. A swap file does still make it easier to change the size as needed though. If you need more swap, you can spin up a new swap file pretty much instantly while the system is running, without having to repartition. You can have both a swap partition and a swap file active at the same time though.

        On systems where the data is encrypted, also encrypting the swap makes sense so I’m glad Debian does that.

      • dan@upvote.au
        link
        fedilink
        arrow-up
        0
        ·
        25 days ago

        I’ve seen so many setups where people encrypt their data but forget to encrypt their swap.

        • DevDave@piefed.social
          link
          fedilink
          English
          arrow-up
          0
          ·
          25 days ago

          what’s the problem? it’s not like you dump the entire contents of your system’s ram to disk any time use hibernate /s

          • dan@upvote.au
            link
            fedilink
            arrow-up
            0
            ·
            25 days ago

            Even without hibernation, data in apps you have open will end up in the swap if your system is ever RAM-constrained.

            • redjard@reddthat.com
              link
              fedilink
              arrow-up
              0
              ·
              25 days ago

              Generally it only happens to programs you keep running in the background and might not use for a long time that also don’t have much background activity. For example password managers.

              • dan@upvote.au
                link
                fedilink
                arrow-up
                0
                ·
                24 days ago

                It depends on what you set your swappiness to, too. I think Linux distros still have pretty aggressive defaults that swap more than they probably need to.

    • Frenchgeek@lemmy.ml
      link
      fedilink
      arrow-up
      0
      ·
      24 days ago

      I do, yeah. Since I’m already partitioning by hand to put /home on a different drive, better use the saved space on the NVME for a small amount of guaranteed swap while I’m at it.

        • redjard@reddthat.com
          link
          fedilink
          arrow-up
          0
          ·
          25 days ago

          So you shut your pc down like a caveman when you do hardware upgrades or repairs or move apartments?

          • dan@upvote.au
            link
            fedilink
            arrow-up
            0
            ·
            24 days ago

            Yeah I shut down every day. It boots up fast enough that it’s really not an issue.

      • PervServer@fedinsfw.app
        link
        fedilink
        English
        arrow-up
        0
        ·
        25 days ago

        Nope, I hibernate with a swap file and it’s in a LUKS partition. Although IIRC that whole setup requires me to use systemd boot.

      • Ooops@feddit.org
        link
        fedilink
        arrow-up
        0
        ·
        edit-2
        25 days ago

        It’s doable with a swap file instead. But some filesystems are more supportive than others.

        For example BTRFS doesn’t support swapfiles over multiple devices (so my raid1c3 spanning 3 differently sized disks for example) and also swapfiles must be completely pre-allocated. (On the plus side BTRFS automatically blocks any accidently attempt to backup a subvolume containing a swap file.)

        And no matter the filesystem you need to manually tell the kernel device and physical offset for the file via kernel parameters. Which can again be easier on some than on others (also causing the no-multiple-device filesystem problem mentioned above.

  • basic_user@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    25 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 👍

  • I’ve had my computer crash trying to open or save a pdf once because it used up all the RAM space (16gb) and then used up the small swap (probably like 10gb?) and I guess some critical processes I guess just got told “no.” Seems wild to me that Windows would just crash before it told a pdf it couldn’t use over 20gb of memory.

  • Jul@piefed.blahaj.zone
    link
    fedilink
    English
    arrow-up
    0
    ·
    25 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.

    • Supercrunchy@programming.dev
      link
      fedilink
      arrow-up
      0
      ·
      25 days ago

      I also found it useful to do some one-off batch processing of a big file without thinking of chunking and doing too complicated things. Imagine something like a 60GB file in a custom format that need to be deduplicated. It’s easier to just load it all up in memory and do run the algorithm 2-3x slower using a 50GB swapfile than spend hours to complicate the algorithm.

      • OwOarchist@pawb.social
        link
        fedilink
        English
        arrow-up
        0
        ·
        25 days ago

        Yep. That’s why it can be nice to just have like an old 1TB drive completely used for swap. Things might get slow once it exceeds your physical memory, but at least it will eventually finish successfully – no out of memory crashes here!

    • Kangae_Hishiryo@scribe.disroot.org
      link
      fedilink
      arrow-up
      0
      ·
      25 days ago

      Actually, there are more than these. For example, hibernation and/or hybrid suspension. It’s, AFAIK, mandatory to have a swap partition to be able to hibernate and/or hybrid suspend your device.

  • queeradjacent@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    0
    ·
    25 days ago

    Maybe stop giving a shit what I do with my partions? 🤷 Mine is definitely to try and make hibernate work on a shitty old laptop that’ll drain the battery if I let it sleep and unplug it.

    • onipa@feddit.org
      link
      fedilink
      arrow-up
      0
      ·
      25 days ago

      I was thinking about hibernation as well but wasn’t sure if hibernation might also work with a swap file

      • queeradjacent@sh.itjust.works
        link
        fedilink
        English
        arrow-up
        0
        ·
        25 days ago

        Honestly the kernel is smart enough to only use it if you need it most of the time from what I can remember from my admin days, no idea why op cares.

  • Buddahriffic@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    23 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.