DefederateLemmyMl

  • Gen𝕏
  • Engineer ⚙
  • Techie 💻
  • Linux user 🐧
  • Ukraine supporter 🇺🇦
  • Pro science 💉
  • Dutch speaker
  • 1 Post
  • 42 Comments
Joined 11 months ago
cake
Cake day: August 8th, 2023

help-circle
  • If he’s processing LLMs or really any non-trivial DB (read: any business DB)

    Actually… as a former DBA on large databases, you typically want to minimize swapping on a dedicated database system. Most database engines do a much better job at keeping useful data in memory than the Linux kernel’s file caching, which is agnostic about what your files contain. There are some exceptions, like elasticsearch which almost entirely relies on the Linux filesystem cache for buffering I/O.

    Anyway, database engines have query optimizers to determine the optimal path to resolve a query, but they rely on it that the buffers that they consider to be “in memory” are actually residing in physical memory, and not sitting in a swapfile somewhere.

    So typically, on a large database system the vendor recommendation will be to set vm.swappiness=0 to minimize memory pressure from filesystem caching, and to set the database buffers as high as the amount of memory you have in your system minus a small amount for the operating system.


  • I have 20GB in my current setup and it was never full. If anything gets swapped in this situation it means it needlessly slows me down.

    Not necessarily. Your memory also contains file backed pages (i.e. “file system cache”). These pages are typically not counted when determining “memory usage”, because they can always be discarded.

    It is often advantageous to keep frequently use files in cache in favor of unfrequently used memory pages.


  • I’ve never understood why GNU/Linux actually needs swap

    It doesn’t. It’s just good to have in most circumstances.

    Also, sidenote: “GNU” doesn’t apply here. Swapping is purely kernel business, no GNU involvement here.

    Okay, I created a 4G partition for it, having 32G of RAM. I never used all that RAM, but even so, stuff regularly ends up in swap. Why does the OS waste write cycles on my SSD if it doesn’t have to?

    Physical memory does not just contain program data, it also contains the filesystem cache, which is also important for performance and responsiveness. The idea is that some of the least recently used memory pages are sometimes evicted to swap in favor of more file caching.

    You can tweak this behavior by setting the vm.swappiness kernel parameter with sysctl. Basically higher values mean higher preference for keeping file backed pages in memory, lower values mean higher preference for keeping regular memory pages in memory.

    By default vm.swappiness = 60. If you have an abundance of memory, like a desktop system with 32G, it can be advantageous to lower the value of this parameter. If you set it to something low like 10 or 1, you will rarely see any of this paradoxical swap usage, but the system will still swap if absolutely necessary. I remember reading somewhere that it’s not a good idea to set it to 0, but I don’t remember the reason for that.

    Alternatively, there is no rule that says you can’t disable swap entirely. I’ve run a 32G desktop system without any swap for years. The downside is that if your 32G does run out, there will be no warning signs and the OOM killer will unceremoniously kill whatever is using the most memory.

    tl;dr just do this:

    sysctl vm.swappiness=10
    echo "vm.swappiness=10" > /etc/sysctl.d/99-swappiness.conf
    

  • I run a lot of VMs; I typically run 2 at the same time in addition to running other programs in the background, my usecase is more eccentric than most users in the Linux space which is already pretty niche

    If what you’re doing involves using close to all of your system memory, it does make sense to add swap. So your use case is a good example actually.

    I also have an old Arch PC that I use to run various VMs on (currently 6 VMs in use). It does have a swapfile, but the most swap I’ve ever seen in use is about 1GB.

    I’m using BTRFS with LUKS-based Full Disk Encryption, the last time I used swapfiles with BTRFS with FDE it was in 2019 and it was painful to say the least, I rememeber spending several weeks scouring Stack and the Arch forums in order to get it to work properly.

    Weird. Sounds like you may have painted yourself a bit into a corner by using BTRFS then. I use trusty old ext4 on top of LUKS FDE, no issues with swapfiles whatsoever.

    That brings me to another downside of swap partitions: encryption. You can leak sensitive data through your swap partition, so it should be encrypted. If you use a plain partition, without LUKS in between, information in your swap is exposed. So you need to do more configuration to setup LUKS on your swap partition.

    If you use a swapfile on an already encrypted filesystem though, you don’t have to worry about it.

    when would I even want to resize swap for a single system

    Maybe your requirements change (e.g. “I want to be able to hibernate”), maybe your memory configuration changes, maybe you’ve underestimated or overestimated how much swap you need.

    Case in point: the Arch PC I mentioned above only uses upto 1GB of swap, but it has a 16GB swapfile. This discussion has brought to my attention that perhaps I should downsize the swapfile a bit and free up disk space.

    you don’t really want to depend on swap if can

    That is my position too. It’s always better to have a properly sized system, or limit what you push on an existing system. High swap usage rarely results in a good experience.


  • 0 swap: which was pretty awful with constant unexpected system freezes/crashes

    I’ve run Arch without swap for many years without issues. The key of course is that you need enough RAM for what you are trying to do with your computer.

    There’s no reason why a 32GB RAM + 0GB swap system should have more problems than a 16GB RAM + 16GB swap system with the same workload. If anything, the former is going to run much better.

    swap file: finicky but doable

    What is finicky about a swap file?

    It’s just this:

    mkswap -U clear --size 4G --file /swapfile
    swapon /swapfile
    

    Done

    If anything it’s way easier to create a file in your filesystem than having to (re-)partition your drive to have a swap partition. Much more flexible too if you want to change your swap configuration in the future.





  • And for some reason if they are already refrigerated they need to stay refrigerated no matter how old.

    It has to do with washing. Eggs, fresh from a chicken’s poophole, have a protective layer around them that allows you to store them at room temperature. If you wash them though, the protective layer disappears and the egg shell becomes porous, and as a result you need to refrigerate them. If you buy eggs that are already refrigerated, they are likely refrigerated because they have been washed, so you should keep them refrigerated as well.




  • First of all, there really isn’t all that much story to the original Doom. There are a couple of paragraphs in a readme.txt file tucked away in the installation folder, and an ending screen after each episode… but that’s basically it.

    As I understood it, Doom 2016 is a re-imagining of Doom, so the universes are not canonically linked. Kinda like how The Thing From Another World (1956), which takes place in Alaska, isn’t canonically linked with The Thing (1982) which takes place on Antarctica.


  • The original DOS version of Doom runs at 35fps, exactly half of the 70Hz refresh rate of 320x200 VGA mode. I thought it felt really smooth back in the day, but it does feel weird and stuttery on modern systems when played through Dosbox. I get used to it after a bit, but still.

    Fortunately as Doom is open source, there are many enhanced Doom ports that lift this 35fps limit and allow it to run on modern machines without emulation. I usually play in GZDoom which can run at the max refresh rate of my monitor (144Hz), so it feels silky smooth.