Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
The truth about swap
View unanswered posts
View posts from last 24 hours

Goto page Previous  1, 2, 3, 4  Next  
Reply to topic    Gentoo Forums Forum Index Off the Wall
View previous topic :: View next topic  
Author Message
sundialsvc4
Guru
Guru


Joined: 10 Nov 2005
Posts: 433

PostPosted: Fri Apr 24, 2009 12:19 pm    Post subject: Reply with quote

That may be why systems like Windows and OS/X swap to a disk-file ... which you can also do in Linux, I believe.

I like to give the system somewhere to stuff data, but when RAM sizes are measured in gigabytes it really does become less of a point.

I would say... it's reasonable to turn-off swap if you have lots of RAM. You can always turn it back on again. The system won't use it anyway, if it doesn't need it. I'd just avoid having a fixed allocation of disk-space, e.g. a partition, for such a (now highly unlikely) purpose anymore.
Back to top
View user's profile Send private message
atrus123
Guru
Guru


Joined: 06 Jul 2005
Posts: 339
Location: Annapolis, MD

PostPosted: Fri Apr 24, 2009 1:47 pm    Post subject: Reply with quote

I've recently been working with some huge files on my laptop w/ 2GB ram.

Basically I have a gigantic image, built in the Gimp and imported into Inkscape for some additional modifications. Then (because Inkscape annoyingly doesn't support compressed PDFs), I export the finished image as PNG and use Imagemagick to build the compressed PDF.

Gimp uses doesn't use swap, but Inkscape and Imagemagick do. If I hadn't given myself 1GB swap to work with, I'd be screwed.

I see no reason to ever shut it off. My system never ever uses swap unless I start doing big graphics work. I don't need to manage it at all.
_________________
"I cannot support a movement that exploded spending and borrowing and blames its successor for the debt."
-Andrew Sullivan
Back to top
View user's profile Send private message
bunder
Bodhisattva
Bodhisattva


Joined: 10 Apr 2004
Posts: 5213

PostPosted: Fri Apr 24, 2009 1:52 pm    Post subject: Reply with quote

i've almost maxed out the swap on my laptop quite a few times editing images in gimp. it's a real pain too, because the PSD's are supposedly big (8mb is big?)... but when i get them open and make a few changes i get really really close to OOM-ing. never had that problem doing video editing back in the day... :?

edit: doesn't help that X and firefox take up most of my ram after a few hours. :roll:
_________________
goodbye fgo. it was nice knowing you.
Back to top
View user's profile Send private message
i92guboj
Moderator
Moderator


Joined: 30 Nov 2004
Posts: 9464
Location: Córdoba (Spain)

PostPosted: Fri Apr 24, 2009 2:05 pm    Post subject: Reply with quote

bunder wrote:
i've almost maxed out the swap on my laptop quite a few times editing images in gimp. it's a real pain too, because the PSD's are supposedly big (8mb is big?)


I know nothing about the psd internal format. But I guess they use some kind of compression algorithm. When dealing with images you don't have to look at the size of the psd, but at the size of the bitmaps once they are uncompressed on your ram, which is how they are when you open the file. And that size will be width*height*bpp plus other info that the file might contain like alpha channels and such. So, an image of 1024x768x24 will always take 18MB, even if the jpg container only takes 35k on your disk.

So, if the psd file takes 8mb in your hd it's very likely that it can take 2, 3, 5, 20 or 200 times more space in your ram. It all depends on the contents of the bitmaps that the file holds inside. Try saving it as an uncompressed bmp (not rle) to get an idea of the real size of the contents (and even then it would be only an approximation because in psd you can have lots of layers, while in bmp you have only one bitmap).
_________________
Gentoo Handbook | My website
Back to top
View user's profile Send private message
durian
Guru
Guru


Joined: 16 Jul 2003
Posts: 312
Location: Margretetorp

PostPosted: Fri Apr 24, 2009 2:21 pm    Post subject: Reply with quote

mdeininger wrote:
yeah that's pretty heavyweight alright :D. kind of reminds me of the arm cluster i'm occasionally emulating on my desktop; lucky i limit those to 32 megs per node :D.

Just for fun, a bit of "top":

Code:
top - 16:18:20 up 8 days,  2:45,  9 users,  load average: 3.03, 3.03, 3.00
Tasks: 239 total,   4 running, 235 sleeping,   0 stopped,   0 zombie
Cpu(s): 12.4%us,  0.0%sy,  0.0%ni, 87.5%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:  132304508k total, 131717844k used,   586664k free,   340268k buffers
Swap:  7815580k total,  1151852k used,  6663728k free, 24784720k cached

  PID USER     PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND           
12694 user1    18  -2 53.0g  52g 1844 R  100 41.9   1191:56 wopr               
  830 user1    18  -2 44.7g  43g 1808 R   99 34.7   3385:46 wopr               
11538 user2    18  -2 3821m 3.7g 1764 R   99  2.9   2677:10 Timbl             


It runs debian, btw. :)

