LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 04-11-2022, 05:49 PM   #16
cwizardone
LQ Veteran
 
Registered: Feb 2007
Distribution: Slackware64-current with "True Multilib" and KDE4Town.
Posts: 9,105

Rep: Reputation: 7281Reputation: 7281Reputation: 7281Reputation: 7281Reputation: 7281Reputation: 7281Reputation: 7281Reputation: 7281Reputation: 7281Reputation: 7281Reputation: 7281

Dumb question: Are there applications that look for swap (partition or file) and if not found, do not perform correctly?
 
Old 04-11-2022, 05:57 PM   #17
LuckyCyborg
Senior Member
 
Registered: Mar 2010
Posts: 3,505

Rep: Reputation: 3320Reputation: 3320Reputation: 3320Reputation: 3320Reputation: 3320Reputation: 3320Reputation: 3320Reputation: 3320Reputation: 3320Reputation: 3320Reputation: 3320
Quote:
Originally Posted by cwizardone View Post
Dumb question: Are there applications that look for swap (partition or file) and if not found, do not perform correctly?
Think about memory defragmentation. Technically, this thing is done.

Even having a little swap would help much the kernel to handle the memory usage.
 
1 members found this post helpful.
Old 04-11-2022, 08:02 PM   #18
jmccue
Member
 
Registered: Nov 2008
Location: US
Distribution: slackware
Posts: 691
Blog Entries: 1

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Quote:
Originally Posted by arubin View Post
Thanks for the replies.

As a follow-up is swap actually needed for sleep as opposed to hibernation?
If you are on a SSD, you should not use hibernation, sleep works fine.

IIRC, sleep is "suspend to RAM", so I very much doubt swap is needed for sleep.
 
Old 04-11-2022, 08:22 PM   #19
notzed
Member
 
Registered: Dec 2020
Location: South Australia
Distribution: slackware64-current
Posts: 95

Rep: Reputation: Disabled
I've run without swap since I started using SSDs and had enough RAM to not need it. It's not required for memory-sleep which I use on this machine multiple times a day. This is one current (12C/24T) slackware machine:

Code:
notzed@shitzone:~$ free
               total        used        free      shared  buff/cache   available
Mem:        32834960     6963784    12213896      117208    13657280    25081600
Swap:              0           0           0
notzed@shitzone:~$
All you do is not setup a swap partition and ignore any warnings about it during setup.

I only installed swap on my (8C/8T) laptop because memory-sleep doesn't work due to a broken BIOS (sigh, clevo) and it is required for disk-sleep (hibernate). And needing that 32GB of swap was a huge cost out of the ~200GB SSD I got it with and in part forced me to upgrade to a 1TB - and it's still a costly chunk out of that. So in practice it's just a huge waste of storage and almost never gets used apart from hibernate - currently sitting at 200MB used despite running a gentoo update which is by far the heaviest load it ever faces. The whole machine didn't even get over 2GB RAM/5GB cache used until it compiled firefox - after 33 other packages and hammering all 8 cores - and even then it only peaked around 10GB RAM/10GB cache.

There's certainly workloads where it will be beneficial to have it because it opens up more effective RAM if there are many stale pages and idle processes, but for a typical single-user desktop with >=16GB RAM it isn't likely to do much if anything. Take the recommendation above about 1GB swap for example, if you have 32GB of RAM another 1GB available at most is SFA and effectively irrelevant. If you've used enough of your RAM for that amount to matter then you already need more of it! Even 1GB is quite a lot of stale daemons for a single-user desktop, the large spikes you get will be for transient operations like compiling rust or c++ concurrently across many cores so increasing swap is unlikely to effectively increase your RAM further. Yes you will be able to more before running out of it but as soon as the working set needs to swap in and out you will be in a world of pain (i've had to just hit the power button in the past since the kernel just can't seem to recover some times, beware of low swappiness values too).

There's a lot of cargo cult nonsense with computers in general and especially for things like swap, and someone like Chris Down will recommend it because both he's worked with the code and because he knows all the sound technical reasons it absolutely does make good sense. But due to changes in the baselines of modern hardware (i.e. gobs of RAM) those technical reasons don't always have any practical impact*.

* You know, depending on use-cases and work loads and so on and so forth.
 
Old 04-11-2022, 09:36 PM   #20
bassmadrigal
LQ Guru
 
Registered: Nov 2003
Location: West Jordan, UT, USA
Distribution: Slackware
Posts: 8,792

Rep: Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656
Quote:
Originally Posted by jmccue View Post
If you are on a SSD, you should not use hibernation, sleep works fine.
Why? Suspend still uses power and may not be ideal depending on your situation.

If you're worried about NAND wear limits, it is very unlikely for anyone to run them on any modern SSD/NVMe device. I've been using my current NVMe drive since 2017, with the root partition, /tmp/, /var/, /home/, and a swap partition all on the same drive (4 separate partitions for the root partition, /home/, EFI, and swap) and I'm only at like 4% of wear. I do a *lot* of compiling on this system and have written 25TB to the device so far (that's an average of 13GB per day... the equivalent of a whole install of Slackware every single day for 5 years). It's rated for 400TB of written data, however, most drives will go far beyond those limits. Even if I just went to the 400TB limit, I could go an additional 34 years if I maintain the same data writing as the last 5 years. This is on 5 year old hardware, so newer hardware will have even higher limits.

Even with 100GB/day, the drive would still last almost 11 years... far beyond the likely usefulness of the device. Especially considering the massive price drops these have had over the last few years. When I bought my Samsung EVO 1TB NVMe drive 5 years ago, it was $500US. The newest generation of Samsung EVO 1TB NVMe drives now go for like $150US.

People can stop babying NAND devices. Use and abuse them to benefit from the massive speed gains over platter harddrives and you'll never hit the NAND wear limit.

Quote:
Originally Posted by jmccue View Post
IIRC, sleep is "suspend to RAM", so I very much doubt swap is needed for sleep.
Correct. If you simply suspend, swap is not needed. Power to the RAM is maintained to keep it active until the battery is depleted, then all data in RAM is lost and it will be a fresh boot when you start it back up (unless the system automatically hibernates when power is low). Hibernation fully powers off the computer, so the contents of RAM need to be transferred elsewhere, which for Linux is typically a swap partition or file. This allows the current session to be saved indefinitely.
 
1 members found this post helpful.
Old 04-11-2022, 09:39 PM   #21
bassmadrigal
LQ Guru
 
Registered: Nov 2003
Location: West Jordan, UT, USA
Distribution: Slackware
Posts: 8,792

Rep: Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656
Quote:
Originally Posted by notzed View Post
I've run without swap since I started using SSDs and had enough RAM to not need it.
You may not need it, but the system can still benefit from it.

Code:
jbhansen@craven-moorhead:~$ free -h
              total        used        free      shared  buff/cache   available
Mem:           62Gi        21Gi       491Mi       312Mi        40Gi        40Gi
Swap:          15Gi       1.6Gi        14Gi
I have an 40GB of RAM effectively available, but the kernel still decided to swap 1.6GB of data. I assume kernel devs know how to best utilize my hardware when it comes to memory usage.
 
Old 04-12-2022, 12:21 AM   #22
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,058

Rep: Reputation: Disabled
Good reads (as usual) on the Arch Wiki:
https://wiki.archlinux.org/title/swap
https://wiki.archlinux.org/title/Imp...d_OOM_handling
 
2 members found this post helpful.
Old 04-12-2022, 03:25 AM   #23
marav
LQ Sage
 
Registered: Sep 2018
Location: Gironde
Distribution: Slackware
Posts: 5,366

Rep: Reputation: 4082Reputation: 4082Reputation: 4082Reputation: 4082Reputation: 4082Reputation: 4082Reputation: 4082Reputation: 4082Reputation: 4082Reputation: 4082Reputation: 4082
Quote:
Originally Posted by bassmadrigal View Post
Why? Suspend still uses power and may not be ideal depending on your situation.

Correct. If you simply suspend, swap is not needed. Power to the RAM is maintained to keep it active until the battery is depleted, then all data in RAM is lost and it will be a fresh boot when you start it back up (unless the system automatically hibernates when power is low). Hibernation fully powers off the computer, so the contents of RAM need to be transferred elsewhere, which for Linux is typically a swap partition or file. This allows the current session to be saved indefinitely.
It drains 2 or 3% of the battery per hour here (vs. 0% during hibernation)
So, for me, hibernation is not an option
 
Old 04-12-2022, 03:50 AM   #24
chrisretusn
Senior Member
 
Registered: Dec 2005
Location: Philippines
Distribution: Slackware64-current
Posts: 2,975

Rep: Reputation: 1551Reputation: 1551Reputation: 1551Reputation: 1551Reputation: 1551Reputation: 1551Reputation: 1551Reputation: 1551Reputation: 1551Reputation: 1551Reputation: 1551
This is my use case on my desktop. This is after 22:50 of uptime.
Code:
free -h
               total        used        free      shared  buff/cache   available
Mem:           7.8Gi       2.7Gi       1.8Gi        87Mi       3.4Gi       4.7Gi
Swap:          8.1Gi       1.1Gi       7.1Gi
I always end up with swap being used at one point or another. This is from lots of Firefox video watching, virtualBox and compiling during the 22:50 period.

My laptop after a power on.
Code:
free -h
               total        used        free      shared  buff/cache   available
Mem:           3.7Gi       134Mi       3.2Gi       1.0Mi       406Mi       3.4Gi
Swap:          2.0Gi          0B       2.0Gi
I use hibernate on this laptop. I use append="resume=/dev/sda1" in the kernel images section of lilo.conf

With my four Slackware VirtualBox machines I do not use swap.

Last edited by chrisretusn; 04-12-2022 at 03:51 AM.
 
Old 04-12-2022, 05:45 AM   #25
luvr
Member
 
Registered: May 2005
Location: Boom - The Home Town of Tomorrowland, Belgium
Distribution: Slackware, Xubuntu
Posts: 459
Blog Entries: 2

Rep: Reputation: 194Reputation: 194
Quote:
Originally Posted by LuckyCyborg View Post
Think about memory defragmentation.
Not sure what memory fragmentation has to do with swap, to be honest. Memory fragmentation happens within a specific address space, and no amount of swapping will help alleviate it. Keep in mind that we’re talking virtual addresses here, not physical RAM addresses. If fact, a chunk of memory that was allocated by a process (and, therefore, is located at a specific virtual address in the address space of the process) may be swapped out and, consequently, not even have a physical address in RAM at any point in time.

What does “memory fragmentation” actually mean, then?

Well, let’s, for example’s sake, assume for a moment that you are running a certain computer architecture that provides each process (i.e., roughly, each running program) with a (virtualised) RAM address space of 100 MiB. Program “A” keeps allocating chunks of memory, 1 MiB at a time, until it fills up its 100-MiB address space. It has now fully allocated 100% of its address space. Next, it begins to free up every other 1-MiB chunk of memory that it allocated, freeing up a total of 50 chunks, which amounts to 50 MiB. It now has 50% of its address space in use, and the other 50% is free. However, the largest available consecutive chunk of memory is just 1 MiB. Next, it attempts to allocate a 2-MiB chunk. Well, no matter how hard it tries, a 2-MiB chunk won’t fit in any of the 1-MiB chunks that it has at its disposal. No amount of swapping will help, either: the address space is 50% full, and 50% empty, but the biggest empty chunk is and will remain just 1 MiB in size.

All the while, a Program “B” (which has its own 100-MiB virtualised RAM address space available to play with) may have allocated a single chunk of, say, 60 MiB. It still has 40 MiB of free memory, most likely in one 40-MiB chunk (in theory, the memory allocator could have placed the 60-MiB chunk somewhere in the middle of the 100-MiB address space, but, for simplicity’s sake, let’s assume it didn’t do that). It now needs another 10-MiB chunk. No problem: the biggest (and even, the only) chunk of free memory that it has at its disposal, is 40 MiB in size, from which a 10-MiB chunk can easily be taken.
 
Old 04-12-2022, 06:03 AM   #26
luvr
Member
 
Registered: May 2005
Location: Boom - The Home Town of Tomorrowland, Belgium
Distribution: Slackware, Xubuntu
Posts: 459
Blog Entries: 2

