FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Gentoo > Gentoo User

 
 
LinkBack Thread Tools
 
Old 12-29-2011, 09:34 PM
Claudio Roberto França Pereira
 
Default To swap or not to swap? Is it really needed?

I've run my box with 2x2GB of RAM for a while, but a couple weeks ago
one of my chips died, and now I'm stuck with 1x2GB. That's not that
terrible, I'm using Gentoo all day, rarely switching to Windows 7
anyways, who really likes RAM.
Anyway, for the last days, my machine has been really slow, with mouse
lag, input delay, and other things. I imediately associated it to the
lack of free RAM, but I always rushed to check the RAM usage with htop
and it were never really high. So today I decided to turn my swap
partition off. And the system is FLYING. I mean, it's pratically a new
machine, now it's usable and reliable.

I thought of falling back from KDE 4 to awesome (tried it earlier in
an old notebook last year) given the memory footprint of KDE, but it
seems that my hard disk was the culprit here.
I've heard that Linux need a little swap partition, maybe just 512MB,
for some tasks, but I'm not going to turn it on anytime soon. It's a
desktop machine, 24/7, and I couldn't care less about suspend-to-disk.

So, should I ban swap partitions entirely from my life? Is that ok?
 
Old 12-29-2011, 09:48 PM
Alan McKinnon
 
Default To swap or not to swap? Is it really needed?

On Thu, 29 Dec 2011 20:34:16 -0200
Claudio Roberto França Pereira <spideybr@gmail.com> wrote:

> I've run my box with 2x2GB of RAM for a while, but a couple weeks ago
> one of my chips died, and now I'm stuck with 1x2GB. That's not that
> terrible, I'm using Gentoo all day, rarely switching to Windows 7
> anyways, who really likes RAM.
> Anyway, for the last days, my machine has been really slow, with mouse
> lag, input delay, and other things. I imediately associated it to the
> lack of free RAM, but I always rushed to check the RAM usage with htop
> and it were never really high. So today I decided to turn my swap
> partition off. And the system is FLYING. I mean, it's pratically a new
> machine, now it's usable and reliable.
>
> I thought of falling back from KDE 4 to awesome (tried it earlier in
> an old notebook last year) given the memory footprint of KDE, but it
> seems that my hard disk was the culprit here.
> I've heard that Linux need a little swap partition, maybe just 512MB,
> for some tasks, but I'm not going to turn it on anytime soon. It's a
> desktop machine, 24/7, and I couldn't care less about suspend-to-disk.
>
> So, should I ban swap partitions entirely from my life? Is that ok?



This question comes up about every three months or so, and the end
result is always the same: the same people chip in with the same
answers and we all come to the same conclusion.

You should check the Gentoo archives for the most recent gigantic
thread on this, that one was particularly illuminating.

But to summarize:

You haven't given any real info for people to answer your actual
question. To do that, we need to know what exactly your machine is
doing and why, please what your swap settings are.

Generally, the kernel is happiest with a little bit of swap (512 MB is
a very much more than a little) and you can get by with that if your
apps fit into ram. KDE is reasonably smart with ram usage, if you only
have 2G it will try fit into that. If you have 22G it will try to use
lots.

If your machine was really slow, it was likely thrashing. But no-one
can say for sure - what was your disk doing at the time? What did
vmstat say was going on?

To summarize a summary, the answer to "can I ban swap?" is "maybe"



--
Alan McKinnnon
alan.mckinnon@gmail.com
 
Old 12-29-2011, 10:09 PM
Dale
 
Default To swap or not to swap? Is it really needed?

Claudio Roberto França Pereira wrote:

I've run my box with 2x2GB of RAM for a while, but a couple weeks ago
one of my chips died, and now I'm stuck with 1x2GB. That's not that
terrible, I'm using Gentoo all day, rarely switching to Windows 7
anyways, who really likes RAM.
Anyway, for the last days, my machine has been really slow, with mouse
lag, input delay, and other things. I imediately associated it to the
lack of free RAM, but I always rushed to check the RAM usage with htop
and it were never really high. So today I decided to turn my swap
partition off. And the system is FLYING. I mean, it's pratically a new
machine, now it's usable and reliable.

I thought of falling back from KDE 4 to awesome (tried it earlier in
an old notebook last year) given the memory footprint of KDE, but it
seems that my hard disk was the culprit here.
I've heard that Linux need a little swap partition, maybe just 512MB,
for some tasks, but I'm not going to turn it on anytime soon. It's a
desktop machine, 24/7, and I couldn't care less about suspend-to-disk.

So, should I ban swap partitions entirely from my life? Is that ok?




You may want to adjust how swap is being used. I have swap but only
want it used to prevent a lockup or some other bad situation. I have
this in /etc/sysctl.conf:


