this post was submitted on 04 Dec 2024
49 points (96.2% liked)

Linux

48624 readers
1584 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 5 years ago
MODERATORS
 

Not sure why that is, but I have 32 GB of RAM and I would like my system to utilize it as much as possible, but as you can see in the screenshot, the system is only using 5.66 GB of the physical RAM, but swap is still being used in a high number. Is this normal? Should I lower the swappiness to lower than 10? Should I let it be? Thanks
Here is the screenshot

top 46 comments
sorted by: hot top controversial new old
[–] [email protected] 31 points 1 week ago (4 children)

You should set it back to whatever it was. It shows 5.6 GB in active use and 19 GB used for cache. You're already using all your RAM, just not actively. You don't sit on 100% of the chairs in your house at once either. 3 GB swap used is very low usage, which is expected when you're not actively using a lot of memory.

Don't mess with things you don't understand, especially when you don't have an actual problem. You're going to end up breaking things. (Which, to be fair, is one way to learn, but at the cost of breakage.)

[–] [email protected] 58 points 1 week ago (5 children)

Don't mess with things you don't understand.

Don't listen to this advice. Messing with things you don't understand is how you learn your OS. Mess with it, break it, then RTFM and fix it. That's how ya learn!!

[–] gi1242 45 points 1 week ago* (last edited 1 week ago) (4 children)

you should especially do this on Friday 5:00pm in production, right before going on an international vacation with bad Internet.

[–] [email protected] 11 points 1 week ago

😂 I love this.

[–] TexasDrunk 7 points 1 week ago

I've had to explain to three different people that they're not getting a production window on Christmas Eve. I'm the only person in the office from the day after Christmas until January 2.

[–] [email protected] 2 points 1 week ago
[–] AnUnusualRelic 1 points 1 week ago

Just before a big presentation is also one of the best times. You have a few minutes to waste, why not spend then optimising stuff?

[–] [email protected] 9 points 1 week ago (1 children)

That's great if you treat your computer as a toy. But if you actually need it to do work then that's terrible advice.

Destroy a virtual machine first, not your actual computer.

[–] [email protected] 6 points 1 week ago

I have a whole machine that I don't touch for stuff like this to get my actual work done on. This one is for learning and fucking shit up. Lol

[–] [email protected] 8 points 1 week ago (3 children)

Or just RTFM first and learn without breaking stuff.

[–] [email protected] 6 points 1 week ago* (last edited 1 week ago)

Nah, without breaking stuff, you never really learn

Hands-on experience is important.

Edit: obviously don't do this with production machines, but I thought that was given...

[–] [email protected] 4 points 1 week ago (1 children)
[–] [email protected] 5 points 1 week ago (1 children)

pretty much. learning things without a corresponding "oh... shit." moment, just never quite stick with you the same way.

[–] [email protected] 4 points 1 week ago

This is 100% it. The sleepless nights I've spent hunting for solutions after nuking everything, taught me a great deal. It was even so much fun, too.

[–] [email protected] 4 points 1 week ago

No fun. Nothing learned.

[–] [email protected] 6 points 1 week ago (1 children)

Nah, homie, fucking shit up then spending your whole evening looking for solutions is what makes it so much fun. lol

[–] [email protected] 6 points 1 week ago

If your googling is about to take you to the arch wiki, you're having a good night!

[–] [email protected] 5 points 1 week ago (1 children)

tinkers with pulseaudio
"Why does my audio not work?"
tinkers more
"Okay I think it kinda works now?"
it breaks again
"fml"

I found the docs for pulseaudio and particularly for pipewire to be rather hard to use, personally. RTFM works if the manual is readable, but in these cases, the learning curve was very steep for me (and I still don't know that I properly understood what's going on, but it's working, so I've stopped tinkering for now).

[–] [email protected] 2 points 1 week ago

You're not really RTFM unless you're digging into source code comments

[–] [email protected] 15 points 1 week ago

While I appreciate your comment, I disagree on the last part. Fucking shit up is what got me into IT to make a decent living and take care of my family. All the fucking shit up is at home on my personal PC of course 😂

[–] extremeboredom 7 points 1 week ago

Your comment was great, until the last part. That's terrible advice. DO mess with things you don't understand, until you understand them!

[–] [email protected] 4 points 1 week ago* (last edited 1 week ago)

You're not going to cause any permanent damage to your system messing around with system settings.

[–] [email protected] 31 points 1 week ago (1 children)

Let it be. The people designing the OS most likely know better than you or anyone else in this thread. I know the urge to "tweak" things is strong, but some defaults are defaults for a good reason.

[–] [email protected] 15 points 1 week ago (1 children)

Pssshhh. I taught Torvalds how to code, how dare you. 😂

[–] WhyAUsername_1 5 points 1 week ago (1 children)

So it was @penquin all along!

[–] [email protected] 2 points 1 week ago

Shut up, private.

[–] [email protected] 11 points 1 week ago (1 children)

