How to configure swappiness in puppy

How to do things, solutions, recipes, tutorials
Post Reply
Message
Author
partsman
Posts: 363
Joined: Wed 06 Jun 2012, 19:00
Location: OHIO,USA

How to configure swappiness in puppy

#1 Post by partsman »

Hello all :D
Here is the definition of swappiness:
https://en.wikipedia.org/wiki/Swappiness
After a close and personal look I noticed that some puppies don't have the file /etc/sysctl.conf

Type "free -m" no quotes in a terminal snd use the example below

Code: Select all

# free -m
total used free shared buffers cached
Mem: 3950 2262 1687 0 407 952
-/+ buffers/cache: 903 3047
Swap: 1953 0 1953
The very 1st number after 'Mem:' is your "RAM size"

Here is the formula to help you calculate your swap if RAMsize=3950MB :
  • 1pct = RAMsize / 100 = 3950 / 100 = 39.5MB
    So 10% of your RAM is calculated
    10pct = 1pct * 10 = 39.5 * 10 = 395MB
Thus 395MB is the "swapiness" storage target amount.

This means that when "10% or less of ram" (395MB) is reached as the available left for program operations, then the PC will start swapping to your swap drive.

To make your system follow this rule, you must alter it as follows:
First
  1. Make a text file in /etc and name it sysctl.conf. If one exist, go to next step

    Code: Select all

    # touch /etc/sysctl.conf
  2. Once /etc/sysctl.conf exists, open it in a text editor
  3. Add the line

    Code: Select all

    vm.swappiness = 10
  4. Save /etc/sysctl.conf
Next
  1. Navigate to your root startup folder (/root/Startup)
  2. Make a script and name it set-swappiness
  3. Open it in a text editor and add:
  4. Add the line

    Code: Select all

    #!/bin/sh
    # Set vm.swappiness:
    sysctl vm.swappiness=10
  5. save it
Done
  • restart X
Your output of

Code: Select all

root# cat /proc/sys/vm/swappiness
10
shows a swappiness value of 10%

You can adjust the value in both files as you see fit.
I recommend a value of 10 or 15 :wink:

This should hopefully help some puppies feel somewhat lighter !
In short with the value left at 60 "seems to be the standard in most puppies" your swap is being accessed when there is still 60% of ram left :shock:
Swap is a good thing but it is about twice as slow as physical ram ! :wink:
Making the value of 10 would not access swap until about 10% of physical ram :wink:
For convenience I have made a pet :
Swappiness PET

Works in:
Tahrpup
vivid pup

Should work in all puppies !

Please backup your savefile before using !!!!!!!!

Please as always use caution as with any forum pet: "Backup first!
Last edited by partsman on Tue 28 Jul 2015, 16:50, edited 4 times in total.
[color=red]Anyone can build a fast processor. The trick is to build a fast system. (Seymour Cray)[/color] :wink:

User avatar
mikeb
Posts: 11297
Joined: Thu 23 Nov 2006, 13:56

#2 Post by mikeb »

yo .... :)

User avatar
corvus
Posts: 153
Joined: Fri 12 Jun 2015, 18:00
Location: In the peninsula shaped like a boot.

#3 Post by corvus »

Very interesting and especially useful to know.
Thanks partsman. :D
[b]We are waves of the same sea, leaves of the same tree, flowers of the same garden.[/b]

User avatar
Mike Walsh
Posts: 6351
Joined: Sat 28 Jun 2014, 12:42
Location: King's Lynn, UK.

#4 Post by Mike Walsh »

Thanks very much, partsman. Very useful; I'd noticed this myself, but didn't know if it was simply a function of Puppy's rather unique method of operation.

Cheers.


Mike. :)

User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

#5 Post by greengeek »

Do you think this has any effect on a puppy loaded from CD and running in ram? Could the performance of such a puppy be compromised if there is no available swap partition somewhere?

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#6 Post by musher0 »

greengeek wrote:Do you think this has any effect on a puppy loaded from CD and running in ram?
Could the performance of such a puppy be compromised if there is no
available swap partition somewhere?
Hello greengeek.

It's good logic to deduct that if you don't have any swap file or partition,
trying to control the swappiness is futile.

That said, just to be on the safe side, if your system doesn't have much
RAM, you may wish to install one of the ready-made swap files provided
here and in the following posts, on your HD or even on a USB stick. An
activation how-to is also provided.

As you may know, if your running applications occupy all of your system's
RAM and there's an overflow, without a swap file or partition to absorb
this overflow, your system will grind to a halt.

Just a thought. Best regards.

musher0
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

#7 Post by greengeek »

Hi musher0, actually I should re-phrase my question: what I really meant is do you think the performance of a puppy loaded from CD and running in ram could be improved by having a swap file and setting the swappiness to a better value as above? Is swappiness even active in a puppy loaded to ram from CD?

gcmartin

#8 Post by gcmartin »

greengeek wrote:... Is swappiness even active in a puppy loaded to ram from CD?
I have never run any Linux/unix system without a SWAP partition. And, in all the years of running PUPs Live via CD/DVDs, I can report that swappiness is active and SWAP is used accordingly.
  • Have I ever filled RAM only? Yes and system stopped
  • Have I ever filled RAM and SWAP? Yes and system slowed to a crawl until services/apps were manually stopped so that system had enough room to survive.
For the most part, I rarely look at it AND most every PUP detects my SWAP partitions at boot negating my having to do anything. This thread has brought attention to one manner of exercising a control of when SWAP system intelligence comes into play.