-peter
Back to top
View user's profile Send private message
bunder
Bodhisattva
Bodhisattva


Joined: 10 Apr 2004
Posts: 5213

PostPosted: Fri Apr 24, 2009 3:45 pm    Post subject: Reply with quote

i92guboj wrote:
bunder wrote:
i've almost maxed out the swap on my laptop quite a few times editing images in gimp. it's a real pain too, because the PSD's are supposedly big (8mb is big?)


I know nothing about the psd internal format. But I guess they use some kind of compression algorithm. When dealing with images you don't have to look at the size of the psd, but at the size of the bitmaps once they are uncompressed on your ram, which is how they are when you open the file. And that size will be width*height*bpp plus other info that the file might contain like alpha channels and such. So, an image of 1024x768x24 will always take 18MB, even if the jpg container only takes 35k on your disk.

So, if the psd file takes 8mb in your hd it's very likely that it can take 2, 3, 5, 20 or 200 times more space in your ram. It all depends on the contents of the bitmaps that the file holds inside. Try saving it as an uncompressed bmp (not rle) to get an idea of the real size of the contents (and even then it would be only an approximation because in psd you can have lots of layers, while in bmp you have only one bitmap).


it's a combination of the both... the images are 2048x2048 with upwards of 10 layers (one of them wireframe, but normally hidden)... when i export to jpg they only come out to 200kb. not entirely small. :?
_________________
goodbye fgo. it was nice knowing you.
Back to top
View user's profile Send private message
durian
Guru
Guru


Joined: 16 Jul 2003
Posts: 312
Location: Margretetorp

PostPosted: Fri Apr 24, 2009 4:05 pm    Post subject: Reply with quote

i92guboj wrote:
I know nothing about the psd internal format. But I guess they use some kind of compression algorithm. ...
See here someone's opinion on PSD format: http://code.google.com/p/xee/source/browse/trunk/XeePhotoshopLoader.m?spec=svn28 lines 107-136

-peter
Back to top
View user's profile Send private message
bunder
Bodhisattva
Bodhisattva


Joined: 10 Apr 2004
Posts: 5213

PostPosted: Fri Apr 24, 2009 4:18 pm    Post subject: Reply with quote

durian wrote:
i92guboj wrote:
I know nothing about the psd internal format. But I guess they use some kind of compression algorithm. ...
See here someone's opinion on PSD format: http://code.google.com/p/xee/source/browse/trunk/XeePhotoshopLoader.m?spec=svn28 lines 107-136

-peter


LOL! that's awesome. :lol:
_________________
goodbye fgo. it was nice knowing you.
Back to top
View user's profile Send private message
atrus123
Guru
Guru


Joined: 06 Jul 2005
Posts: 339
Location: Annapolis, MD

PostPosted: Fri Apr 24, 2009 4:36 pm    Post subject: Reply with quote

bunder wrote:
i92guboj wrote:
bunder wrote:
i've almost maxed out the swap on my laptop quite a few times editing images in gimp. it's a real pain too, because the PSD's are supposedly big (8mb is big?)


I know nothing about the psd internal format. But I guess they use some kind of compression algorithm. When dealing with images you don't have to look at the size of the psd, but at the size of the bitmaps once they are uncompressed on your ram, which is how they are when you open the file. And that size will be width*height*bpp plus other info that the file might contain like alpha channels and such. So, an image of 1024x768x24 will always take 18MB, even if the jpg container only takes 35k on your disk.

So, if the psd file takes 8mb in your hd it's very likely that it can take 2, 3, 5, 20 or 200 times more space in your ram. It all depends on the contents of the bitmaps that the file holds inside. Try saving it as an uncompressed bmp (not rle) to get an idea of the real size of the contents (and even then it would be only an approximation because in psd you can have lots of layers, while in bmp you have only one bitmap).


