View previous topic :: View next topic |
Do you use a swapfile, swap partition, or neither? |
Swapfile |
|
12% |
[ 8 ] |
Swap partition |
|
87% |
[ 57 ] |
|
Total Votes : 65 |
|
Author |
Message |
ukky Tux's lil' helper
Joined: 26 Feb 2023 Posts: 109 Location: Montreal, Canada
|
Posted: Sun Feb 26, 2023 8:17 pm Post subject: |
|
|
My primary desktop system would lock in a few weeks without a swap media.
Any other system I use never uses swap storage, though all systems have swap enabled (swap partition).
System will lock without swap media when total application memory plus buffers plus cache reaches physical RAM total.
On my primary desktop system, eventually all RAM will be used, and contrary to what I've read about the cache memory, cache will never be dropped in favor of memory allocation request from application.
Cache/buffer usage is growing fast when a lot of packages are recompiled, especially www-client/chromium, or when rebuilding everything from empty tree (emerge --emptytree).
Another case when system might need swap media is when system has 2GiB or less per CPU core when compiling www-client/chromium.
In one of the tests I was using 2GiB per CPU core, recompiling sys-devel/clang, www-client/firefox, app-office/libreoffice, and www-client/chromium. There was some swap space allocated when all these packages were recompiled.
With 0.7GiB per CPU core system did hang recompiling just sys-devel/clang. System was using 2.6GiB of swap memory when system was locked/hung.
I have noticed a change in cache/buffer memory usage when udev was unmerged from the system (using sys-fs/static-dev now, with CONFIG_DEVTMPFS enabled). This might also be related to removal of CONFIG_UEVENT_HELPER from kernel after udev was unmerged.
With udev unmerged, memory usage for buffers/cache doesn't grow as fast as when udev was installed.
When system starts using swap memory the solution is to drop cache, then turn swap off, and then turn swap on. |
|
Back to top |
|
|
eccerr0r Watchman
Joined: 01 Jul 2004 Posts: 9883 Location: almost Mile High in the USA
|
Posted: Sun Feb 26, 2023 9:01 pm Post subject: |
|
|
Buffers conditionally will be dropped depending if there is backing store (tmpfs in buffers cannot be dropped, but can be swapped!), but caches will be dropped under memory pressure. I can see these numbers going down as memory pressure increases. Note that if you see swap usage of 4GB and you have 4GB of buffers/cache, this is NOT abnormal: this could simply be optimal use of your RAM! Also note if your machine crashes when it runs out of memory, you'll have no way to tell it actually dropped your caches before it crashed and burned
Again, yes, having anonymous swap space is good. I was merging gcc-12 [+lto] on an 8GiB machine with -j5, and it went 12GB into swap during lto. The machine actually remained usable during the immense pressure, it was very slow but still responsive to ssh. Caches and buffers dropped significantly, down to less than 200MB or so each of the 8GiB RAM where it normally hovers around 2-3 GB. And yes, I let it finish, and finish it did -- and gcc[+lto] built just fine. Whether I'll let it do this again come next time I build gcc, that probably will be a resounding "no".
There is no reason to not have swap other than if you simply don't have the storage available. And no reason to drop caches unless if you're doing benchmarking. _________________ Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching? |
|
Back to top |
|
|
ukky Tux's lil' helper
Joined: 26 Feb 2023 Posts: 109 Location: Montreal, Canada
|
Posted: Sun Feb 26, 2023 9:23 pm Post subject: |
|
|
eccerr0r,
A while ago I had a similar question: Do we still need a swap memory if system has plenty of RAM?
The test confirmed that at least my primary desktop does need a swap memory.
The test was to disable any swap media and let system run for as long as it can.
The result: system did lock/hang when memory usage reached physical RAM size. I did not measure how much time it took, but I believe it was about two or three weeks. No benchmarking was performed during the test, it was regular desktop usage.
System had 5.33GiB per CPU thread in this case, and I have Conky running to monitor memory usage.
It may depend on usage. I tend to have multiple Firefox instances running as a separate processes, and each Firefox instance has quite a lot of tabs open. |
|
Back to top |
|
|
Hu Administrator
Joined: 06 Mar 2007 Posts: 23062
|
Posted: Sun Feb 26, 2023 10:33 pm Post subject: |
|
|
You do not need swap if you have sufficient RAM. However, swapping out low value content for high value cache can be beneficial. If your system encounters an out-of-memory event during normal use, then by definition you did not have sufficient RAM for everything you wanted to keep in memory at once. Add more RAM, use less memory, or add swap to handle the overflow. |
|
Back to top |
|
|
eccerr0r Watchman
Joined: 01 Jul 2004 Posts: 9883 Location: almost Mile High in the USA
|
Posted: Mon Feb 27, 2023 12:32 am Post subject: |
|
|
I notice some people keeping a zillion tabs open on their firefox or other browser. I would think those who do this would benefit greatly from having swap as those open tabs that are not being looked at are basically consuming memory for no good reason, and memory reclaimed for cache or other use. (Just hope those tabs are also not using cpu resources, which some do ...)
Use pattern makes a difference, and this is one of those that may benefit from swap.
(Me, I always close my browser tabs and windows when I'm done with them. Garbage collected and memory back into the pool for reuse.) _________________ Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching? |
|
Back to top |
|
|
g047 n00b
Joined: 22 Aug 2022 Posts: 23
|
Posted: Tue Feb 28, 2023 10:54 pm Post subject: |
|
|
Swap file, less headache for something that barely gets used. Easier to use on an encrypted disk too imo. |
|
Back to top |
|
|
mike155 Advocate
Joined: 17 Sep 2010 Posts: 4438 Location: Frankfurt, Germany
|
Posted: Wed Mar 01, 2023 12:36 am Post subject: |
|
|
No swap file, no swap partition, no swap at all.
RAM is cheap nowadays: last week, I bought 32GB RAM for less than 100 US-$. |
|
Back to top |
|
|
mistah_monocle n00b
Joined: 04 Mar 2023 Posts: 12 Location: Southern US
|
Posted: Tue Mar 14, 2023 1:21 pm Post subject: |
|
|
I just gave myself a swap partition twice the size of my ram like the install guide says lol. Im still learning
But so far it's never been used. I have 8G of ram and 16G of swap, which I now realize might be insane overkill.
But it doesn't matter to me cause I never even come close to using most of my disk space anyway, and I like having the swap space there, just in case I ever need it. _________________ doogenhaj |
|
Back to top |
|
|
NeddySeagoon Administrator
Joined: 05 Jul 2003 Posts: 54799 Location: 56N 3W
|
Posted: Tue Mar 14, 2023 2:54 pm Post subject: |
|
|
mistah_monocle,
Swap is used for hibernate even then, swap the size of RAM is enough as the hibernate image is compressed.
The kernel has several ways of swapping. The swap partition/file is only one.
Its good to have a small swap space so you get warning of pressure on RAM.
All swapping slows things down, its just that swap space is visible
Having swap and not using it is harmless. Not having swap and needing it, forcing the kernel to swap other ways is bad, as you might think your shiny new 96 core Eypc was faulty. _________________ Regards,
NeddySeagoon
Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail. |
|
Back to top |
|
|
mistah_monocle n00b
Joined: 04 Mar 2023 Posts: 12 Location: Southern US
|
Posted: Wed Mar 15, 2023 1:43 am Post subject: |
|
|
Ahh, someday I'll upgrade and get to experience Gentoo on something better than an old core 2 _________________ doogenhaj |
|
Back to top |
|
|
eccerr0r Watchman
Joined: 01 Jul 2004 Posts: 9883 Location: almost Mile High in the USA
|
Posted: Wed Mar 15, 2023 2:29 am Post subject: |
|
|
I'm still using a Core2 Quad... actually several Core2 Quads and a Xeon X3000...
As earlier I have 16GB swap on my 8GB (DDR2) RAM machine.
Too bad I cannot put more RAM in this machine, hence depending on swap.
Been RAM limited, my conundrum is whether I should swap my core2 quad with an Atom board that has 16GB DDR3 RAM. More RAM, but it's a slower CPU... _________________ Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching? |
|
Back to top |
|
|
sdauth l33t
Joined: 19 Sep 2018 Posts: 671 Location: Ásgarðr
|
Posted: Wed Mar 15, 2023 6:42 am Post subject: |
|
|
I'm using a swapfile for all my machines. The only one that is actually used though (during GCC upgrade especially (pgo+lto)) is the one on my NAS (Xeon L5408 and 4GB of DDR2, only one slot of ram so can't go higher than that) |
|
Back to top |
|
|
user Apprentice
Joined: 08 Feb 2004 Posts: 214
|
Posted: Wed Mar 15, 2023 7:48 am Post subject: |
|
|
neither.
Code: | # free -h
total used free shared buff/cache available
Mem: 62Gi 22Gi 10Gi 1.0Mi 28Gi 38Gi
Swap: 8.0Gi 3.5Gi 4.5Gi
# zramctl
NAME ALGORITHM DISKSIZE DATA COMPR TOTAL STREAMS MOUNTPOINT
/dev/zram1 lz4 20G 97.9M 11.2M 14.2M 16 /tmp
/dev/zram0 zstd 8G 3.5G 700.7M 726.1M 16 [SWAP]
|
|
|
Back to top |
|
|
Syl20 l33t
Joined: 04 Aug 2005 Posts: 621 Location: France
|
Posted: Fri Mar 17, 2023 7:38 pm Post subject: |
|
|
Hu wrote: | You do not need swap if you have sufficient RAM. |
Interesting, but I'd say : "If you don't need swap, then you have too much RAM".
I am surprised when I'm reading comments saying "my computer have billons of petabytes of RAM, so I don't need swap". But... am I the unique user who chose Gentoo among others to avoid needing those indecent amounts of useless resources ?
My most loaded server runs, in a hardened (then not so optimized) Core2Quad server :
- 1 Commafeed instance (java + postgreSQL),
- 1 Nextcloud instance (apache + PHP + postgreSQL + redis),
- 1 Firefly III instance (apache + PHP + postgreSQL + redis),
- 1 Keeweb instance (apache),
- 1 Mozilla Syncserver instance (python CGI + postgreSQL),
- 1 shared distfiles network filesystem (Samba),
- 1 Apt-Cacher NG instance (Gentoo package),
and :
Code: | # free -h
total utilisé libre partagé tamp/cache disponible
Mem: 3,8Gi 875Mi 528Mi 218Mi 2,4Gi 2,3Gi
Partition d'échange: 2,0Gi 0B 2,0Gi |
My workstations....
1/ mine (gentoo + XFCE) :
Code: | $ uptime
20:11:44 up 43 days, 2:36, 4 users, load average: 0,84, 1,18, 1,08
$ free -h
total utilisé libre partagé tamp/cache disponible
Mem: 19Gi 2,4Gi 3,0Gi 268Mi 14Gi 16Gi
Partition d'échange: 8,0Gi 32Mi 8,0Gi |
2/ my wife's (LMDE + Mate) :
Code: | $ uptime
20:14:14 up 51 days, 10:42, 2 users, load average: 2,82, 1,94, 1,66
$ free -h
total utilisé libre partagé tamp/cache disponible
Mem: 7,4Gi 3,5Gi 631Mi 780Mi 3,3Gi 2,9Gi
Partition d'échange: 4,0Gi 128Mi 3,9Gi |
Of course I need swap. Anyway, my main bottleneck is my terrible internet bandwidth. |
|
Back to top |
|
|
nikolis Apprentice
Joined: 21 Aug 2003 Posts: 200 Location: Athens
|
Posted: Tue Mar 21, 2023 10:08 pm Post subject: |
|
|
My main system has 64gb ram so it does not need swap today. I don't use hibernate. |
|
Back to top |
|
|
linux_os2 Apprentice
Joined: 29 Aug 2018 Posts: 258 Location: Zedelgem Belgium
|
Posted: Fri Apr 28, 2023 5:59 pm Post subject: |
|
|
swap partition. never used: 128G ram. |
|
Back to top |
|
|
CooSee Veteran
Joined: 20 Nov 2004 Posts: 1507 Location: Earth
|
Posted: Sat Apr 29, 2023 1:52 am Post subject: |
|
|
nikolis wrote: | My main system has 64gb ram so it does not need swap today. I don't use hibernate. |
me too - 32GB RAM - no suspend or hibernate.
_________________ " Die Realität ist eine Illusion, die durch Mangel an ehrlicher Kommunikation entsteht "
---
" Der Mensch ist von Natur aus neugierig, was am Ende übrig bleibt ist die Gier " |
|
Back to top |
|
|
enhaced n00b
Joined: 10 Mar 2022 Posts: 26
|
Posted: Tue May 09, 2023 1:18 am Post subject: Re: Do you use a swapfile, swap partition, or neither? |
|
|
Trademark97 wrote: | Which one do you use? If you use either a swapfile or swap partition, why did you choose that particular swap method? If you don't use either, why did you decide not to use swap?
Personally, I've been using a swapfile for easier resizing (I use XFS as my filesystem and so resizing is tricker than it would be otherwise). |
Partition, I've been using Linux since 2010 for servers and as my daily driver since 2021 (pretty late ik) and I've always used a swap partition, I don't see why I would change it for a swapfile either _________________ addict with a pen |
|
Back to top |
|
|
maalth Tux's lil' helper
Joined: 06 Jun 2003 Posts: 76 Location: Can't tell you...
|
Posted: Sun May 21, 2023 5:35 pm Post subject: |
|
|
I use a 16 GB swap partition. This particular system has 64 GB memory. I've never even come close to using it. My older system I have a 64 GB swap on the HDD. I can't add any more memory to that system and I use it for testing configurations. The swap came in handy for that system because the QT web compile complained about not having enough physical ram, but physical ram and swap was enough. _________________ Screw you guys, I'm going home... |
|
Back to top |
|
|
szatox Advocate
Joined: 27 Aug 2013 Posts: 3489
|
Posted: Sun May 21, 2023 8:44 pm Post subject: |
|
|
maalth wrote: | I use a 16 GB swap partition. This particular system has 64 GB memory. [..]the QT web compile complained about not having enough physical ram[..] |
So, basically... Your MAKEOPS -j value is over 9000 |
|
Back to top |
|
|
figueroa Advocate
Joined: 14 Aug 2005 Posts: 3007 Location: Edge of marsh USA
|
Posted: Tue May 23, 2023 4:05 am Post subject: |
|
|
As a general rule, I always set a swap partition. I put it on a secondary hard drive if one exists. Usually at the end of the drive. On my primary desktop (in sig, below) with 16 GB of RAM, I don't really need swap and it's almost not used at all. It's just for insurance. I don't hibernate. The size of my current swap partition is somewhat arbitrary.
Current memory use:
Code: | $ free -h
total used free shared buff/cache available
Mem: 15Gi 5.8Gi 1.6Gi 21Mi 8.2Gi 9.5Gi
Swap: 8.5Gi 38Mi 8.5Gi |
The reported used swap 38Mi almost never changes. _________________ Andy Figueroa
hp pavilion hpe h8-1260t/2AB5; spinning rust x3
i7-2600 @ 3.40GHz; 16 gb; Radeon HD 7570
amd64/23.0/split-usr/desktop (stable), OpenRC, -systemd -pulseaudio -uefi |
|
Back to top |
|
|
pandoraxero n00b
Joined: 15 Nov 2009 Posts: 56 Location: USA. Southeast
|
Posted: Fri May 26, 2023 8:38 pm Post subject: |
|
|
My use case does not normally require me to use swap at all. I have systems with 32 and 64GB of RAM.
Additionally, if I did have swap it would be on an SSD, and that's just generally a bad idea.
However, if I did have swap, it would be its own partition, not a file. |
|
Back to top |
|
|
wayfly n00b
Joined: 10 Jul 2023 Posts: 2
|
Posted: Sun Jul 23, 2023 4:59 pm Post subject: |
|
|
Yes, I use swap partition, But in fact I don’t use it too often. Because 16G is enough for me. After all I did’t want play game in linux (Please forgive my English is not so well ) _________________ Compared to a star, we are like mayflies, fleeting ephemeral creatures who live out their whole lives in the course of a single day. |
|
Back to top |
|
|
ChrisJumper Advocate
Joined: 12 Mar 2005 Posts: 2403 Location: Germany
|
Posted: Wed Jul 26, 2023 9:15 pm Post subject: |
|
|
Right now my 8 GB Swapfile is not used. But when i Compile my World Update and have large Packages or some Rainbow Table to calculate, the Swap will be need. Maybe for some minor Applications like Browser, Open Documents or my stopped Playlist or some SSH/screen/TMUX-Session.
I feel better with one, cause the system could be have a crash or a Memory-Drain, and freeze every second. So i want to have the possibility to use the Magic Keys with REISUP to Reboot.
Swap was designed for the system to reject a HOLD or Freeze at some Point. It gets ugly slow, but still respond and you still have a responding system. So have some even if you don't need it in 99%. |
|
Back to top |
|
|
wwdev16 n00b
Joined: 29 Aug 2018 Posts: 53
|
Posted: Thu Jul 27, 2023 10:51 pm Post subject: |
|
|
Unencrypted swap has the potential to leave secret keys on the disk.
No swap on any of our systems as none hibernate and we use a build host with plenty of ram for package building. W/o swap, one less detail for system admin. |
|
Back to top |
|
|
|