It is probably normal. Don't decrease your swappiness too much.

I think it happened the following way:

See the "cached" ram is taking 19 gigs. Theese cached ram improves performance by keeping frequently used system files on ram. So the actual occupied amount of ram would be 5+19 ≈ 25gb. Thoose system files might be used more than other app's ram so that they have higher priority to be in ram. So at the time you opened certain other applications, the total ram usage including cached might be a little over the availiable ram and likely got swapped. The once swapped thing won't be cleared immediately or with any much priority. I often see swapped contents remain even after closing a bunch of apps which gave empty space in ram.

So its just normal but is it using swap without once opening enough apps to fill the availiable space with used+cached? If so I would also be concerned

[–] [email protected] 7 points 1 week ago

Damn. I actually didn't even pay attention to the cached part, nor have I ever even known what it was for. Makes sense now. Thank you.

[–] patatahooligan 8 points 1 week ago

Yes, this is normal and it's a good thing (unless you've come across a bug). I don't know exactly what app the screenshot is showing, but I'm guessing that the caching shown is referring to the filesystem cache. The kernel is keeping a cache of files you are likely to access again so that it doesn't have to read them from storage again. So what you're seeing here is that some memory contents were moved to swap to make room for filesystem cache. This is because the kernel believes you're more likely to access those files again rather than the memory contents. If it's right, then this a performance improvement despite the fear surrounding swap usage.

Setting a low non-zero swappiness value is telling the kernel that memory contents have priority over filesystem cache for remaining in RAM, or conversely that file cache is more likely to be evicted from the RAM. A value of 100 would mean that they have equal priority. So that memory content must have been very stale to be evicted despite having a significantly higher priority to reside in RAM.

So:

  • don't worry about swap usage unless you're experiencing actual performance issues
  • for ssd's the value should be close to 100
  • for hdd's it should be low
  • if you're using both on your system, the default value of 60 is probably a decent approximation of the optimal value

Source: https://chrisdown.name/2018/01/02/in-defence-of-swap.html

[–] [email protected] 4 points 1 week ago

if you really feel the need to fuss with it then replace with swap on zram

[–] [email protected] 3 points 1 week ago (1 children)

how do you change swappiness?

[–] [email protected] 2 points 1 week ago

sudo nano /etc/sysctl.d/99-swappiness.conf
then add this line inside
vm.swappiness=10
Change the 10 any number you want

[–] [email protected] 3 points 1 week ago (2 children)
[–] [email protected] 1 points 1 week ago

Surprised I had to scroll so far to find this comment. I would be concerned about SSD longevity if my swap was doing that, but zram kind of negates that problem.

[–] [email protected] 1 points 1 week ago

I've always thought that zram was a Fedora thing. Lol.
I don't have it setup, no.

[–] RedWeasel 2 points 1 week ago

You probably just had a program(s) use a lot of ram and that pushed some processes to swap. When the system needs it, it will be moved back. I’d +1 on setting up zram. Can be setup easily on most distros.

[–] mvirts 2 points 1 week ago

I've been trying to run a stable system with never overcommit and no swap . It's impossible. this is the thing that may make me a kernel developer once I retire.

I've settled for tons of swap with never overcommit but I still can't do normal things sometimes.

The downside to swap is wearing out your disk and latency when swapping, it's good to have swap usage before ram is gone to let the system have more ram available for random allocations. My goal is to never need the oom killer, but it seems like many apps (chrome and FF mostly) basically require overcommit to function.

Right now my system has 30% ram used and is still keeping 700MB is swap. I would recommend to try benchmarking your settings but I don't do that myself so I don't know what to use 😅.

You can try disabling swap with swapoff, then your system is definitely maximizing your ram use, just be prepared for the oom killer to wreck your session.

[–] [email protected] 1 points 1 week ago
[–] [email protected] 1 points 1 week ago (1 children)

That looks a lot like task manager, what tool is that?

[–] [email protected] 1 points 1 week ago

Mission center. It's a gnome app. I used KDE plasma, but prefer this app over the plasma one.

[–] [email protected] 0 points 1 week ago (2 children)

swap is usually significantly slower than ram; are you certain that you wan to use that instead?

[–] [email protected] 5 points 1 week ago (1 children)

I think you misread, OP is saying the system is using to little ram and too much swap.

[–] [email protected] 1 points 1 week ago

that makes much more sense; thanks for the correction.

[–] [email protected] 2 points 1 week ago (2 children)

The other way around. I want the system to use all of my RAM. I paid good money for it, might as well use it all. Unused RAM is wasted RAM, right?

[–] [email protected] 1 points 1 week ago* (last edited 1 week ago)

i see it as more a capability that i don't always need beyond the minimum; but if you feel about it like this, you can also disable swap all together.

[–] phubarr 1 points 1 week ago

Have you ever tried just not having swap? Maybe don't have a swap partition and see what results you get. I think there's even a command that turns your swap completely off, too. Google "swapoff". Good luck my friend.