LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-07-2020, 11:10 AM   #1
SandaruLJ
LQ Newbie
 
Registered: Oct 2019
Location: Kurunegala, Sri Lanka
Distribution: Fedora
Posts: 7

Rep: Reputation: Disabled
Why does buffer cache build up cause unnecessary swapping?


(I'm using bold words to refer to 'free -h' columns)

I have Arch Linux installed on my laptop with 4GB RAM. When I'm copying a large file (or doing anything involving file operations), I can see the Mem: buff/cache increasing using 'free -h'. Regardless of how much RAM I'm using at the moment, buff/cache grows up until there's only about 100mb of Mem: free memory. Then, when the value of Mem: free goes below 100mb, the system starts swapping. Usually about 35mb of data gets swapped, and it stays around that number. Then, as the file is still being copied, the data amount in Swap: used fluctuates between 1-2 megabytes. If 35mb are swapped, it becomes 36mb after a few seconds, and then after another few seconds it returns to 35mb. This fluctuation affects the performance as it continues swapping in and out until the file is copied. I've experienced this behaviour on Arch, PopOS and Elementary OS. So I thought this was normal for linux until...

I recently installed Linux Mint and noticed that this doesn't happen on it. No matter how large a file I try to copy, Mem: buff/cache grows until Mem: free goes below 100mb, and then it stabilizes. Mem: free value fluctuates slightly by about 10 megabytes. In Mint, swapping doesn't occur while copying files.

How does this happen? Does Mint have special settings that prevent unnecessary swapping? If it does how do I apply them to Arch or any other distro?

PS: Sorry for my bad English and the terrible structure of the question. I tried my best to put this together.

Last edited by SandaruLJ; 01-07-2020 at 11:11 AM.
 
Old 01-11-2020, 08:27 AM   #2
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 16,292

Rep: Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322
What you need to read is the linux kernel documentation on swapping, if you're going to rebuild the kernel. Usually it's in the Documentation directory of the kernel source. Otherwise do what the rest of us do: use your computer without fixating on figures.

Linux isn't windows. No BSOD in linux! It can run hundreds of processes any of which can want a chunk of ram to avoid crashing, and linux might give them the same chunk of ram. Then when one of them actually starts writing to that ram, it has to juggle things around, and tries to keep blocks contiguous (=together), rather than spread all over. It never wants to use the last byte, and does different things depending on the pressure it's under. Programs may have asked for a buffer, and they fill unpredictably. So if youi can figure what it's up to with free -h, you're smarter than me.
 
2 members found this post helpful.
Old 01-11-2020, 08:49 AM   #3
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,849

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
probably you will find it interesting: www.linuxatemyram.com
 
1 members found this post helpful.
Old 01-27-2020, 04:19 AM   #4
SandaruLJ
LQ Newbie
 
Registered: Oct 2019
Location: Kurunegala, Sri Lanka
Distribution: Fedora
Posts: 7

Original Poster
Rep: Reputation: Disabled
Thanks for the replies! I found out that the unresponsiveness during swapping data is caused by a bug in the linux kernel starting from 5.3.0

The problem doesn't occur on Linux Mint because it uses kernel 5.0
 
  


Reply

Tags
buffer, cache, swapping



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Why does fs/buffer.c exist? Didn't the page cache and buffer cache merge in 2.4? bagelboy62 Linux - Kernel 2 12-14-2017 08:12 AM
LXer: Nouveau Driver Improves Buffer Swapping LXer Syndicated Linux News 0 03-02-2012 10:50 PM
Difference between page cache and buffer cache Nayaka Linux - Kernel 5 09-28-2011 08:23 AM
unit of cache swapping sulekha Linux - General 4 10-01-2010 07:26 PM
What is the difference between the free buffer and buffer in the buffer hash queue? Swagata Linux - Enterprise 0 05-25-2006 11:57 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:16 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration