Swap partition slowing down the computer.

New to Puppy and have questions? Start here

Moderator: Forum moderators

Post Reply
Tippe
Posts: 140
Joined: Wed Feb 15, 2023 11:55 pm
Has thanked: 8 times
Been thanked: 21 times

Swap partition slowing down the computer.

Post by Tippe »

Hi.

I have 4GB of RAM and also 4GB of Swap partition.

As soon as the swap partition starts to be used, the computer slows down.
The more the swap is in use, the more the computer is getting slower.

What am I doing wrong?
Should I deactivate the Swap partition?
What will happen, if RAM is filled up without having Swap partition to be used?

Thanks.

Bionic Puppy 64bit.
Won't use another one.

User avatar
bigpup
Moderator
Posts: 6416
Joined: Tue Jul 14, 2020 11:19 pm
Location: Earth, South Eastern U.S.
Has thanked: 766 times
Been thanked: 1326 times

Re: Swap partition slowing down the computer.

Post by bigpup »

If the swap partition is getting used. It is going to be slower than only using RAM.
Swap is not about making a computer run faster, but keeping it operating, if you run out of usable ram.

What are you doing when the swap partition starts to be used?

What drive is the swap partition on?
What type drive?
USB?
Hard drive?
SSD?

How are you running Bionicpup64?
A full install?
A frugal install?

Installed on same drive as the swap partition is on?

Forum Global Moderator
The things you do not tell us, are usually the clue to fixing the problem.
When I was a kid, I wanted to be older.
This is not what I expected :o

Tippe
Posts: 140
Joined: Wed Feb 15, 2023 11:55 pm
Has thanked: 8 times
Been thanked: 21 times

Re: Swap partition slowing down the computer.

Post by Tippe »

What are you doing when the swap partition starts to be used?

Different stuff. Usually it starts when around 1GB of RAM is used.

What drive is the swap partition on?

The same drive as the install drive (sda1 = ext3 & sda3 = swap)

What type drive?

Internal 500GB Western Digital Harddisk.

How are you running Bionicpup64?

No save file at all, pfix=nocopy.

Bionic Puppy 64bit.
Won't use another one.

User avatar
mikewalsh
Moderator
Posts: 5669
Joined: Tue Dec 03, 2019 1:40 pm
Location: King's Lynn, UK
Has thanked: 606 times
Been thanked: 1742 times

Re: Swap partition slowing down the computer.

Post by mikewalsh »

@Tippe :-

I think @bigpup will agree with me on this one. You need to dial "swappiness" down.

This is the point at which the kernel will start to send stuff to the swap-file/swap-partion. OOTB, this is set to 60; for effective operation, this really wants to be dialled-down to around 10.

One of the guys on the old forum put a wee pet together several years ago to do just this. It involves creating a text file called

Code: Select all

sysctl.conf

...in /etc, and places a wee script in /root/Startup which "activates" this at every boot. The tiny .pet puts all this in place for you. I've been using this for years, though with 32GB of DDR4, technically I don't really need it these days!

I've attached it below. (I could be wrong; bigpup might have a different idea about this. Don't use it immediately; wait until you get corroboration on this point). :)

Mike. ;)

Attachments
swappiness.pet
Sets "swappiness" down to a value of 10....
(417 Bytes) Downloaded 18 times

Puppy "stuff" ~ MORE Puppy "stuff" ~ ....and MORE! :D
_______________________________________________________

Image

Clarity
Posts: 3364
Joined: Fri Jul 24, 2020 10:59 pm
Has thanked: 1387 times
Been thanked: 445 times

Re: Swap partition slowing down the computer.

Post by Clarity »

Hello @Tippe

Yes that is a phenom that is normal. As shared by @bigpup SWAP intends to keep the system running...as it is not aimed at "running at RAM speed". In fact, since most OSes are run from the system drive versus RAM (as in case of forum distros) we would not notice much of a change since all would be running in-line with the HDD's performance and users would not see the speed degradation as much.

Swappiness 'may' be tailored to affect system behavior a little, but it intends to suggest 'when' swapping is to begin. I can always tell when swapping has begun on my systems as my browser performance will slow.

Not sure where on your system drive you placed your swap-partition, but, when starting from a scratch/new system drive, I create the swap-page partition in the middle of the drive versus at the end as it "seems" to benefit performance a bit by reducing head movement when multiple items running in the system (ie program fetches, data fetches, browser caching, and swapping to keep system alive).

Hope this info is helpful.

BTW: There are options that improve responsiveness in this modern age: Adding RAM or adding a faster SWAP media/unit/device.

P.S. I NEVER-EVER put swap or page or "Persistence"... again ever, on a USB of any type. I dont have any USB that out-performs system drives, as of yet.

fatdoguser
Posts: 175
Joined: Sat Aug 05, 2023 10:54 am
Has thanked: 22 times
Been thanked: 79 times

Re: Swap partition slowing down the computer.

Post by fatdoguser »

Tippe wrote: Mon Mar 11, 2024 11:22 pm

Hi.

I have 4GB of RAM and also 4GB of Swap partition.

As soon as the swap partition starts to be used, the computer slows down.
The more the swap is in use, the more the computer is getting slower.

What am I doing wrong?
Should I deactivate the Swap partition?
What will happen, if RAM is filled up without having Swap partition to be used?

Thanks.

4GB should be generally enough to run without swap. If you do process large files then try to do so within a HDD based folder rather than within ram (/root). If you do a lot of browsing then consider moving the browser cache to HDD.

Try running the system after booting and running swapoff -a
Without swap and running cd /root;yes >lst
will quickly fill up ram with that lst file, and you'll see what happens when all of free ram gets filled up. Typically the system should just end with a insufficient space outcome or grind down to a slow crawl with some kind of warning about running low/out of ram, where you might rectify that such as ending that yes >lst command and removing the lst file.

If you do large compiles, or renders/videos etc. then you just have to plan/prepare for the likely amount of space being used, set up the program(s) to use HDD instead of all running in ram.

Running 4GB without any swap and mostly you should be fine, just keep it in mind and if you for instance download a 5GB file make sure its saved directly to HDD ...etc.

User avatar
bigpup
Moderator
Posts: 6416
Joined: Tue Jul 14, 2020 11:19 pm
Location: Earth, South Eastern U.S.
Has thanked: 766 times
Been thanked: 1326 times

Re: Swap partition slowing down the computer.

Post by bigpup »

Yes changing swappiness setting may help you.

But this statement by you makes me wonder.

What are you doing when the swap partition starts to be used?

Different stuff. Usually it starts when around 1GB of RAM is used.

If you have 4GB of RAM. A lot of Swap should be starting more like around 3GB of RAM usage or at around 2GB and not that much to start.

I wonder if all your RAM is good :idea:

If you keep something running for a long time (specific program). The Linux kernel will use swap, to move components of the program, out of RAM, and into swap.
But it is not stuff that should affect how the program runs, as you use it.

Forum Global Moderator
The things you do not tell us, are usually the clue to fixing the problem.
When I was a kid, I wanted to be older.
This is not what I expected :o

User avatar
bigpup
Moderator
Posts: 6416
Joined: Tue Jul 14, 2020 11:19 pm
Location: Earth, South Eastern U.S.
Has thanked: 766 times
Been thanked: 1326 times

Re: Swap partition slowing down the computer.

Post by bigpup »

If you are running with no save.

I assume you are in pupmode 5 operation.

So the save is being done with a save ramdisk using some of the RAM.

Forum Global Moderator
The things you do not tell us, are usually the clue to fixing the problem.
When I was a kid, I wanted to be older.
This is not what I expected :o

Tippe
Posts: 140
Joined: Wed Feb 15, 2023 11:55 pm
Has thanked: 8 times
Been thanked: 21 times

Re: Swap partition slowing down the computer.

Post by Tippe »

Hi, and thanks for all the replies.

The Computer's CPU is an AMD 2-Core Processor. Sadly its power supply exploded when switching on the last time. Heavy light flashes came out of the desktop computer's case. Luckily the hard drives are still working. They are in use in my new Computer now. A Lenovo with Intel 4-Core CPU and 8 GB of RAM. I hope this will have its benefits...

Again thanks.

The old computer was running for around 10 years 24 hours a day. Hopefully the new one will last such a long time without running 24 hours a day.

Bionic Puppy 64bit.
Won't use another one.

dimkr
Posts: 2015
Joined: Wed Dec 30, 2020 6:14 pm
Has thanked: 38 times
Been thanked: 925 times

Re: Swap partition slowing down the computer.

Post by dimkr »

This is why newer Puppy releases automatically fall back to zram if no there's no swap partition. Your system will slow down or lock up if you're running low on memory and swap resides on a slow disk. Swap space in zram is much faster (because it's written to RAM) and usually keeps your system responsive enough for you to kill problematic applications that consume all your RAM. And zram is better than having no swap at all, because you don't want your applications to get killed (and lose/corrupt data) when you're running low on RAM. An old Puppy like BionicPup64 is smaller and maybe lighter, but on many computers you'd get better perceived responsiveness and better performance with a current Puppy.

esos
Posts: 154
Joined: Thu Feb 18, 2021 4:33 am
Been thanked: 17 times

Re: Swap partition slowing down the computer.

Post by esos »

And zram is better than having no swap at all

How to setup and use zram?
Do you think zram can run efficient while you have only 4Gb of ram.
Thanks.

fatdoguser
Posts: 175
Joined: Sat Aug 05, 2023 10:54 am
Has thanked: 22 times
Been thanked: 79 times

Re: Swap partition slowing down the computer.

Post by fatdoguser »

esos wrote: Thu Mar 14, 2024 11:14 pm

And zram is better than having no swap at all

How to setup and use zram?
Do you think zram can run efficient while you have only 4Gb of ram.
Thanks.

Under Fatdog (your pup may vary) for creating/using zram file ...

Code: Select all

modprobe zram # load module (creates /sys/block/zramX folder and content)

#show supported compression algorithms
cat /sys/block/zram0/comp_algorithm
lzo [lz4]

#opt to use lz4 compression algorithm
echo lz4 > /sys/block/zram0/comp_algorithm

echo 1G > /sys/block/zram0/disksize  # no more than 2x memory size as pointless

mkfs.ext2 /dev/zram0
mkdir /xxx
mount /dev/zram0 /xxx

For creating it as swap you'd use mkswap/swapon ...etc. instead of mkfs.ext2/mount

Be mindful however that using zram, or encrypted swap, adds the additional overhead of having to compress/decompress (encrypt/decrypt). May very well not resolve the issue, rather just prolong things a bit longer before a massive slow-down/lock-up occurs.

If you're OK with leaving a forensic trail, then a straight swap file, not encrypted, on HDD can work OK and resize your save/tmp areas to use that. But that is more for a case of where you have save on demand, and generally don't save changes. Which is little different to that of repointing save/tmp to be on HDD rather than in ram i.e. 'problems' can be resolved by re-configuration rather than adopting zram or encrypted swap. For many that may be as simple as moving your browser cache and download folders to be on HDD rather than in ram. For others such as doing large video edits, move the temp/work folders to be on HDD ...etc.

I run a Fatdog usb boot as one of my choices, but with forensics in mind, not leaving a footprint on 'foreign' host cpu/system. Even though my radeon grabs 600MB for vram, leaving just 3.4GB ram (that Linux typically halves that amount as being the available 'free' ram), that is still more than enough for typical usage where fatdog main sfs and changes are loaded into and run from ram, as are potential changes (that I don't actually save) recorded in ram.

If you are tight on space, then don't copy sfs's into ram, leave them on disk and blocks will be read into/ejected from ram/cache by the system. The times that fails is when there's too much 'current' data required and insufficient ram/cache space to accommodate that i.e. you're asking too much of the available hardware/resources. Or when the configuration isn't appropriate, such as attempting to edit a large video where the actual and temp files are being fully kept in ram.

a.k.a. with 4GB I suspect you can run things better without either swap or zram as neither will totally eliminate the risk of a slow-down/lock-up. If you do need to do 'big things' on foreign systems where you don't want to leave evidence (private data that others could potentially see after you'd used/left that system) then a portable usb/ssd device is the more appropriate over a usb flash-stick. In which case a straight non-compressed swap or re-pointing the 'ram' based save area to be on the ssd instead works fine. Or even if you don't want to preserve changes, make a copy of the current save file/folder before bootup, run with changes being stored into a new version of the save file/folder, and then ditch that to restore the original save file/folder - so as though no changes were saved.

In my case Fatdog main sfs is around 450MB (xz high compressed, over 2GB of actual data), in addition to that another save/changes sfs is around 20MB (my reconfiguration of Fatdog for locale/looks etc.), I also have a chrome sfs that is around 130MB, so in total, 600MB of compressed sfs data copied into ram at bootup. A further 600MB of the 4GB ram is allocated by Radeon as vram, leaving 3.4GB, of which LInux in effect halves that down to 1.7GB. With 600MB in sfs form, that leaves around 1.1GB of free ram initially. Linux works fine with that, will page/cache things in/out fine. The only time it becomes a issue is if that 1.1GB is used up by single files or browser cache ...etc. that with a bit of configuration/application of thought ... can largely if not totally avoided. Whist with all sfs's in ram, the system runs (very) quick. To free up more ram I could leave the sfs's on disk, but in my case the disk is a old mechanical one and its very slow to spin-up/use, so for operational reasons I prefer my sfs's in ram. But that is somewhat wasteful, as for light usage in effect I have the sfs copy of files copied into ram, and then the cached copy of files also being copied into/remaining in cache, but if things work fine that way that's not really a issue, and if the system needs the cached space then it dumps that so that the next read of a file within a sfs has to be decompressed/copied back into cache again if/when needed.

dimkr
Posts: 2015
Joined: Wed Dec 30, 2020 6:14 pm
Has thanked: 38 times
Been thanked: 925 times

Re: Swap partition slowing down the computer.

Post by dimkr »

esos wrote: Thu Mar 14, 2024 11:14 pm

How to setup and use zram?

If you use a more recent Puppy (>=2021), it will enable zram automatically if no swap partition is found.

esos wrote: Thu Mar 14, 2024 11:14 pm

Do you think zram can run efficient while you have only 4Gb of ram.

Yes, the amount of RAM usable by zram is limited, and zram is in use only when you're really running low on RAM. This means there's no upfront cost, before you actually need swap. But the real question is your disk, because the slowdown happens because swap resides on a slow (slow enough for you to notice) disk - zram is almost guaranteed to be faster than swap on disk.

A computer with 2 GB of RAM can run pretty comfortably with zram swap (without applications crashing due to low memory) if it uses a lightweight Puppy, so 4 GB is more than enough.

esos
Posts: 154
Joined: Thu Feb 18, 2021 4:33 am
Been thanked: 17 times

Re: Swap partition slowing down the computer.

Post by esos »

Thank you so much for all the replies.
I am using zram to avoid running low on Ram some times.

Post Reply

Return to “Beginners Help”