vm.swappiness = 20

With a setting of 20, it will use swap but only when it is out of ram.
I have 16Gbs of ram in my rig and I wouldn't run it without at least a
little swap. Why? Well not long ago I did a update. One of the KDE
programs got updated and I was still logged in. It wasn't happy and
starting eating ram like a cookie monster. That one program was using
over 14Gbs and growing. I was able to kill it before things got to bad
but even with 16Gbs of ram and swap, it was dog slow. Another minute or
two, it may have locked me out.


I would recommend having swap and just setting it to use it when ram
fills up. I would also replace that stick when I could too. ;-)


Dale

:-) :-)

--
I am only responsible for what I said ... Not for what you understood or how you interpreted my words!

Miss the compile output? Hint:
EMERGE_DEFAULT_OPTS="--quiet-build=n"
 
Old 12-29-2011, 10:11 PM
Claudio Roberto França Pereira
 
Default To swap or not to swap? Is it really needed?

Sorry for being so general, for not giving any real info. I'm new to
system monitoring, I just learnt about iostat and swapon -s, now about
vmstat. I mainly tried to catch anything unusual in top/htop.

Trying to be more specifically, my system is a core 2 duo, dual core
3ghz processor, 4gb of ram (now 2gb), ATI radeon HD4850 with 512mb of
vram. I used to play a lot on this box, now a lot less. On Gentoo,
when I play is some browser game or cowsay (it's in games-misc!), not
anything relevant. I'm using radeon open source drivers, by the way.
My main use, currently, is web surfing, firefox with LOTS of tabs,
email, social networks and random browsing. Firefox alone uses lots of
ram, almost always it's using more than a half GB, sometimes it passes
the 1gb mark. I also do Qt develop on this, but nothing heavy. No
virtual machines, no 3d rendering, no heavy processing, no
hibernation.

So, I'm just a basic common web surfer. In this case, can I say it's
at least SAFE to disable swap? I'll look into "last month's" thread on
this.
 
Old 12-29-2011, 11:03 PM
Paul Hartman
 
Default To swap or not to swap? Is it really needed?

On Thu, Dec 29, 2011 at 5:11 PM, Claudio Roberto França Pereira
<spideybr@gmail.com> wrote:
> Sorry for being so general, for not giving any real info. I'm new to
> system monitoring, I just learnt about iostat and swapon -s, now about
> vmstat. I mainly tried to catch anything unusual in top/htop.
>
> Trying to be more specifically, my system is a core 2 duo, dual core
> 3ghz processor, 4gb of ram (now 2gb), ATI radeon HD4850 with 512mb of
> vram. I used to play a lot on this box, now a lot less. On Gentoo,
> when I play is some browser game or cowsay (it's in games-misc!), not
> anything relevant. I'm using radeon open source drivers, by the way.
> My main use, currently, is web surfing, firefox with LOTS of tabs,
> email, social networks and random browsing. Firefox alone uses lots of
> ram, almost always it's using more than a half GB, sometimes it passes
> the 1gb mark. I also do Qt develop on this, but nothing heavy. No
> virtual machines, no 3d rendering, no heavy processing, no
> hibernation.
>
> So, I'm just a basic common web surfer. In this case, can I say it's
> at least SAFE to disable swap? I'll look into "last month's" thread on
> this.
>

Safe to disable, sure. "swapoff" your device(s) and see how it goes.
If you start to get out-of-memory errors, you know you've made the
wrong decision.

I think general opinion is that swap is slow and kills performance,
you want to avoid it happening if at all possible. If you have enough
RAM to avoid using it entirely, great. Tuning the sysctl settings like
Dale said, while still having swap partition "just in case" is the way
I'd go. If the system is swapping all the time, maybe you just need
more RAM.

While you're looking at recent threads, check the one about ZRAM also.
It is a good alternative to (or complement to) disk-based swap, if
your normal swap usage is less than the amount of ZRAM you've
allocated.

Some things, like suspend-to-disk, might require a swap device
on-disk. I have never used that feature myself, so I'm not familiar
with the details.
 
Old 12-30-2011, 01:23 AM
Claudio Roberto França Pereira
 
Default To swap or not to swap? Is it really needed?

ZRAM is a compressed ramdisk for swap, right? I'm really not
interested currently.
My next system will have 16gb of ram, and I'll create an 8gb ramdisk
on it to increase emerge performance. Other than that, I'm pretty
happy with my system performance, disabling swap and compositing
effects (remember, open source radeon drivers, I might try fglrx again
but I really liked KMS) did the trick.
 
Old 12-30-2011, 01:56 AM
Nikos Chantziaras
 
Default To swap or not to swap? Is it really needed?

On 12/30/2011 12:34 AM, Claudio Roberto França Pereira wrote:

Anyway, for the last days, my machine has been really slow, with mouse
lag, input delay, and other things. I imediately associated it to the
lack of free RAM, but I always rushed to check the RAM usage with htop
and it were never really high. So today I decided to turn my swap
partition off. And the system is FLYING. I mean, it's pratically a new
machine, now it's usable and reliable.
[...]


Usable, yes. Reliable, no ;-) Once RAM runs out, random processes get
killed. Possible data loss due to that.




So, should I ban swap partitions entirely from my life? Is that ok?


No. You simply tweak swappiness. In your /etc/sysctl.conf, add this:

vm.swappiness = 20

The default value is 60. Which makes the system use swap very early on.
With 20, you pretty much will swap only when really needed. I've read
somewhere that values lower than 20 are not recommended, but I don't
remember where or why.
 
Old 12-30-2011, 02:54 AM
Michael Mol
 
Default To swap or not to swap? Is it really needed?

On Thu, Dec 29, 2011 at 9:23 PM, Claudio Roberto França Pereira
<spideybr@gmail.com> wrote:
> ZRAM is a compressed ramdisk for swap, right? I'm really not
> interested currently.
> My next system will have 16gb of ram, and I'll create an 8gb ramdisk
> on it to increase emerge performance. Other than that, I'm pretty
> happy with my system performance, disabling swap and compositing
> effects (remember, open source radeon drivers, I might try fglrx again
> but I really liked KMS) did the trick.

8GB isn't enough for some packages. Though putting it on top of zram
might work. I don't know how you'd calculate the free space, though,
and portage would check in advance.

--
:wq
 
Old 12-30-2011, 06:31 AM
Dale
 
Default To swap or not to swap? Is it really needed?

Michael Mol wrote:

On Thu, Dec 29, 2011 at 9:23 PM, Claudio Roberto França Pereira
<spideybr@gmail.com> wrote:

ZRAM is a compressed ramdisk for swap, right? I'm really not
interested currently.
My next system will have 16gb of ram, and I'll create an 8gb ramdisk
on it to increase emerge performance. Other than that, I'm pretty
happy with my system performance, disabling swap and compositing
effects (remember, open source radeon drivers, I might try fglrx again
but I really liked KMS) did the trick.

8GB isn't enough for some packages. Though putting it on top of zram
might work. I don't know how you'd calculate the free space, though,
and portage would check in advance.



I have portages work directory on tmpfs and it works fine. I don't have
it set to a specific amount so it uses whatever it needs. It even works
fine with LOo. I have 16Gbs in all but it rarely uses more than 4Gbs.
Of course, I don't just sit here and watch it either. I start my
updates and usually go to bed.


Dale

:-) :-)