Rep: Reputation: 194Reputation: 194
Quote:
Originally Posted by wainamoinen View Post
I've not used swap for the last 10 years. No issues at all. In fact I always mount /tmp as a tmpfs (to use more the RAM), this makes things like compiling really fast. Why, just because now computers have a lot of RAM.
I don’t use swap, either, with no noticeable ill effects. My computer has 32 GiB of RAM and, on the Slackware partition that I use to build packages from SlackBuilds, I mount “/tmp” as a 24-GiB tmpfs. I can compile the “gcc5” package just fine that way. I do realize that I may run out of memory some day, when building a really, really, really humongous package, but so be it. In fact, let’s agree that I’ll post here about it when it happens.

Quote:
I don't hybernate my laptop. My laptop can be suspended for a couple days without problem. If I'm going to power it off for more time I just shut it down, but I don't remember the last time I needed to do that.
I’m not that much of a laptopper anyway, I’m mostly using a desktop computer. I don’t hibernate or suspend or let my computers go to sleep or whatever, I simply perform a shutdown when I’m done. Works more than good enough for me, but: “Your Mileage May Vary”.
 
Old 04-12-2022, 07:06 AM   #27
USUARIONUEVO
Senior Member
 
Registered: Apr 2015
Posts: 2,335

Rep: Reputation: 930Reputation: 930Reputation: 930Reputation: 930Reputation: 930Reputation: 930Reputation: 930Reputation: 930
I never use swap , dont like see my ssd used as ram to read/write , and nothing fails or im not see.

The swap partitions time are when systems have low memory ram size.


In my case in x64 system with 32gb of ram , swap are useless.

Last edited by USUARIONUEVO; 04-12-2022 at 07:08 AM.
 
Old 04-12-2022, 07:16 AM   #28
subscrive
Member
 
Registered: Feb 2022
Posts: 72

Rep: Reputation: 12
Consider my system having 4gb ram. It is recommended to have 4 gb swap (as per rhel documentation).
I have possibility of increasing it to 8 gb.
Now, in case I increase it to 8 gb, does my swap need disappear?
If no, what could be the reason?
If no, is it possible to set swap as "in-memory"? If yes, and I set it as 4gb swap, then my system will again be 4gb for OS + 4 gb for swap.
 
Old 04-12-2022, 10:17 AM   #29
bassmadrigal
LQ Guru
 
Registered: Nov 2003
Location: West Jordan, UT, USA
Distribution: Slackware
Posts: 8,792

Rep: Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656
Quote:
Originally Posted by marav View Post
It drains 2 or 3% of the battery per hour here (vs. 0% during hibernation)
So, for me, hibernation is not an option
Wait, so your reason to not use swap is because saves more power?

Quote:
Originally Posted by USUARIONUEVO View Post
I never use swap , dont like see my ssd used as ram to read/write , and nothing fails or im not see.
Why wouldn't you want to use the second fastest storage on your system for fast read/write? It is pretty much impossible to exceed the write capacity of modern NAND without purposefully finding a way to do it.

Seriously, people need to stop babying NAND.
 
2 members found this post helpful.
Old 04-12-2022, 10:34 AM   #30
NakedRider
Member
 
Registered: Nov 2008
Location: Sacramento, CA
Distribution: Slackware and only Slackware
Posts: 194

Rep: Reputation: 114Reputation: 114
I haven't used swap in over 9 months. No problems. 16G of RAM.
 
  


Reply



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
Triple-boot Mac/Win/Linux: Possible to boot from, or install swap partition on second drive? endgame Linux - Newbie 14 02-18-2017 06:07 AM
How to install slackware to two partitions (One for Slackware and one for swap) sycho123321 Linux - Newbie 13 11-24-2013 09:31 AM
How to unmount actual swap and mount a new(bigger) swap space? isaac Linux - Newbie 1 06-06-2004 01:23 AM
Slackware 9 Creating new swap partitions after installation without destroying data MegaGeoff Linux - Newbie 1 01-18-2004 08:44 PM
Difference between Swap Virtrual memory and Swap Parition Nappa Slackware 4 11-27-2003 07:58 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 03:03 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