For me, setting it at 10% is too low. Reason: Many subsystems upon activation could exhaust RAM leaving swappiness intelligence never getting the chance to go into action on a very fast CPU. Thus for my PCs and their RAM sizes, 20% is a much safer value giving the system scheduler more opportunity for swappiness intelligence to be invoked without RAM being filled.

Hope this info is useful

partsman
Posts: 363
Joined: Wed 06 Jun 2012, 19:00
Location: OHIO,USA

#9 Post by partsman »

greengeek wrote:Hi musher0, actually I should re-phrase my question: what I really meant is do you think the performance of a puppy loaded from CD and running in ram could be improved by having a swap file and setting the swappiness to a better value as above? Is swappiness even active in a puppy loaded to ram from CD?
Puppy running from a cd/dvd will automatically find and use swap :wink:

And swappiness is basically this in short :

Say your swappiness is set at 60 "usual default"

When you use up 40% of your virtual ram your swap file begins getting used ! "swap is twice as slow as virtual ram"

If your swappiness is set at 10

90% of your virtual ram is used before your swap gets used !
"Virtual ram is faster than swap" :wink:

@greengeek
So to answer your question :
do you think the performance of a puppy loaded from CD and running in ram could be improved by having a swap file and setting the swappiness to a better value as above?
That really depends on the amount of virtual ram being used ! :wink:

For example I have a nice light and fluffy puppy that never really uses alot of my virtual ram !
So lowering the swappiness value has no effect ! I never use up the 40% of virtual ram !

Now on the flip side :
I have a heavier puppy that does use up that 40% of virtual ram and swap begins to get used ! "Things get glitchy heavy feeling slow" But I still have 60% of my virtual ram left ! :shock:

I lower the swappiness to 10 now I can use 90% of my virtual ram before swap gets used ! "Feels nice and fluffy not glitching etc." :wink:

So everyone has a different setup !
So that is where the formula above comes into play ! :wink:

Experiment with it raise and lower the swappiness values
Try on heavier puppies and lighter puppies etc . :wink:
Just remember to restart X after adjusting the values to see the effects ! :wink:
[color=red]Anyone can build a fast processor. The trick is to build a fast system. (Seymour Cray)[/color] :wink:

User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

#10 Post by greengeek »

Thanks partsman that is helpful clarification.
I had a look at the link you provided and it suggests using the following syntax to temporarily change the swappiness:

Code: Select all

#echo 10 > /proc/sys/vm/swappiness
I tried various values but did not see any performance change.

That link also says that setting a value of 100 makes the kernel swap aggressively.

I gave this a try using the above syntax but see no effects on my system. It runs just the same and still shows 0 swap in use. I also tried creating the /etc/sysctl.conf file with the same value of 100 but still no difference. I loaded your pet and set the values to 100 but still no change, so i am uncertain about the following:

1) Should the syntax echo 10 > /proc/sys/vm/swappiness make a temporary change to the swappiness behaviour even without a restartx?
2) Why does your pet place the script in /root/Startup? Hasn't the system already booted and set it's swappiness by that time?
3) If I set swappiness to 100 (for test purposes) what effects might you expect to see? Would you expect the swap file to be used immediately? Or only once current memory has hit "full" for the first time? I tried running several videos at once and opening browser pages but never saw swap in use at all. (running a slacko 5.6 derivative with 2 gig ram)
4) Do you think it might be possible to run a 500MB CD based puppy in a 256MB ram PC by adding a swap file and setting swappiness to a suitable number? Ok I would expect it to be slow, but is it even possible - can a "fat" puppy be squeezed into a little ram by use of swap parameters?

gcmartin

#11 Post by gcmartin »

Hello @GreenGeek. As you have known, I too, am a DVD user for all my productive PUPPY usage
4) Do you think it might be possible to run a 500MB CD based puppy in a 256MB ram PC by adding a swap file and setting swappiness to a suitable number? Ok I would expect it to be slow, but is it even possible - can a "fat" puppy be squeezed into a little ram by use of swap parameters?
I will share what "little" I know about the boot process and relate this to Puppy's past.

The problem is NOT the size of the distro on a bootable DVD (I haven't used CD for data in almost a decade. In fact, I do not own any PC which has a CD drive for all of them have DVD burners since 2003/4. So I share my DVD experiences as I remember.)

Live boots for me began with Knoppix...before Puppy. An excellent distro and many excellent concepts which are now commonplace thruout the world of Linux/Unix. Knoppix, though larger than RAM at that time, successfully booted on PCs with RAM as you indicate.

In my early days of PUPs, I did have some P3/P4 PCs with limited RAM. In fact, I cannot remember which, but, I booted a PUP which was larger, back then, than the PC's RAM, and it too behaved similar to Knoppix where it booted using the DVD for its program items which were NOT loaded to RAM.

The behavior
When the boot process cannot/does not find enough RAM to load all of itself, it will load the base running system's needs and will use the DVD in the same way it would use a HDD (for auxiliary storage). While not as fast as a HDD, the Linux system will, using SWAP, rollout and rollin what is needed to continue servicing the threads requiring service.

Thus, YES, you can have a DVD with 690MB boot and run on a PC with 256MB...assuming Linux is built to interrogate the hardware and act accordingly. In most cases, though, a particular Linux will load and load and merely hit the wall and stop before ever getting to the point of being capable to use the DVD for the remaining needs. But, some do.

This is my observation, externally.

Hope this helps

partsman
Posts: 363
Joined: Wed 06 Jun 2012, 19:00
Location: OHIO,USA

#12 Post by partsman »

Hi all :D
Edit because found issue was not related to swappiness
[color=red]Anyone can build a fast processor. The trick is to build a fast system. (Seymour Cray)[/color] :wink:

Post Reply