it's a combination of the both... the images are 2048x2048 with upwards of 10 layers (one of them wireframe, but normally hidden)... when i export to jpg they only come out to 200kb. not entirely small. :?

That sounds about right for the jpg.

I bet if you were to max the jpeg quality and change your subsampling (found under Advanced Options of the save dialog) to 1x1,1x1,1x1, the file would be a hell of a lot larger.
_________________
"I cannot support a movement that exploded spending and borrowing and blames its successor for the debt."
-Andrew Sullivan
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 29996
Location: 56N 3W

PostPosted: Fri Apr 24, 2009 6:17 pm    Post subject: Reply with quote

atrus123,

You can always make a swap file. Swap need not be a partition, its just faster that way as swapping does not involve the filesystem driver.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
TNorthover
Guru
Guru


Joined: 25 Jan 2004
Posts: 434
Location: Edinburgh, UK

PostPosted: Fri Apr 24, 2009 6:23 pm    Post subject: Reply with quote

NeddySeagoon wrote:
You can always make a swap file. Swap need not be a partition, its just faster that way as swapping does not involve the filesystem driver.

I believe it skips that during normal operation anyway. On initialisation it finds out which blocks it has and uses just uses those raw afterwards.
Back to top
View user's profile Send private message
energyman76b
Advocate
Advocate


Joined: 26 Mar 2003
Posts: 2022
Location: Germany

PostPosted: Fri Apr 24, 2009 6:42 pm    Post subject: Reply with quote

NeddySeagoon wrote:
atrus123,

You can always make a swap file. Swap need not be a partition, its just faster that way as swapping does not involve the filesystem driver.


that isn't true anymore (since 2.6 AFAIR). But it could still be faster - if the swapfile has holes...
_________________
AidanJT wrote:

Libertardian denial of reality is wholly unimpressive and unconvincing, and simply serves to demonstrate what a bunch of delusional fools they all are.

Satan's got perfectly toned abs and rocks a c-cup.
Back to top
View user's profile Send private message
cokehabit
Advocate
Advocate


Joined: 23 Apr 2004
Posts: 3302

PostPosted: Fri Apr 24, 2009 7:02 pm    Post subject: Reply with quote

Code:
leviathon ~ # free
             total       used       free     shared    buffers     cached
Mem:       2057568    1366068     691500          0     134516     735580
-/+ buffers/cache:     495972    1561596
Swap:      4000176      36352    3963824
what a waste :(
Back to top
View user's profile Send private message
eccerr0r
Advocate
Advocate


Joined: 01 Jul 2004
Posts: 3000
Location: USA

PostPosted: Fri Apr 24, 2009 7:55 pm    Post subject: Reply with quote

My (rough) rules for swap files/partitions:

Rule 1: If needed for swsusp, allocate enough for swsusp
Rule 2: If not using magnetic hard drives, swap = 0 and look for more RAM...
Rule 3: If system RAM is less than or equal to 256MB, set for 2x RAM size
Rule 4: All other cases: take single disk bandwidth and multiply by 15 seconds. Use that as a basis for swap size. If it exceeds 2X RAM, then cap at 2X RAM
Rule 5: If you have much more RAM than your apps really can use (don't count disk cache), then reduce swap partition size...

Recently I've been building/getting machines with more RAM than I really could use. Even at 1GB RAM, if I set things up properly and there are no leaks, I don't think I could use it all for apps (of course, cache will always be useful). Mostly I keep swap for some overflow protection as well as swapping out anything that won't be used for a while. Unused stuff in RAM that can't be freed (such as memory leaks) IS, however, wasted RAM. But you can swap out application memory leaks and go on, as if nothing ever happened...

Typically I cap out at 1GB swap or so, unless dealing with swsusp. A lot of machines I have 512MB mostly due to legacy calculations...
_________________
Core-i7-2700K@4.1GHz/8GB RAM/180GB SSD/Intel HD3000 graphics
What the heck am I advocating?
Back to top
View user's profile Send private message
mdeininger
Veteran
Veteran


Joined: 15 Jun 2005
Posts: 1738
Location: University of Tuebingen, Germany

PostPosted: Tue Apr 28, 2009 5:25 pm    Post subject: Reply with quote

durian wrote:
mdeininger wrote:
yeah that's pretty heavyweight alright :D. kind of reminds me of the arm cluster i'm occasionally emulating on my desktop; lucky i limit those to 32 megs per node :D.

Just for fun, a bit of "top":

Code:
top - 16:18:20 up 8 days,  2:45,  9 users,  load average: 3.03, 3.03, 3.00
Tasks: 239 total,   4 running, 235 sleeping,   0 stopped,   0 zombie
Cpu(s): 12.4%us,  0.0%sy,  0.0%ni, 87.5%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:  132304508k total, 131717844k used,   586664k free,   340268k buffers
Swap:  7815580k total,  1151852k used,  6663728k free, 24784720k cached

  PID USER     PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND           
12694 user1    18  -2 53.0g  52g 1844 R  100 41.9   1191:56 wopr               
  830 user1    18  -2 44.7g  43g 1808 R   99 34.7   3385:46 wopr               
11538 user2    18  -2 3821m 3.7g 1764 R   99  2.9   2677:10 Timbl             


It runs debian, btw. :)

-peter
lol, funky, i don't think i've ever seen a 'g' used as a unit in top :)
_________________
"Confident, lazy, cocky, dead." -- Felix Jongleur, Otherland

