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 |
Trademark97 n00b
Joined: 08 Nov 2017 Posts: 3 Location: somewhere in Alabama
|
Posted: Sat Jan 28, 2023 5:35 am Post subject: Do you use a swapfile, swap partition, or neither? |
|
|
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). _________________ devout linux user since 2010
devout gentoo user since november 2017
never going back to Windows |
|
Back to top |
|
|
spica Guru
Joined: 04 Jun 2021 Posts: 329
|
Posted: Sat Jan 28, 2023 5:51 am Post subject: |
|
|
There's no Neither option in the poll.
IMO with 16+ RAM the swap only does a wear to SSD.
Swapfile can be turned on any time if the question is a lack of RAM.
Those who want "hibernation to swap" they obviously use a partition. |
|
Back to top |
|
|
APolozov Apprentice
Joined: 28 Sep 2006 Posts: 194 Location: Voronezh, Russia
|
Posted: Sat Jan 28, 2023 8:23 am Post subject: |
|
|
I am using a swapspace (dynamic swap manager) + zswap kernel option. _________________ Excuse my bad English, I only study it. |
|
Back to top |
|
|
NeddySeagoon Administrator
Joined: 05 Jul 2003 Posts: 54577 Location: 56N 3W
|
Posted: Sat Jan 28, 2023 9:48 am Post subject: |
|
|
Trademark97,
I use both :) but I suppose the real answer is neither.
If I plan ahead I use a partition, or actually a swap logical volume.
When i need swap for diagnostics, its a swap file, as its only for the duration of the diagnostics.
The kernel uses the partition/logical volume raw, there is no filesystem code involved.
A swap file is marginally slower as all the IO has to go through the filesystem layer.
My main system has 128G RAM because I don't plan to upgrade it, so it does not need swap today. I don't use hibernate.
In 10 or 12 years, memory requirements will grow, as they always have, so I may need to add swap within the lifetime of this system. _________________ Regards,
NeddySeagoon
Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail. |
|
Back to top |
|
|
pa4wdh l33t
Joined: 16 Dec 2005 Posts: 881
|
Posted: Sat Jan 28, 2023 10:54 am Post subject: |
|
|
I use swap partitions by default. For sizing i usually choose a sensible amount based on the system's real memory and amount of storage available. For my desktop this means it has the same amount of swap as memory, my Raspberry Pi has more swap than memory.
If i somehow need to expand swap during the lifetime of the system (which so far has never happened) i'll use LVM where possible or a swap file when LVM is not available. _________________ The gentoo way of bringing peace to the world:
USE="-war" emerge --newuse @world
My shared code repository: https://code.pa4wdh.nl.eu.org
Music, Free as in Freedom: https://www.jamendo.com |
|
Back to top |
|
|
asturm Developer
Joined: 05 Apr 2007 Posts: 9259
|
Posted: Sat Jan 28, 2023 11:21 am Post subject: |
|
|
file. I have stopped obsessing over the ideal partitioning layout years ago when SSDs arrived. |
|
Back to top |
|
|
AJM Apprentice
Joined: 25 Sep 2002 Posts: 195 Location: Aberdeen, Scotland
|
Posted: Sat Jan 28, 2023 11:56 am Post subject: |
|
|
I want to vote neither but there's no option for that (I want to make a political joke here but will refrain!)
If I have a memory constrained system I just use enable a swapfile as required but have got on far better without swap for years now (since RAM became so relatively cheap.) My laptop has a swap partition for hibernation purposes. |
|
Back to top |
|
|
Suicidal l33t
Joined: 30 Jul 2003 Posts: 959 Location: /dev/null
|
Posted: Sat Jan 28, 2023 1:39 pm Post subject: |
|
|
I have a partition configured, but I also have 32 GB of ram. I’ve never seen it get used, even in an emerge -e @world with MAKEOPTS=“-j25 -l22” |
|
Back to top |
|
|
mv Watchman
Joined: 20 Apr 2005 Posts: 6780
|
Posted: Sat Jan 28, 2023 2:24 pm Post subject: |
|
|
swap partition + zswap + (sometimes for a part) zram/swap with a lower priority.
I have only 8GB, so ram is an issue for large projects even with -j3. Sometimes I experienced a slight performance improvement when adding a small amount of zram in a lower priority swap partition, sometimes I think that I had actually bugs with it (or with the combination with zram?), so I sometimes toggled the state. |
|
Back to top |
|
|
steve_v Guru
Joined: 20 Jun 2004 Posts: 409 Location: New Zealand
|
Posted: Sat Jan 28, 2023 3:41 pm Post subject: |
|
|
Swap partition + zswap. earlyoom too, because linux handling of memory pressure under interactive workloads still blows, and a notification on the desktop to the effect of "low memory, killing process xyz" before the system slows to a crawl is kinda nice. _________________ Once is happenstance. Twice is coincidence. Three times is enemy action. Four times is Official GNOME Policy. |
|
Back to top |
|
|
Anon-E-moose Watchman
Joined: 23 May 2008 Posts: 6145 Location: Dallas area
|
Posted: Sat Jan 28, 2023 4:39 pm Post subject: |
|
|
Don't have any swap set up, 64g mem at the moment, plenty for my uses without a swap.
BUT if I had to use a swap, I'd set up a file on my nvme, while I might lose a little performance with file vs partition,
since I'd be using an nvme that's not much of a concern. _________________ PRIME x570-pro, 3700x, 6.1 zen kernel
gcc 13, profile 17.0 (custom bare multilib), openrc, wayland |
|
Back to top |
|
|
apiaio Guru
Joined: 04 Dec 2008 Posts: 426
|
Posted: Sat Jan 28, 2023 4:50 pm Post subject: |
|
|
I use swap partition, but I believe, that it has never been used. |
|
Back to top |
|
|
Gatsby Tux's lil' helper
Joined: 18 Jan 2010 Posts: 121 Location: 127.0.0.1
|
Posted: Sat Jan 28, 2023 6:38 pm Post subject: |
|
|
Swap partition + swap file. _________________ "Its your Gentoo, your way. When it breaks, you can keep all the pieces."
-- NeddySeagoon@forums.gentoo.org |
|
Back to top |
|
|
mrbassie l33t
Joined: 31 May 2013 Posts: 821 Location: over here
|
Posted: Sat Jan 28, 2023 7:22 pm Post subject: |
|
|
I've voted partition but it's really zram and a zvol (I know you shouldn't do the latter, but I did and I can't be arsed to repartition. I've 16 gigs of ram and it's an 8/8 split. It's a cludge but it's it's not as crap as it was with just the zvol). |
|
Back to top |
|
|
sublogic Apprentice
Joined: 21 Mar 2022 Posts: 269 Location: Pennsylvania, USA
|
Posted: Sun Jan 29, 2023 3:11 am Post subject: |
|
|
On an old laptop, swap and hibernation to a logical volume. And zswap. The poor thing has only (hah!) 1GB of RAM. ionice -c idle is your friend.
On my desktop, swap to LVM also. 32 GB on that one, so Code: | $ swapon --show
NAME TYPE SIZE USED PRIO
/dev/dm-4 partition 64G 0B -2 | I've never seen more than 0B used. I keep the swap anyway, in case I want to hibernate to rearrange power cables or some such. |
|
Back to top |
|
|
szatox Advocate
Joined: 27 Aug 2013 Posts: 3408
|
Posted: Sun Jan 29, 2023 3:28 am Post subject: |
|
|
My system is on LVM, so I guess neither.
Stable diffusion can get really hungry cranking those pics |
|
Back to top |
|
|
eccerr0r Watchman
Joined: 01 Jul 2004 Posts: 9818 Location: almost Mile High in the USA
|
Posted: Sun Jan 29, 2023 3:40 am Post subject: |
|
|
Both, depending on machine and situation. I tend to use files recently so it's easier to manage them but a little harder to resume from (for hibernation).
I think LVM volumes easily qualify as 'partition' for most intents and purposes, except for resume from hibernation... _________________ Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching? |
|
Back to top |
|
|
allistarM Tux's lil' helper
Joined: 22 Jul 2004 Posts: 141
|
Posted: Sun Jan 29, 2023 4:02 am Post subject: |
|
|
I normally don't use either because I have 64Gb of RAM. However, when running IntelliJ x 2 and compiling Chromium it can run out of memory, so I add 32Gb of swap space via a swap file which is on a RAID 10 spinning disk array. |
|
Back to top |
|
|
gtwrek Tux's lil' helper
Joined: 10 Mar 2017 Posts: 110 Location: San Jose, CA
|
Posted: Mon Jan 30, 2023 3:29 pm Post subject: |
|
|
Swapfile, turned on, only when I need it (i.e. during world updates). 16 GB physical RAM. No real reason swapfile vs partition, other than I didn't expect to need swap at all when I setup my partitions. But emerging GCC, LLVM, Rust, and chromium (amongst others) starting getting more and more memory hungry... So added a swapfile, and "swapon; emerge; swapoff" in my portage update flow. The swapfile is on my large spinning rust disk. |
|
Back to top |
|
|
eccerr0r Watchman
Joined: 01 Jul 2004 Posts: 9818 Location: almost Mile High in the USA
|
Posted: Mon Jan 30, 2023 4:14 pm Post subject: |
|
|
For those who "turn swap on when doing big jobs" -- I don't understand why. I just leave swap on all the time whether I need it or not. I don't have gobs of memory, but most of the time when I'm not building big packages, I don't need the swap (other than for hibernation) but I leave it on all the time.
It's a "just in case" - there when I need it, don't need to think about it, it's there, ready.
Just trying to dispel the myth that swap is bad even when you have gobs of memory... it's not a bad thing, and great for sloppy software programmers these days that leak memory. _________________ Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching? |
|
Back to top |
|
|
asturm Developer
Joined: 05 Apr 2007 Posts: 9259
|
Posted: Mon Jan 30, 2023 4:18 pm Post subject: |
|
|
^exactly that. |
|
Back to top |
|
|
gtwrek Tux's lil' helper
Joined: 10 Mar 2017 Posts: 110 Location: San Jose, CA
|
Posted: Tue Jan 31, 2023 12:25 am Post subject: |
|
|
Quote: | For those who "turn swap on when doing big jobs" -- I don't understand why. |
For me it's mostly ignorance of swap optimization and effects mostly. Like many on this thread, when I configured my system I had enough physical RAM (at the time) so I thought, I didn't need any swap. If you're swapping - "that's bad your systems going to thrash" is a common stated reason - whether this statement is accurate or not is another matter.
So, I added the swapfile, which I just turn on when needed. I sometimes forget to turn it back off (manually), so it's there until my next reboot.
Permanently adding it goes back to my system brings back the age-old question "How much Swap should I add" - which is probably one of the most asked questions for linux installers. With very few concrete answers. The lower bound, is "0" - no swap. But what's the upper/optimal value? A multiplier of physical RAM is an often quoted formula - with nominal answers anywhere from Swap = 1/2 to 4x Physical Memory. But should it be a function of nominal load on a machine instead? Does linux do anything differently when it's more RAM constrained? Or since I've got metric tons of disk space, is there any drawbacks from setting my swap to 16X, 32X, 128X of physical memory? I dunno.
I'm mostly a lazy admin. If it works, I leave it alone... |
|
Back to top |
|
|
pjp Administrator
Joined: 16 Apr 2002 Posts: 20476
|
Posted: Tue Jan 31, 2023 1:12 am Post subject: |
|
|
gtwrek wrote: | Permanently adding it goes back to my system brings back the age-old question "How much Swap should I add" - which is probably one of the most asked questions for linux installers. With very few concrete answers. The lower bound, is "0" - no swap. But what's the upper/optimal value? A multiplier of physical RAM is an often quoted formula - with nominal answers anywhere from Swap = 1/2 to 4x Physical Memory. But should it be a function of nominal load on a machine instead? Does linux do anything differently when it's more RAM constrained? Or since I've got metric tons of disk space, is there any drawbacks from setting my swap to 16X, 32X, 128X of physical memory? I dunno.
I'm mostly a lazy admin. If it works, I leave it alone... | I recall two major uses of why you should have swap. The common issue when contents of memory are paged out. And to copy the contents of memory to a core dump in case of crash. If you expect to get support for said crash, then you probably ought to have whatever metric of physical RAM that allows saving the contents to disk. This may be very important if your database server crashes and you'd like the vendor to tell you why. _________________ Quis separabit? Quo animo? |
|
Back to top |
|
|
steve_v Guru
Joined: 20 Jun 2004 Posts: 409 Location: New Zealand
|
Posted: Tue Jan 31, 2023 4:28 am Post subject: |
|
|
gtwrek wrote: | If you're swapping - "that's bad your systems going to thrash" is a common stated reason - whether this statement is accurate or not is another matter. |
Not entirely, pages that simply aren't going to be needed anytime soon can be swapped out as well (depending on your tuning OFC), and so long as the kernel guesses correctly on that front it's not really "thrashing", it's just freeing memory for something more useful.
Having swap isn't a bad thing, it's needing swap that tanks performance. _________________ Once is happenstance. Twice is coincidence. Three times is enemy action. Four times is Official GNOME Policy. |
|
Back to top |
|
|
eccerr0r Watchman
Joined: 01 Jul 2004 Posts: 9818 Location: almost Mile High in the USA
|
Posted: Tue Jan 31, 2023 5:32 pm Post subject: |
|
|
Actually simply "needing" swap is not a bad thing either, swap is only bad if there's barely enough to do what the computer needs to do and start thrashing. But this is not the fault of swap - it's the fault of the user trying to use more than what's feasibly available.
Again memory leaks is a big problem. You use memory and you leave it in there without regard to really needing it in there (even if you keep track of it, the mere fact you're occupying ram and not using it is the problem), and even worse - forget that you had it there. All of this data can be swapped out and memory reclaimed for active use which will improve performance.
Forcing the computer to swap text pages is the absolute worst thing to let the computer do. There aren't that many of them as a percentage of all pages, especially when compiling/linking and hence that's why computers tank when you run out of memory and no anonymous swap is available. _________________ Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching? |
|
Back to top |
|
|
|