Do you use more memory to reduce the swap file size in Linux?

GWGeorge007
GWGeorge007
Joined: 8 Jan 18
Posts: 3,035
Credit: 4,940,891,023
RAC: 882,062
Topic 227461

I have noticed in Einstein that there is what I consider to be an excessive amount of "Peak Swap Size", as in this file of mine:

 


Task 1277396184

Name: LATeah3012L07_748.0_0_0.0_30493080_0

Workunit ID: 632849162

Created: 20 Apr 2022 21:33:02 UTC

Sent: 20 Apr 2022 22:30:53 UTC

Report deadline: 4 May 2022 22:30:53 UTC

Received: 21 Apr 2022 0:00:27 UTC

Server state: Over

Outcome: Success

Client state: Done

Exit status: 0 (0x00000000)

Computer: 12895648

Run time (sec): 122.80

CPU time (sec): 120.74

Peak working set size (MB): 228.75

Peak swap size (MB): 6127.01

Peak disk usage (MB): 0.02

Validation state: Valid

Granted credit: 3,465

Application: Gamma-ray pulsar binary search #1 on GPUs v1.28 (FGRPopencl2Pup-nvidia)
x86_64-pc-linux-gnu


 

When checking my own swap file size in Linux Ubuntu 20.04.3 LTS, I get this: 

 



george@GWG-PC3:~$ free -h

              total        used        free      shared  buff/cache   available

Mem:           31Gi       4.7Gi       5.9Gi        55Mi        20Gi        26Gi

Swap:         2.0Gi       363Mi       1.6Gi

george@GWG-PC3:~$



 

I'm wondering if I were to increase my memory would I be reducing the amount of "swapping" back and forth of the files so that they can be completed as Valid faster.

As it is now, I'm running a 5950X using a SAMSUNG 970 Plus SSD 1TB M.2 NVMe as my boot drive and for BOINC with 32GB of DDR4-3600 CL14 DRAM, so I think it is fairly fast.

Can I make it run faster?







George

Proud member of the Old Farts Association

Keith Myers
Keith Myers
Joined: 11 Feb 11
Posts: 4,956
Credit: 18,618,882,004
RAC: 5,625,249

Yes you can increase your

Yes you can increase your swap size.  But it won't make the tasks run any faster.

You can increase your memory but it won't make tasks run much faster.

I have all the Ryzens on 32GB same as you.  I have a swap file of 6GB on this daily driver and I still see swap activity.

Only on the Epyc hosts with 128GB do they show no activity or usage of the default 2GB swap file.

 

GWGeorge007
GWGeorge007
Joined: 8 Jan 18
Posts: 3,035
Credit: 4,940,891,023
RAC: 882,062

Keith Myers wrote: Yes you

Keith Myers wrote:

Yes you can increase your swap size.  But it won't make the tasks run any faster.

You can increase your memory but it won't make tasks run much faster.

I have all the Ryzens on 32GB same as you.  I have a swap file of 6GB on this daily driver and I still see swap activity.

Only on the Epyc hosts with 128GB do they show no activity or usage of the default 2GB swap file.

So even if I were to increase my memory to 128GB, my system would still be "swapping" files on my SSD?

Frankly, I am having a bit of trouble seeing the benefit of increasing the swap file size.  That just gives it more room to swap out files from memory and I want to have less swapping activity.

George

Proud member of the Old Farts Association

Ian&Steve C.
Ian&Steve C.
Joined: 19 Jan 20
Posts: 3,927
Credit: 45,761,692,642
RAC: 63,848,965

if you have enough system

if you have enough system memory, and you don't think you'll ever be in a situation of running out, you can delete the swap entirely.

_________________________________________________________________________

GWGeorge007
GWGeorge007
Joined: 8 Jan 18
Posts: 3,035
Credit: 4,940,891,023
RAC: 882,062

When checking my own swap

When checking my own swap file size in Linux Ubuntu 20.04.3 LTS, I get this: 

 


george@GWG-PC3:~$ free -h

              total        used        free      shared  buff/cache   available

Mem:           31Gi       4.7Gi       5.9Gi        55Mi        20Gi        26Gi

Swap:         2.0Gi       363Mi       1.6Gi

george@GWG-PC3:~$


 