( hot: jyujinX on Twitter | ef.gy )
Back to top
View user's profile Send private message
cokehabit
Advocate
Advocate


Joined: 23 Apr 2004
Posts: 3302

PostPosted: Tue Apr 28, 2009 7:16 pm    Post subject: Reply with quote

mdeininger wrote:
durian wrote:
mdeininger wrote:
yeah that's pretty heavyweight alright :D. kind of reminds me of the arm cluster i'm occasionally emulating on my desktop; lucky i limit those to 32 megs per node :D.

Just for fun, a bit of "top":

Code:
top - 16:18:20 up 8 days,  2:45,  9 users,  load average: 3.03, 3.03, 3.00
Tasks: 239 total,   4 running, 235 sleeping,   0 stopped,   0 zombie
Cpu(s): 12.4%us,  0.0%sy,  0.0%ni, 87.5%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:  132304508k total, 131717844k used,   586664k free,   340268k buffers
Swap:  7815580k total,  1151852k used,  6663728k free, 24784720k cached

  PID USER     PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND           
12694 user1    18  -2 53.0g  52g 1844 R  100 41.9   1191:56 wopr               
  830 user1    18  -2 44.7g  43g 1808 R   99 34.7   3385:46 wopr               
11538 user2    18  -2 3821m 3.7g 1764 R   99  2.9   2677:10 Timbl             


It runs debian, btw. :)

-peter
lol, funky, i don't think i've ever seen a 'g' used as a unit in top :)
g is the best letter there is :wink:
Back to top
View user's profile Send private message
poly_poly-man
Advocate
Advocate


Joined: 06 Dec 2006
Posts: 2477
Location: RIT, NY, US

PostPosted: Tue Apr 28, 2009 8:50 pm    Post subject: Reply with quote

gcc always gives me trouble on big emerges - I am constantly eating through swap.
_________________
iVBORw0KGgoAAAANSUhEUgAAA

avatar: new version of logo - see topic 838248. Potentially still a WiP.
Back to top
View user's profile Send private message
cokehabit
Advocate
Advocate


Joined: 23 Apr 2004
Posts: 3302

PostPosted: Tue Apr 28, 2009 9:02 pm    Post subject: Reply with quote

poly_poly-man wrote:
gcc always gives me trouble on big emerges - I am constantly eating through swap.
Do you have strange CFLAGS or too high MAKEOPTS?
Back to top
View user's profile Send private message
mdeininger
Veteran
Veteran


Joined: 15 Jun 2005
Posts: 1738
Location: University of Tuebingen, Germany

PostPosted: Tue Apr 28, 2009 9:10 pm    Post subject: Reply with quote

cokehabit wrote:
g is the best letter there is :wink:
the letter to rule them all is, of course, the lambda! also kappa is pretty important in one of the contexts where lambda occurs :D.
_________________
"Confident, lazy, cocky, dead." -- Felix Jongleur, Otherland

( hot: jyujinX on Twitter | ef.gy )
Back to top
View user's profile Send private message
mdeininger
Veteran
Veteran


