Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Wed 29 Jul 2015, 22:15
All times are UTC - 4
 Forum index » House Training » HOWTO ( Solutions )
How to configure swappiness in puppy
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [12 Posts]  
Author Message
partsman

Joined: 06 Jun 2012
Posts: 293
Location: OHIO,USA

PostPosted: Sun 12 Jul 2015, 12:03    Post subject:  How to configure swappiness in puppy
Subject description: Keep puppy from accessing Swap unnecessarily
 

Hello all Very Happy
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:
# 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:
    # touch /etc/sysctl.conf

  2. Once /etc/sysctl.conf exists, open it in a text editor
  3. Add the line
    Code:
    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:
    #!/bin/sh
    # Set vm.swappiness:
    sysctl vm.swappiness=10

  5. save it

Done
    restart X
Your output of
Code:
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 Shocked
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!

_________________
"PUPPY" POWERED BY PEOPLE
AKITA LINUX kernel 2.6.32.28
Wink

Last edited by partsman on Yesterday, at 12:50; edited 4 times in total
Back to top
View user's profile Send private message 
mikeb


Joined: 23 Nov 2006
Posts: 11069

PostPosted: Sun 12 Jul 2015, 12:34    Post subject:  

yo .... Smile
Back to top
View user's profile Send private message 
corvus


Joined: 12 Jun 2015
Posts: 20
Location: somewhere in Southern Europe

PostPosted: Sun 12 Jul 2015, 18:04    Post subject:    

Very interesting and especially useful to know.
Thanks partsman. Very Happy

_________________
Precise 5.7.1 - Tahrpup 6.0.2
Back to top
View user's profile Send private message 
Mike Walsh


Joined: 28 Jun 2014
Posts: 550
Location: King's Lynn, UK.

PostPosted: Wed 22 Jul 2015, 07:55    Post subject:  

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. Smile

_________________
You can only be certain of three things in life; birth, death.....and TAXES!! Laughing
----------------------------------------------------

Back to top
View user's profile Send private message 
greengeek

Joined: 20 Jul 2010
Posts: 3192
Location: New Zealand

PostPosted: Wed 22 Jul 2015, 15:23    Post subject:  

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?
Back to top
View user's profile Send private message 
musher0


Joined: 04 Jan 2009
Posts: 5675
Location: Gatineau (Qc), Canada

PostPosted: Wed 22 Jul 2015, 15:54    Post subject:  

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

_________________
"Logical entities must not be multiplied needlessly." / "Il ne faut pas multiplier les êtres logiques inutilement." (Ockham)
Back to top
View user's profile Send private message Visit poster's website 
greengeek

Joined: 20 Jul 2010
Posts: 3192
Location: New Zealand

PostPosted: Thu 23 Jul 2015, 14:15    Post subject:  

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?
Back to top
View user's profile Send private message 
gcmartin


Joined: 14 Oct 2005
Posts: 5272
Location: Earth

PostPosted: Thu 23 Jul 2015, 16:51    Post subject:  

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

_________________
Get ACTIVE Create Circles; Do those good things which benefit people's needs!
We are all related ... Its time to show that we know this!
3 Different Puppy Search Engine or use DogPile
Back to top
View user's profile Send private message 
partsman

Joined: 06 Jun 2012
Posts: 293
Location: OHIO,USA

PostPosted: Fri 24 Jul 2015, 01:28    Post subject:  

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 :
Quote:
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 ! Shocked

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

_________________
"PUPPY" POWERED BY PEOPLE
AKITA LINUX kernel 2.6.32.28
Wink
Back to top
View user's profile Send private message 
greengeek

Joined: 20 Jul 2010
Posts: 3192
Location: New Zealand

PostPosted: Sat 25 Jul 2015, 16:15    Post subject:  

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:
#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?
Back to top
View user's profile Send private message 
gcmartin


Joined: 14 Oct 2005
Posts: 5272
Location: Earth

PostPosted: Sat 25 Jul 2015, 16:46    Post subject:  

Hello @GreenGeek. As you have known, I too, am a DVD user for all my productive PUPPY usage
Quote:
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

_________________
Get ACTIVE Create Circles; Do those good things which benefit people's needs!
We are all related ... Its time to show that we know this!
3 Different Puppy Search Engine or use DogPile
Back to top
View user's profile Send private message 
partsman

Joined: 06 Jun 2012
Posts: 293
Location: OHIO,USA

PostPosted: Sun 26 Jul 2015, 11:54    Post subject:    

Hi all Very Happy
Quote:
Edit because found issue was not related to swappiness

_________________
"PUPPY" POWERED BY PEOPLE
AKITA LINUX kernel 2.6.32.28
Wink
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [12 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » House Training » HOWTO ( Solutions )
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0895s ][ Queries: 11 (0.0055s) ][ GZIP on ]