Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
@jonas-w s2disk and s2both ?
Or.. you know... preferring a computer slowing down over OOMKilling your apps with unsaved state -
j0n4s54352y@netikras yes but he said he has memory issues which means he hasn't enough RAM to run some programs. I think my swap only gets used for s2disk or s2both.
-
@jonas-w: Why would you really need swap
@jonas-w: which means he hasn't enough RAM to run some programs
Doesn't that kind of answer your own question...?
Also, swap is not used to run programs. Programs can only run on RAM. -
I only find compelling arguments to USE swap memory, regardless of whether used as a booster or a stopgap measure. I did create a swap partition for my Linux laptop 4 years ago, but I didn't know it was adjustable (see this article: https://linuxhint.com/swap_memory_l...). It looks like it may be interesting to alter those settings periodically to cache "old memory" every now and then
-
@webketje
> It enhances the overall performance of your system.
It does not. On the contrary - it slows down the machine considerably
> to cache "old memory" every now and then
That's a performance hit. You'd have to wait until those swapped pages are read back from the disk (HDD?) and loaded into RAM before a process could use them. And these pages aren't loaded all at once -- Linux only loads pages that the process is trying to actually access (with some read-ahead caching), which means your apps, that are even partially swapped-out, will be ssslllooooooowwwwwwww. Why would you want that?
I ONLY use swap for my personal devices - NEVER on servers/containers. And only to use as a storage for hibernation or a failsafe mechanism for unanticipated high usage of RAM. Should such an event happen, I swapoff and swapon back immediately after I stabilize mem usage to fit it all on RAM. -
Root825382yWhy do you need swap?
I agree with @jonas-w and @netikras — it’s a great stopgap when you need it, but it’s just a safety net. -
Okay, so to everyone here, this was apparently a sensitive subject. I'm no expert on the internals of Linux, but from what I've found on the internet swap is a crucial part of modern Linux distros to ensure they run smoothly. In my case I'm often touching the 16 GB line (as much RAM as I've got) and it causes my computer to freeze and become sluggish. So therefore I assumed I need swap. Perhaps it's not necessary and if so, please tell me. But from my research I need it.
@netikras @Root @webketje @jonas-w @Oktokolo -
@ScriptCoded If you're hitting actual USED ram limits of 16GB - then yes, you need swap. If there still are some gigs in buff/cache or available or free columns of `free -h` output - you may not need it.
Crucial -- that's a big fat NO. Swap ALWAYS slows down the machine. It's recommended to disable swap altogether in servers, more so on container hosts. For workstations, where the load/mem usage pattern is very unpredictable, having swap makes sense. Actually using swap will save your PC from crashes (some of them), but will cause your machine to run slower -
@ScriptCoded Swap is needed when running software uses more RAM than is actually installed. So if you are that sort of person, who likes to have _all_ the applications running all the time despite only using a few of them, swap might actually work well for you as it allows you to keep opening more and more opplications and files as long as you aren't actually using them all at the same time.
And the kernel might or might not let applications allocate more than the combined physical and swap memory depending on whether overcommiting¹ is enabled (it normally is, but within limits²).
So normally, you want to have a reasonably-sized swap available - but not actually using it.
¹https://en.wikipedia.org/wiki/...
²https://kernel.org/doc/html/... -
Maybe turn down the volume of the discussion a bit.....
Swap isn't inherently bad.
It's misunderstood. Especially in desktop systems.
Swap wasn't meant to be as an emergency "memory overflow solution".
That's what most people think swap is.
Which is fundamentally wrong. You might wanna hit your head a few times on the table to get rid of that thought.
https://chrisdown.name/2018/01/...
If you want an older, but very detailed explanation.
To give a short, but precise explanation for desktops: stop running a quadruple of memory hogging processes with the expectation that it runs fine.
Especially if you run IO bound memory hogging processes, as even an SSD (assuming it is on the same drive as your root partition) has it's limits.
That's even more true for servers - make your homework.
Find out what uses RAM, how much, monitor, be wary of spikes.
Don't calculate with 100 % - always leave room, cause surprises usually come in form of lil atomic explosions making your life very miserable.
Swap isn't bad - expecting a system to run smoothly while overexerting it's physical capabilities is bad.
Same goes e.g. for the long hyper threading discussions :) -
@netikras @Oktokolo @IntrusionCM Thanks for the clear and to the point explanations guys. Perhaps I should rather investigate what hogs all my RAM, but at least now I know a little bit about the implications of swap :)
Sleep tight -
@ScriptCoded Chances are that you actually need the stuff that hogs up your RAM. If you happen to need to run Docker desktop with multiple containers, multiple IDE instances, some PDFs, some Office, the occasional 3D modeling, CAD, video editing, or other RAM-hogging application and multiple browsers when developping, that can actually justify getting more than 16 GiB of RAM if possible.
You can always optimize and close applications as soon as they aren't needed anymore. Docker is configurable. Current browsers support bookmarks so you don't actually have to keep hundreds of tabs open, IDEs can be optimized for low memory footprints by sacrificing some very useful features...
But at the end, RAM isn't that expensive anymore and having to keep RAM-usage in mind can prevent you getting into the flow as much as any other annoyance. -
@IntrusionCM Hooolld ooonn...
> Swap wasn't meant to be as an emergency "memory overflow solution".
The article also says the same thing. But when you continue reading it -- it is in essence saying that SWAP is used to prevent problems when you overflow your memory.
The difference only is the perspective: the article says SWAP makes more room in your RAM for your other apps, so you could overcommit your RAM. Sysadmins say, that SWAP allows you to overcommit your RAM. Both agree that RAM overflows into SWAP.
IDK, it seems like the article says the same thing sysadmins do. Except the article explains how it actually works, and that it tries to prevent OOMKs, but then causes more problems when OOMKs are triggered. -
@Oktokolo
> RAM isn't that expensive anymore
Well, you're right, DIMMs aren't expensive, that's right. Replacing LPDDR DIMMs is VERY expensive.
Soo... buying a cheap (arguably) 64GB LPDDR DIMM and keeping it on your windowsill, because you can't resolder it, won't help me open more chrome tabs w/o being OOMKilled... :/ -
@netikras WTF - did they force you to use a... 😱 𝖑𝖆𝖕𝖙𝖔𝖕 😱 ?
Well, in that case, you have no choice than to optimize your workflow a bit. -
@Oktokolo well yes. Otherwise, it would be quite an adventure dragging the actual workstation home whenever I want to WFH
-
@netikras
There is one important part in the large wall of text ( :) )
"Well, this is precisely what swap is for. Swap is a storage area for these seemingly "unreclaimable" pages that allows us to page them out to a storage device on demand. This means that they can now be considered as equally eligible for reclaim as their more trivially reclaimable friends, like clean file pages, allowing more efficient use of available physical memory.
Swap is primarily a mechanism for equality of reclamation, not for emergency "extra memory". Swap is not what makes your application slow – entering overall memory contention is what makes your application slow."
Memory overflow or a high memory pressure is one of the reasons why swap might be used.
Another one is that the kernel realizes that the memory is infrequently used - it can be swapped out.
If it's on an SSD / NVME, access is still fast.
Here lies the "rotten" apple on why disabling swap might be a bad idea TM:
If sth is infrequently used, it could be swapped out - if swapping is not available, it needs to be purged / will be purged if memory pressure is high.
This can lead to sth. like a feedback loop:
As the kernel couldn't swap it out, it is purged. Process loads it back into memory - for the kernel it's new memory, so it is "fresh". Memory pressure rises. Kernel decides to clean up **older** (different) memory pages. Memory freed. Process kicks in again, wants the freed memory back in RAM....
And we start again. These kinds of feedback loops can be extremely annoying in sensitive applications, as the system has a constant memory pressure due to lacking a backing store for "infrequently" used pages.
This is e.g. a recipe for problems in databases. When a whole database is purged from memory and needs to be reinserted into memory, but that leads to purging another database from memory etc. you can get pretty funky statistics.
Hope it's understandable. -
@netikras There are non-crippling solutions to that problem: Remote access, one SSD on multiple machines, GIT on multiple machines.
-
@Oktokolo I know what you mean. Having a laptop is just... easier. All the other ways require a constant (and good, may I add) internet connection. Having a lappy I got used to the freedom and mobility, a side effect of which is sometimes finding myself in places where even GSM is a challenge, let alone GPRS or anything better. And I like it.
-
@netikras Contrary to popular belief, using one SSD on multiple machines doesn't require any Internet or other network connection - as long as you don't want to use it on multiple machines at the same time.
And don't let rumors about the physical impossibility of moving any mass storage device without moving a PC at the same time discourage you - it can be done and there is absolutely no risk of creating a spacetime anomaly by doing so. -
@Oktokolo I've read this now numerous times....
Do you need a bit of haloperidol?
I'm not sure if I can make sense of it, but this reads a lot like tinfoil head paranoia. XD -
@IntrusionCM What the fuck are you talking about?
He has shitty or no Internet connection at home and doesn't like to be constrained by a laptop when working at home or at the office. Having real desktop PCs at both places and just carrying the mass storage around might sound like a too lowtech solution to you - but how is it paranoid?! -
@Oktokolo ah. Now I understand it.
I just couldn't make sense of what you meant, wasn't meant offensive xD
I meant paranoid as the sentence with the rumors sounded... Extremely weird.
Like "I can't move my mass storage with me coz of all the secrets I have..."
Sounded a bit in the end like you drilled down the PC on a claymore, so if it gets moved, the term "nailed it" becomes very literal. -
@IntrusionCM Well, he wrote about all options requiring reliable Internet connectivity... 😇
-
@Oktokolo And then work using what? personal hardware?
There are so many reasons for companies to be against that. And enough reasons for employers to be against it as well.
Using two separate devices for personal and work uses should be the preferred setup. -
@netikras If you ask nicely, maybe they give you a workstation for WFH - or a Starlink subscription for reliable and fast remote access using the existing laptop as a terminal...
-
@Oktokolo you do realise that we're approaching a literally cosmic solution to a problem that could be solved by a... laptop. Right? :)
-
@netikras Yeah, not sure why i assumed that you somehow aren't fully satisfied with the laptop solution.
Related Rants
-
gururaju53*Now that's what I call a Hacker* MOTHER OF ALL AUTOMATIONS This seems a long post. but you will definitely ...
-
linuxxx65This guy at my last internship. A windows fanboy to the fucking max! He was saying how he'd never use anythi...
-
creedasaurus60Another dev on my team just got a new machine. Before he came in today I made two separate USB installers and ...
Oh my god I forgot to add swap to my install. No wonder I'm having memory issues 😅
rant
ram
linux
swap