--
I am only responsible for what I said ... Not for what you understood or how you interpreted my words!

Miss the compile output? Hint:
EMERGE_DEFAULT_OPTS="--quiet-build=n"
 
Old 12-30-2011, 12:32 PM
Michael Mol
 
Default To swap or not to swap? Is it really needed?

On Fri, Dec 30, 2011 at 2:31 AM, Dale <rdalek1967@gmail.com> wrote:
> Michael Mol wrote:
>>
>> On Thu, Dec 29, 2011 at 9:23 PM, Claudio Roberto França Pereira
>> <spideybr@gmail.com> *wrote:
>>>
>>> ZRAM is a compressed ramdisk for swap, right? I'm really not
>>> interested currently.
>>> My next system will have 16gb of ram, and I'll create an 8gb ramdisk
>>> on it to increase emerge performance. Other than that, I'm pretty
>>> happy with my system performance, disabling swap and compositing
>>> effects (remember, open source radeon drivers, I might try fglrx again
>>> but I really liked KMS) did the trick.
>>
>> 8GB isn't enough for some packages. Though putting it on top of zram
>> might work. I don't know how you'd calculate the free space, though,
>> and portage would check in advance.
>>
>
> I have portages work directory on tmpfs and it works fine. *I don't have it
> set to a specific amount so it uses whatever it needs. *It even works fine
> with LOo. *I have 16Gbs in all but it rarely uses more than 4Gbs. *Of
> course, I don't just sit here and watch it either. *I start my updates and
> usually go to bed.

Hm. tmpfs defaults (at least on my system) to a capacity of about 3GB.
What do you have for mount options in fstab?

I used to put portage's work directory on tmpfs, but I had to stop
when LO ran out of space in a pre-check, IIRC. Now I have it on top of
a RAID5 it shares with /home.

--
:wq
 

Thread Tools




All times are GMT. The time now is 12:42 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2007 - 2008, www.linux-archive.org