maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Maemo 5 / Fremantle (https://talk.maemo.org/forumdisplay.php?f=40)
-   -   How to set swappiness? (https://talk.maemo.org/showthread.php?t=48966)

TheSacredSoul 2010-04-01 14:20

How to set swappiness?
 
I see people discussing changing swappiness but what is the exact way to go about doing it and making it stick at every reboot? Also, I heard you can run swap from the microsd to get a more responsive device?

My phone comes down to a crawl after less then a day of usage. I normally have to repeatedly tap conversations for it to open after a minute so im looking at anything to improve the responsiveness. Thanks for your help!

ossipena 2010-04-01 14:22

Re: How to set swappiness?
 
swappiness?!?!?

are you referring to swap partition maybe?

what unstable stuff have you installed to your device?

ToJa92 2010-04-01 14:23

Re: How to set swappiness?
 
Quote:

Originally Posted by ossipena (Post 591410)
swappiness?!?!?

are you referring to swap partition maybe?

what unstable stuff have you installed to your device?

Read this, there are some info about swappiness: http://kerneltrap.org/node/3000
I suppose Wikipedia also got some info on that subject.

TheSacredSoul 2010-04-01 14:29

Re: How to set swappiness?
 
Thanks for the link... I roughly know whats swappiness after using Andriod with custom ROM's for over a year. I just dont know how to set it on N900. And google isnt much too :(

ossipena 2010-04-01 14:31

Re: How to set swappiness?
 
I'd leave it be, it probably has already been optimized.

hqh 2010-04-01 14:36

Re: How to set swappiness?
 
Quote:

Originally Posted by ossipena (Post 591418)
I'd leave it be, it probably has already been optimized.

Yes, the problem lies somewhere else since slowing down to a crawl in a day isn't normal behavior.

Rob1n 2010-04-01 14:38

Re: How to set swappiness?
 
Quote:

Originally Posted by TheSacredSoul (Post 591417)
Thanks for the link... I roughly know whats swappiness after using Andriod with custom ROM's for over a year. I just dont know how to set it on N900. And google isnt much too :(

Just echo a value to /proc/sys/vm/swappiness (as root). There doesn't appear to be sysctl on the N900, so persisting the changes would be a bit trickier.

wheelybird 2010-04-01 14:43

Re: How to set swappiness?
 
It's /proc/sys/vm/swappiness. As root:
echo "50" > swappiness
will change it, though this won't survive a reboot.
The default is 100, which is the swappiest. You could try lowering it to, say, 50.

You can add a swap partition to your SD card by editing the partitions and adding a Linux swap partition to it (type 82).
For example, add a swap partition of 1GB to the SD. Search the internet for fdisk, swapon, swapoff and mkswap to teach you what to do. You'd turn the SD swap on and the internal swap off.

Please note: this is for information only. Do what you like with your device, but at the risk of making it not work at all. Personally I'd recommend keeping it set up as it is at the moment.

memoryguy 2010-04-01 14:44

Re: How to set swappiness?
 
Quote:

Originally Posted by Rob1n (Post 591428)
Just echo a value to /proc/sys/vm/swappiness (as root). There doesn't appear to be sysctl on the N900, so persisting the changes would be a bit trickier.

I updated my swappiness a couple months ago... I think I found a spot somewhere in the init scripts... if I recall correctly there was a comment saying to put updates to /proc stuff there... I think... I forget now and don't have the device handy.

I think it defaults to swapiness 100, which I think means "go ahead and swap as much as you want" ... which didn't seem right to me so I changed it to 0... not sure if I've noticed much difference... I should change it back again and see...

TheSacredSoul 2010-04-01 14:54

Re: How to set swappiness?
 
From what I've read, the sweet spot is 60... I just set mine to 60. Shall give it a try. Thanks for your help. And for anyone who wants to know the command is

echo 60 /proc/sys/vm/swappiness

Rob1n 2010-04-01 15:02

Re: How to set swappiness?
 
Quote:

Originally Posted by TheSacredSoul (Post 591456)
From what I've read, the sweet spot is 60... I just set mine to 60. Shall give it a try. Thanks for your help. And for anyone who wants to know the command is

echo 60 /proc/sys/vm/swappiness

The sweet spot will be very much dependent on the ratio between the memory performance and the media performance. That will be drastically different on a standard desktop PC (with very high-speed RAM and pretty slow hard drive media) than on the N900 (with slower RAM and higher-speed flash memory media).

And you've missed the critical '>' in the command you've given there.

TheSacredSoul 2010-04-01 15:13

Re: How to set swappiness?
 
Thank you Rob1n. My bad. How do you type > using the n900 keyboard?

Rob1n 2010-04-01 15:15

Re: How to set swappiness?
 
Quote:

Originally Posted by TheSacredSoul (Post 591498)
Thank you Rob1n. My bad. How do you type > using the n900 keyboard?

It's in the symbols table - press the blue arrow, then the Sym/Ctrl key above it, then select '>' from the pop-up symbols table.

TheSacredSoul 2010-04-01 15:17

Re: How to set swappiness?
 
Thank you once again. You are a live saver. So just to confirm...


echo 60 > /proc/sys/vm/swappiness

Rob1n 2010-04-01 15:21

Re: How to set swappiness?
 
Quote:

Originally Posted by TheSacredSoul (Post 591505)
Thank you once again. You are a live saver. So just to confirm...


echo 60 > /proc/sys/vm/swappiness

Yep, that's it. You can check the current value by running:

Code:

cat /proc/sys/vm/swappiness

TheSacredSoul 2010-04-01 15:25

Re: How to set swappiness?
 
Yep it's 60 :) Thank you!

Venemo 2010-04-01 15:46

Re: How to set swappiness?
 
Could you tell us how much better does it perform with the new value after some use?

pycage 2010-04-01 15:53

Re: How to set swappiness?
 
I have been running my N900 with swappiness 30 for some weeks without any ill side-effect. But it seems that battery-life and device responsiveness have both noticably improved.

BTW, on Diablo OS, the default swappiness value was 1. I'm almost certain that a default value of 100 on the N900 is not the optimal setting for this device at all.

Venemo 2010-04-01 16:10

Re: How to set swappiness?
 
Thanks Pycage!
Do you know how to set it so the value will persist after reboot?

@SR 2010-04-01 16:14

Re: How to set swappiness?
 
On n900 default value for swappiness is set by /etc/init.d/rcS script somewhere in the last lines.
echo value > /proc/sys/vm/swappiness works until the next reboot. So if you want to change the value permanently you should edit it in rcS script.

TheSacredSoul 2010-04-01 17:26

Re: How to set swappiness?
 
Quote:

Originally Posted by @SR (Post 591565)
On n900 default value for swappiness is set by /etc/init.d/rcS script somewhere in the last lines.
echo value > /proc/sys/vm/swappiness works until the next reboot. So if you want to change the value permanently you should edit it in rcS script.

How can we get hold of this script from the n900, edit it and push it back?:o

@SR 2010-04-01 18:10

Re: How to set swappiness?
 
Quote:

Originally Posted by TheSacredSoul (Post 591640)
How can we get hold of this script from the n900, edit it and push it back?:o

I think the easiest way would be to edit the file on n900 itself (you only need to change one number in this file). I recommend editing it using nano editor in terminal (nano /etc/init.d/rcS). vi editor may be a little hard to use for someone who haven't used it before. it is available in repository (apt-get install nano). You will also need root rights to do anything with that file (modify it on devise or replace it with the one you edited on computer) so you will need rootsh.
If you chose to edit it on computer then you should first copy it for example in MyDocs using terminal:
cp /etc/init.d/rcS /home/user/MyDocs/
Edit it and then copy it back:
cp /home/user/MyDocs/rcS /etc/init.d/rcS

Be careful not to edit something else in this script as it may result in unbootable device and you would have to reflash firmware to restore it.

Venemo 2010-04-01 20:33

Re: How to set swappiness?
 
Quote:

Originally Posted by TheSacredSoul (Post 591640)
How can we get hold of this script from the n900, edit it and push it back?:o

Perhaps you can use Midnight Commander on the N900, or WinSCP over SSH to edit and save it.

dhcmega 2010-04-01 23:58

Re: How to set swappiness?
 
Quote:

Originally Posted by @SR (Post 591695)
I think the easiest way would be to edit the file on n900 itself (you only need to change one number in this file). I recommend editing it using nano editor in terminal (nano /etc/init.d/rcS). vi editor may be a little hard to use for someone who haven't used it before. it is available in repository (apt-get install nano). You will also need root rights to do anything with that file (modify it on devise or replace it with the one you edited on computer) so you will need rootsh.
If you chose to edit it on computer then you should first copy it for example in MyDocs using terminal:
cp /etc/init.d/rcS /home/user/MyDocs/
Edit it and then copy it back:
cp /home/user/MyDocs/rcS /etc/init.d/rcS

Be careful not to edit something else in this script as it may result in unbootable device and you would have to reflash firmware to restore it.

hi
if you move rcS around, make sure it end up with exec permitions.

ls -al /etc/init.d/rcS
will show rwxr-xr-x
(look at the 3 x)

will it not work inside MyDocs, but if it loses that permitions, you can set it back with: chmod +x /etc/init.d/rcS

you can check it with: ls -al /etc/init.d/rcS

TheSacredSoul 2010-04-02 00:17

Re: How to set swappiness?
 
Hmm. I decided to use midnight commander. easier then expected. I browsed to the folder, tapped edit, searched for "swappiness", changed the 100 to 30, saved it, and rebooted.

cat /proc/sys/vm/swappiness shows 30.

Lets see how much of an improvement there is.

noipv4 2010-06-05 07:16

Re: How to set swappiness?
 
I tried this
echo 0 > /proc/sys/vm/page-cluster

in vim /etc/init.d/rcS line 264.

guided by this blog http://www.sabi.co.uk/blog/anno05-3rd.html#050923

Seemed to reduce the pressure on VM usage.

hackfanatic 2010-07-09 18:51

Re: How to set swappiness?
 
Hey guys i thought ill bring this thread back to life.. i have been using swappiness to 30 past few days..

I dont see any ill effects at all.. and performance seems to have improved a lot .. and battery life by a bit if im not imagining things

am running 750 mhz clocked kernel..

slender 2010-08-30 21:37

Re: How to set swappiness?
 
I have also tested swappiness 30 and page-cluster 0. I'm pretty sure that responsivness has been better. I would be highly interested on possible side-effects on these changes.

btw.
is it possible to unload preloaded modest and browserd?

.edit
I have also seen some nice value tweaks. Have you tried them and what were the results?

j.s 2010-08-30 21:48

Re: How to set swappiness?
 
Quote:

Originally Posted by pycage (Post 591545)
I have been running my N900 with swappiness 30 for some weeks without any ill side-effect. But it seems that battery-life and device responsiveness have both noticably improved.

BTW, on Diablo OS, the default swappiness value was 1. I'm almost certain that a default value of 100 on the N900 is not the optimal setting for this device at all.

In March, you said that you were using 1.
http://talk.maemo.org/showthread.php?t=47173&page=2

Did you decide 30 is better?

JaseP 2010-09-02 17:56

Re: How to set swappiness?
 
I just switched swappiness to 30,... much faster in starting and stopping applications,... just more responsive overall.

To give a comparison, Ubuntu defaults to a swapiness value of 60. On some server systems, where a large program is going to remain in memory while other tasks are being performed, a swappiness value of 100 can be advisable, but 60 is the sweet spot for desktop/server hybrid use (which is why they use that). For most desktop use, with a decent amount of RAM, you want to have a swappiness setting of 10 on Ubuntu systems...

The trade off is having enough virtual memory for keeping application that are idle running and happy, versus having too much being pushed to virtual memory. With flash memory, it has limited read-write cycles, even with modern level wearing stuff going on, so lower swappiness will help the system's flash memory lifespan.

For the N900, because it has flash storage, a setting of 60 is probably too much. And since flash memory's faster than disk, a 30 is proabably about right for the N900.

Setting it too low (like a 0 or a 1) might possibly effect some daemons (Like phone related stuff) running in the background that we might not be aware of. But overall, I agree that a 100 is way out of line. Running at 30 makes it seem like a whole new device.

mr_xzibit 2010-09-03 22:47

Re: How to set swappiness?
 
how do i edit with midnight commander? i can locate the rcS edit it but it wont save my settings?

egoshin 2010-09-03 23:27

Re: How to set swappiness?
 
Quote:

Originally Posted by JaseP (Post 805475)
And since flash memory's faster than disk

That is wrong. Test it yourself - eMMC flash speed is around 19MByte/sec but most of modern hard disk have more than 50MBytes/sec. And some server disks have around 130MByte/sec.

However, the swapiness 100 is definitely wrong, at least with current kernel - it doesn't have a conditional swapiness which would stop swap ops in progress if there is no "not-enough-memory" condition and some urgent flash IO.

tomast 2010-09-03 23:34

Re: How to set swappiness?
 
You must become root before starting mc. Install package 'rootsh', start xterminal, write
Code:

root
mc

But be careful, especially when editing rcS. It's easy to render your N900 unbootable.

egoshin 2010-09-04 00:22

Re: How to set swappiness?
 
I highly recommend to anybody who wants to change rcS - instead of that just create a file /etc/event.d/somename with following lines:

Code:

description "my somename fix"
author "My Name"

console output

start on started rcS-late

script
      echo "30" > /proc/sys/vm/swappiness
end script

... and insert any another wished lines after "echo 30" and before "end script"

This would not corrupt your N900 in case of problem and it allows the next Nokia OTA upgrade.

You need to be root and run your favorite editor (see prev posts for know how to edit file).

toxaris 2010-09-07 06:49

Re: How to set swappiness?
 
Quote:

Originally Posted by egoshin (Post 806769)
I highly recommend to anybody who wants to change rcS - instead of that just create a file /etc/event.d/somename with following lines:

Code:

# my somename fix

start on started rcS-late

script
      echo 30 > /proc/sys/vm/swappiness
end script

... and insert any another wished lines after "echo 30" and before "end script"

This would not corrupt your N900 in case of problem and it allows the next Nokia OTA upgrade.

You need to be root and run your favorite editor (see prev posts for know how to edit file).

Yea, good idea. thx

hassan_badredin 2010-09-07 14:53

Re: How to set swappiness?
 
how do i get this symbol in n900??

>

wmarone 2010-09-07 14:58

Re: How to set swappiness?
 
Quote:

Originally Posted by egoshin (Post 806732)
That is wrong. Test it yourself - eMMC flash speed is around 19MByte/sec but most of modern hard disk have more than 50MBytes/sec. And some server disks have around 130MByte/sec.

As I noted to you elsewhere, a hard disk can do 50MByte/s or better but only when streaming. As soon as you start pushing random pages on and off disk, doing small reads and writes, a hard disk can fall under 200KB/s while a decent SSD will maintain at least 1MByte/s or better.

Consider that writing a single 4K RAM page consists of 8 x 512B writes (with the only benefit being that -this- page will be contiguous) and if you're pushing off more than a few pages swap partition, you're going to be hurting.

The eMMC lacking moving parts should maintain throughput much better. If you're real curious, you could always throw IOMeter at it ;)

sony123 2010-09-07 18:33

Re: How to set swappiness?
 
FYI this is a good tutorial of Linux VM

http://www.redhat.com/magazine/001nov04/features/vm/

geneven 2010-09-07 18:45

Re: How to set swappiness?
 
Quote:

Originally Posted by hassan_badredin (Post 809602)
how do i get this symbol in n900??

>

You go to the manual and read the section titled "Enter a character not found from the keyboard."

To save you some time, here is what the manual says:

"Press and hold (the diagonal blue arrow) and then press the sym key."

egoshin 2010-09-07 19:09

Re: How to set swappiness?
 
Actually, flash devices are more suitable for streaming then random access - there is a serious logic behind that. Yes the random access in flash is faster for READ but write is another story and it is not very good for flash devices yet.

In any way, swap write is essentially a sequential operation. Kernel does a special logic behind this.


All times are GMT. The time now is 06:34.

vBulletin® Version 3.8.8