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
-
Because it's stuff that isn't used anyway. You can decrease the inclination to swap.
cat /proc/sys/vm/swappiness (that's probably 60)
Edit /etc/sysctl.conf as root. Add/modify the following line:
vm.swappiness=25
(Or maybe 20, something like that.) -
^^ what he said. Or set it to 0. Or even disable swap if you don't want apps to use it
-
Swap is enabled by default for linux.
even if you disable it completly, and remove the swap partition setup in fstab, the kernel will still try to use it anyways.
Kubernetes for example, does *not* like swap. -
@magicMirror
> Swap is enabled by default for linux.
Is it though?
If you choose a fully automated install - then perhaps. But for all the setups I've installed manually, I had to explicitly specify a swap partition to use if I wanted one. -
@netikras No idea 🤷♂️.
Too many linux distros, and too many install options.....
The best imo, is to use a custom VM images for k8s clusters. -
Because caching regularly used disk content is better use of the memory than keeping never used pages there. The ratio can be configured by vm.swappiness.
-
because paging out memory that hasn't been accessed for (relative) eons frees the ram to be used as cache, which improves performance.
-
@IntrusionCM smth is going on. Seems like a surge of questions about swap lately. It wasn't there until like a month ago.
Did some country switch to all-linux? -
@IntrusionCM
> isn't a ram extension
to some extent it kind of is :) and still you haven't convinced me that swap's purpose is anything but *extending ram's* 'cold storage' for unused pages :) bcz the articles you referred to were explaining exactly that, i.e. how kernel does that with swap. -
@netikras
It's an extension to the memory available for the kernel - kernel memory, not RAM.
Nitpick, but it makes a difference.
And the kernel can not store everything in a swap - there are rules.
Nitpicky, again, but makes a difference.
An extension would mean to me that it can be used in the same way as RAM - which isn't possible.
It is not an substitute either, as the kernel requires RAM to boot.
Which brings me back to the beginning - it's a form of extension to the memory available for the kernel, not RAM. -
(If I'm currently sounding bitch, I'm having migraine like headaches at the moment. Pain makes me very ... Bitchy)
-
@IntrusionCM You bitch!!! :)
naah, you sound alright.
Just to be clear, only kernel can make memory allocations. An app does not know nor does it care what hides behind the term "memory", as long as there's some for it to allocate. Where do these pages go afterwards - ... meeh.. Not app's problems. So when you say it's a memory extension for kernel - that's both wrong and right, depending on the PoV :)
I would completely agree with you IF having more swap did not boost the available address space, i.e. apps could not overcommit RAM on swap's account. And kernel only used swap for its own business, having no effect on the applications' behaviour. But now.. a single app cannot overcommit RAM, but all the processes running on the system in total - can, when swap is enabled. -
@netikras Hm... Yes.
Though the application CAN tell the kernel what needs to be done.
Look at e.g. madvise and mlock.
That's why I think more of kernel memory management then RAM.
mmap with anon isn't swappable either, if my mushroom of brain isn't wrong.
So as you said - you usually don't use RAM, you use the kernels memory management system and all the shenanigans it offers. -
@IntrusionCM
could it be we disagree bcz we're looking at it from different perspectives?
from kernel's PoV - yes, it's not a RAM's extention, but rather a mechanism helping to reduce pressure on RAM. Pages in swap cannot be used directly - they still have to be moved back to ram before accessing them [though idk if that's true for non-data-read/write access].
From app's/user's PoV - I don't see how swap is different from RAM, as it is the same big memory pool. It asks the kernel to allocate a memory chunk - and the kernel allocates, regardless of whether ram is full or not [assuming there's enough space in swap]
does that sound right?
Gosh, I love how well brain works right after waking up :) -
@netikras might be.
Highly likely I would say.
Though - as mentioned - the app can absolutely say what it wants.
madvise / mmap / mlock as I said before. ;)
I'd guess that's where my point stems from. RAM is kinda useless without the kernel managing it - as u said.
But the kernels memory management is vastly more complex than "that's RAM, that's swap". I'd guess that's why I'm so nitpicky.
Kernel memory management is a fickle thing which can "entertain" one for days without understanding it at all.
Guess that's why this is one of the things I'd like to torture myself regularly with.
But in database and any complex server app, there is a certain need in my opinion to at least grasp the basics, otherwise you'll be royally fucked.
I'd guess that's the other reason I love and hate swap discussions.
It's an entirely different thing comparing desktop vs server / complex application use.
Swap and constant memory pressure is a thing that makes no fun in desktop apps, many user suffer from it cause they absolutely have no frigging clue how to use their resources probably.
Pisses me off regularly - cause it is just dumb.
But in server applications? That's not dumb. That's suicide.
Database running on constant memory pressure and wasting CPU cycles and burning IO coz one wasn't able to do simple mathematics? That's... Imho an reason for serious talk if the admin is fit for the job. After all, the database is suffering major performance penalties and thus every application based on the database is suffering. That's clusterfuck exponential.
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 ...
Linux nerds, here is a question,
I have a machine with 32 GB Ram, currently it is using 12.5 G and at the same time I see swap is used 1.55G/2.00G
why swap is used if i have enough Ram ?
question
linux