Joined: 15 Jun 2005
Posts: 1738
Location: University of Tuebingen, Germany

PostPosted: Tue Apr 28, 2009 9:11 pm    Post subject: Reply with quote

poly_poly-man wrote:
gcc always gives me trouble on big emerges - I am constantly eating through swap.
gcc or ld? ld is pretty evil on c++ linking.
_________________
"Confident, lazy, cocky, dead." -- Felix Jongleur, Otherland

( hot: jyujinX on Twitter | ef.gy )
Back to top
View user's profile Send private message
jdmulloy
Tux's lil' helper
Tux's lil' helper


Joined: 24 Dec 2004
Posts: 139
Location: Massachusetts, USA

PostPosted: Tue Apr 28, 2009 9:12 pm    Post subject: Reply with quote

cokehabit wrote:
poly_poly-man wrote:
gcc always gives me trouble on big emerges - I am constantly eating through swap.
Do you have strange CFLAGS or too high MAKEOPTS?


Well of course you're going to hit swap on a machine that has 16MB of RAM.

:lol:
_________________
Joe Mulloy | http://twitter.com/jdmulloy | Ron Paul in 2012! | 5-1-07 | Unban Playfool | Fire your "Too big to fail" bank http://moveyourmoney.info
Back to top
View user's profile Send private message
eccerr0r
Advocate
Advocate


Joined: 01 Jul 2004
Posts: 3000
Location: USA

PostPosted: Tue Apr 28, 2009 9:12 pm    Post subject: Reply with quote

Compiling C++ programs tends to eat a lot of RAM.

I was trying to compile CenterICQ (CenterIM) on my DECstation 3100 (NetBSD). It has 24MB RAM at 16.6MHz, and compiling it would chew through all of swap (since it is a classic Un*x machine it has 48MB swap). Of course, it then ended up at the OOM killer.

Since I really didn't care what that machine was doing, I ended up letting it have 100MB more swap on another disk and let it go...

It took 3 days of nonstop swapping to finally complete building CenterICQ with just the ICQ personality enabled.

Then again it takes about 5 hours to compile a new NetBSD kernel.
_________________
Core-i7-2700K@4.1GHz/8GB RAM/180GB SSD/Intel HD3000 graphics
What the heck am I advocating?
Back to top
View user's profile Send private message
cokehabit
Advocate
Advocate


Joined: 23 Apr 2004
Posts: 3302

PostPosted: Tue Apr 28, 2009 9:25 pm    Post subject: Reply with quote

jdmulloy wrote:
cokehabit wrote:
poly_poly-man wrote:
gcc always gives me trouble on big emerges - I am constantly eating through swap.
Do you have strange CFLAGS or too high MAKEOPTS?


Well of course you're going to hit swap on a machine that has 16MB of RAM.

:lol:
my watch has more ram than his computer... and it's analogue!
Back to top
View user's profile Send private message
poly_poly-man
Advocate
Advocate


Joined: 06 Dec 2006
Posts: 2477
Location: RIT, NY, US

PostPosted: Tue Apr 28, 2009 9:27 pm    Post subject: Reply with quote

might be ld - not sure - all I know is emerges take lots of ram.

I have 2gb ram, 512mb swap.
_________________
iVBORw0KGgoAAAANSUhEUgAAA

avatar: new version of logo - see topic 838248. Potentially still a WiP.
Back to top
View user's profile Send private message
cokehabit
Advocate
Advocate


Joined: 23 Apr 2004
Posts: 3302

PostPosted: Tue Apr 28, 2009 9:27 pm    Post subject: Reply with quote

eccerr0r wrote:
Compiling C++ programs tends to eat a lot of RAM.

I was trying to compile CenterICQ (CenterIM) on my DECstation 3100 (NetBSD). It has 24MB RAM at 16.6MHz, and compiling it would chew through all of swap (since it is a classic Un*x machine it has 48MB swap). Of course, it then ended up at the OOM killer.

Since I really didn't care what that machine was doing, I ended up letting it have 100MB more swap on another disk and let it go...

It took 3 days of nonstop swapping to finally complete building CenterICQ with just the ICQ personality enabled.

Then again it takes about 5 hours to compile a new NetBSD kernel.
you should do the pi test on it that is somewhere on a thread here
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Off the Wall All times are GMT
Goto page Previous  1, 2, 3, 4  Next
Page 3 of 4

 
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