What puzzles me is my memory is showing that I have 32/31GB total, and I'm using just 4.7GB with 5.9GB "free".

Could you describe to me what is the "shared", "buff/cache" and "available" memory listed?  The numbers just don't add up.

And if I don't kill the swap file altogether when adding more ram, will I just use the swap file because it's there?

George

Proud member of the Old Farts Association

Keith Myers
Keith Myers
Joined: 11 Feb 11
Posts: 4,956
Credit: 18,618,882,004
RAC: 5,625,249

Buffers Are used by

  • Buffers

    Are used by programs with active I/O operations, i.e. data waiting to be written to disk




  • Cache

    Is the result of completed I/O operations, i.e. buffers that have been flushed or data read from disk to satisfy a request.



As I mentioned in my previous post, with 128GB of memory I haven't touched the swap file once. I could just as easily remove it entirely. Ubuntu installs a 2GB swap file by default whether there is little or a lot of memory.

The only reason I increased mine is because the daily driver was occasionally using more than the 2GB because of all the stuff running on it. The Boinctasks history and the Gridcoin wallet putting the extra demand on the memory pool. This host is the only one I needed to increase the swap file size.

 

Keith Myers
Keith Myers
Joined: 11 Feb 11
Posts: 4,956
Credit: 18,618,882,004
RAC: 5,625,249

Ian&Steve C. wrote: if you

Ian&Steve C. wrote:

if you have enough system memory, and you don't think you'll ever be in a situation of running out, you can delete the swap entirely.

In the latest distros and kernels, they improved the oomd driver so that the kernel does not get into a panic situation when you run out of memory.  Helpful for 1GB Rpi's and such.  Plus, it acts smarter and will kill off unnecessary processes to relieve the memory pressure.  All to keep the kernel happy and the host running.

George, I don't know why you are worrying so much.  Linux is very smart about memory management.

With the system installed on a M.2 SSD, any swap activity, if needed at all, is going to be very fast and have very minimal impact on the rest of the system processes.

 

Boca Raton Community HS
Boca Raton Comm...
Joined: 4 Nov 15
Posts: 235
Credit: 10,137,655,586
RAC: 24,039,791

Ian&Steve C. wrote: if you

Ian&Steve C. wrote:

if you have enough system memory, and you don't think you'll ever be in a situation of running out, you can delete the swap entirely.

 

Does that only apply to Linux or also Windows? Is there a benefit to deleting it?

GWGeorge007
GWGeorge007
Joined: 8 Jan 18
Posts: 3,035
Credit: 4,940,891,023
RAC: 882,062

Quoting Keith: "George, I

Quoting Keith:

"George, I don't know why you are worrying so much.  Linux is very smart about memory management.

With the system installed on a M.2 SSD, any swap activity, if needed at all, is going to be very fast and have very minimal impact on the rest of the system processes."

I am not "worrying so much", I was just wondering (aloud?) about the cache and swap file size and trying to see if it made any difference in speed for Einstein with the CPU stage of GPU usage.  I spend about 20/30 secs in CPU mode before I get another GPU task for my 3080.

George

Proud member of the Old Farts Association

Ian&Steve C.
Ian&Steve C.
Joined: 19 Jan 20
Posts: 3,927
Credit: 45,761,692,642
RAC: 63,848,965

Boca Raton Community HS

Boca Raton Community HS wrote:

Ian&Steve C. wrote:

if you have enough system memory, and you don't think you'll ever be in a situation of running out, you can delete the swap entirely.

 

Does that only apply to Linux or also Windows? Is there a benefit to deleting it?

you can do it on Windows too. Windows calls it the pagefile. you can select an option in the system settings under virtual memory to remove it.

no performance benefit in doing so. but it'll reclaim some disk space on your OS drive.

_________________________________________________________________________

Keith Myers
Keith Myers
Joined: 11 Feb 11
Posts: 4,956
Credit: 18,618,882,004
RAC: 5,625,249

Boca Raton Community HS

Boca Raton Community HS wrote:

Ian&Steve C. wrote:

if you have enough system memory, and you don't think you'll ever be in a situation of running out, you can delete the swap entirely.

 

Does that only apply to Linux or also Windows? Is there a benefit to deleting it?

No.  No benefit.  OS's are smart in their memory management.  Best to let them do their normal stuff as designed by default for almost all use cases.

 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.