DaemonForums  

Go Back   DaemonForums > Miscellaneous > Off-Topic

Off-Topic Everything else.

View Poll Results: Do you use a swap partition?
Yes 23 100.00%
No 0 0%
Voters: 23. You may not vote on this poll

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 9th July 2008
JMJ_coder JMJ_coder is offline
VPN Cryptographer
 
Join Date: May 2008
Posts: 464
Thanked 8 Times in 8 Posts
Default Do you still use swap?

Hello,

In the days of increasing RAM in computers - where 2GB is standard and 4GB or even 8GB is not unheard of - how many of you still use a swap partition. I think my first swap partition that I created back for Red Hat 9 was only about 1GB - back then they recommended double your amount of RAM for the swap. Today, some swaps would need to be 16GB or more to accommodate that recommendation. I believe that swap was used as a supplement for less RAM, but that help may no longer be needed.

So, how many of you still use a swap partition?
__________________
And the WORD was made flesh, and dwelt among us. (John 1:14)
Reply With Quote
  #2   (View Single Post)  
Old 9th July 2008
BSDfan666 BSDfan666 is offline
Real Name: N/A, this is the interweb.
Helpful companion
 
Join Date: Apr 2008
Location: Ontario, Canada
Posts: 2,223
Thanked 193 Times in 184 Posts
Default

Contrary to popular believe, a swap partition is still an integral role of paging in the x86 architecture, pages are relocated to "secondary storage" when not in use.

You should always create a swap file or partition, even if you don't think it's important.. it really is.
Reply With Quote
  #3   (View Single Post)  
Old 9th July 2008
DrJ DrJ is offline
ISO Quartermaster
 
Join Date: Apr 2008
Location: Gold Country, CA
Posts: 506
Thanked 39 Times in 39 Posts
Default

I still do -- 4GB with 3GB RAM -- simply because disk space is so cheap. Its size really is set to accommodate the memory requirements of the largest program you can run. I don't run anything that requires 7GB of RAM, but I could. And freeing 4GB out of the 200GB or so of disk that I have installed is not worth it.
Reply With Quote
  #4   (View Single Post)  
Old 9th July 2008
BSDfan666 BSDfan666 is offline
Real Name: N/A, this is the interweb.
Helpful companion
 
Join Date: Apr 2008
Location: Ontario, Canada
Posts: 2,223
Thanked 193 Times in 184 Posts
Default

@OP, Let's expand on this concept... each process has access to it's own "virtual" address space, 4GB on a 32bit architecture.

When a program "allocates" memory, i.e: malloc(3), it's actually requesting that "x" amount of memory be mapped into it's address space. (Because, most of it is empty space, i.e: unmapped..).

Now, allocated memory doesn't always need to stay in RAM, The kernel is free to "relocate" it into the swap space on your hard drive.

If the program attempts to access the memory that was swapped, a "page fault" occurs, causing the kernel to halt the process, and reload the data back into RAM.

The benefits of this are clear...
Reply With Quote
  #5   (View Single Post)  
Old 9th July 2008
ocicat ocicat is offline
Administrator
 
Join Date: Apr 2008
Posts: 2,831
Thanked 190 Times in 160 Posts
Default

Configuring swap space is insurance, but ultimately it depends on the system & how it is used. Being familiar with standard performance metrics observable with tools like top(1) is imperative -- especially in situations where space which would/should be configured as swap is scrimped upon.

The old adage of configuring 2x the amount of RAM has to be tempered with usage & what resources are available. Like DrJ, I am more liberal with configuring swap on systems where disk space is not an issue. However, on smaller systems were extremely limited storage is available (firewalls...), I reduce swap significantly.

Paraphrasing BSDfan666, the lack of any configured swap space can really hurt if it isn't available. Thus, I like the insurance of configured swap space on servers which are exposed to the wiles of the Internet. Yet for desktop systems, I can be more experimental because I'm more in control of what loads they are subjected.

Ultimately, the decision is yours, & if you can justify your decisions & live with the consequences if your decisions are wrong, go for it.
Reply With Quote
  #6   (View Single Post)  
Old 9th July 2008
J65nko J65nko is offline
Administrator
 
Join Date: May 2008
Location: Budel - the Netherlands
Posts: 3,116
Thanked 182 Times in 149 Posts
Default

Code:
$ swapctl -l
Device      512-blocks     Used    Avail Capacity  Priority
swap_device     128000        0   128000     0%    0
Should I vote I use it nor not?
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump
Reply With Quote
  #7   (View Single Post)  
Old 9th July 2008
BSDfan666 BSDfan666 is offline
Real Name: N/A, this is the interweb.
Helpful companion
 
Join Date: Apr 2008
Location: Ontario, Canada
Posts: 2,223
Thanked 193 Times in 184 Posts
Default

@J65nko, wise guy..
Reply With Quote
  #8   (View Single Post)  
Old 9th July 2008
vermaden's Avatar
vermaden vermaden is offline
Administrator
 
Join Date: Apr 2008
Location: pl_PL.lodz
Posts: 1,051
Thanked 118 Times in 93 Posts
Default

I always add SWAP space and I always mount /tmp there.

My choices on my boxes has been like that:
256MB RAM laptop: 512MB SWAP + 128MB for /tmp
1GB RAM workstation: 2GB RAM SWAP + 256MB for /tmp
2GB RAM workstation: 2GB RAM SWAP + 512MB for /tmp
__________________
religions, worst damnation of mankind
"If 386BSD had been available when I started on Linux, Linux would probably never had happened." Linus Torvalds

Linux is not UNIX! Face it! It is not an insult. It is fact: GNU is a recursive acronym for “GNU's Not UNIX”.
vermaden's: links resources deviantart spreadbsd
Reply With Quote
  #9   (View Single Post)  
Old 9th July 2008
ninjatux's Avatar
ninjatux ninjatux is offline
Real Name: Baqir Majlisi
Spam Deminer
 
Join Date: May 2008
Location: Antarctica
Posts: 293
Thanked 15 Times in 15 Posts
Default

I still go by the 2xRAM recommendation.
__________________
"UNIX is basically a simple operating system, but you have to be a genius to understand the simplicity."
MacBook Pro (Darwin 9), iMac (Darwin 9), iPod Touch (Darwin 9), Dell Optiplex GX620 (FreeBSD 7.1-STABLE)
Reply With Quote
Old 9th July 2008
J65nko J65nko is offline
Administrator
 
Join Date: May 2008
Location: Budel - the Netherlands
Posts: 3,116
Thanked 182 Times in 149 Posts
Default

About the 2xRAM size this is what the OpenBSD FAQ has to say (http://www.openbsd.org/faq/faq4.html#Partitioning)
Quote:
The 'b' partition of your root drive automatically becomes your system swap partition. Many people follow an old rule of thumb that your swap partition should be twice the size of your main system RAM. This rule is nonsense. On a modern system, that's a LOT of swap, most people prefer that their systems never swap. You don't want your system to ever run out of RAM+swap, but you usually would rather have enough RAM in the system so it doesn't need to swap. If you are using a flash device for disk, you probably want no swap partition at all. Use what is appropriate for your needs. If you guess wrong, you can add another swap partition in /etc/fstab or swap to a file later.
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump
Reply With Quote
Old 9th July 2008
TerryP's Avatar
TerryP TerryP is offline
Arp Constable
 
Join Date: May 2008
Location: USofA
Posts: 1,547
Thanked 112 Times in 104 Posts
Default

The way I look at it, if my computer does not have enough virtual memory to complete the tasks I need of it, I can't use my computer to do what I need/want it to do, hence I've screwed myself by design.



All of my systems have swap space and /tmp allocated based on usage and hardware parameters.


I typically will use as much swap space as I ever intend to have RAM installed. And /tmp big enough to accomdate the largest unpacking jobs I expect to run, typically 0.1~1500mb


For example, my desktop has 2GB of RAM and 4GB of swap, it's maximum capacity is 4gb and disk space is huge. It rarely has extreme loads but sometimes does, hence lots of swap just in case of WW III !


My laptop has 512MB of RAM and 1GB of Swap which is the most I ever expect to have installed, although she tops out at 2GB of RAM.

I'm prone to doing a lot of things in short order on computers, to the point that I usually call it "omni tasking".


My laptop used to have 512MB of Swap and I've seen top come to close suggesting that my swap space is approaching exhaustion (~10s of mb left). I have not had that happen more then once or twice but by George, doubling my swap space is a small price for paranoia on an 80gb disk!

I never trust memory usage reported by any program, top included but I do consider it a guideline.



The PC pressed into service as a file server has about 300MB of swap and 384MB RAM -8MB for the gfx card.


Disk space was initially small (8GB), I have no reason to buy extra PC100, and it sits idle most of the time.


SSH, NFS, and MySQL currently running 'round the clock with provisions for Samba and printing software to be added later. She doesn't have much need for swapping, so the swap space was kept quite minimal.


normally if RAM is small (e.g. <1GB) or disk space cheap (e.g. > 80GB) I will usually opt for more swap then I need to worry about because I *can*.


In this case, extreme swap would've been more dentimental then memory problems.
__________________
My Journal

Thou shalt check the array bounds of all strings (indeed, all arrays), for surely where thou typest ``foo'' someone someday shall type ``supercalifragilisticexpialidocious''.
Reply With Quote
Old 9th July 2008
lvlamb's Avatar
lvlamb lvlamb is offline
Real Name: Louis V. Lambrecht
Spam Deminer
 
Join Date: May 2008
Location: .be
Posts: 221
Thanked 25 Times in 24 Posts
Default

Quote:
Originally Posted by J65nko View Post
Code:
$ swapctl -l
Device      512-blocks     Used    Avail Capacity  Priority
swap_device     128000        0   128000     0%    0
Should I vote I use it nor not?

A swap partition will not eat any bread.
Further, a swap partition will not eat a primary entry either, and all Linuces or *BSDs can mount an extended Linux swap partition.
Hard drive space is penty, so I have a swap parition in the "extended" area, usage 0% , available to whoever is concerned
Well, I am the kind of guy holding his pants with both a bet and suspenders.

La,la: 32MB of swap once was plenty.
If you intend to debug a memory dump, you might use a swap=memory. If this happens me twice, I reinstall the OS from fresh.
Some laptops suspend to swap (or elsewhere).
Some OSes really make a bad usage of the RAM (and swap).
----
edit
the FAQ reads: ... twice the size of your main system RAM. This rule is nonsense.
__________________
da more I know I know I know nuttin'

Last edited by lvlamb; 9th July 2008 at 11:52 PM.
Reply With Quote
Old 10th July 2008
robbak's Avatar
robbak robbak is offline
Real Name: Robert Backhaus
VPN Cryptographer
 
Join Date: May 2008
Location: North Queensland, Australia
Posts: 366
Thanked 40 Times in 39 Posts
Default

OK, how about "one third of your total memory should be physical"?

Like everyone says, I always configure a generous swap, but it is rarely used.
Code:
Device          1K-blocks     Used    Avail Capacity
/dev/ad4s1b       3897344      68K     3.7G     0%
4GB amd64 box. That said, it runs squid, and I am more than happy to have it caching in RAM to it's heart's content.
__________________
The only dumb question is a question not asked.
The only dumb answer is an answer not given.
Reply With Quote
Old 10th July 2008
DrJ DrJ is offline
ISO Quartermaster
 
Join Date: Apr 2008
Location: Gold Country, CA
Posts: 506
Thanked 39 Times in 39 Posts
Default

That does bring up a question. Sometimes I have some things in swap, even though there is plenty of free memory. Like now:

Quote:
CPU states: 11.4% user, 0.0% nice, 6.9% system, 0.4% interrupt, 81.2% idle
Mem: 616M Active, 818M Inact, 243M Wired, 58M Cache, 112M Buf, 1264M Free
Swap: 4096M Total, 290M Used, 3805M Free, 7% Inuse
Why does it even use swap? Even if I close everything (other than X, gnome and the daemons) it stays there.
Reply With Quote
Old 10th July 2008
robbak's Avatar
robbak robbak is offline
Real Name: Robert Backhaus
VPN Cryptographer
 
Join Date: May 2008
Location: North Queensland, Australia
Posts: 366
Thanked 40 Times in 39 Posts
Default

Firstly , free physical memory is good for a system. It means that it does not have to free up memory if a process suddenly requires a large amount of memory. (The other side of the tale, "Free memory is wasted memory," is also true: the two maxims must be balanced.)

That swap may simply be pages of memory that are cached in swap - The data is both in swap and in physical RAM, so the space is there if the system needs it, and the data is there if the process needs it. Best of both worlds.

And what is the point of paging back in idle data? The process is not likely to require it any time soon, or it wouldn't have stayed paged out for the last hour. I'll only have to swap it back out again, and I'm lazy. Despite having a brain the size of a planet....
__________________
The only dumb question is a question not asked.
The only dumb answer is an answer not given.
Reply With Quote
Old 10th July 2008
DrJ DrJ is offline
ISO Quartermaster
 
Join Date: Apr 2008
Location: Gold Country, CA
Posts: 506
Thanked 39 Times in 39 Posts
Default

Quote:
Originally Posted by robbak View Post
That swap may simply be pages of memory that are cached in swap - The data is both in swap and in physical RAM, so the space is there if the system needs it, and the data is there if the process needs it. Best of both worlds.
That's true, and I had not considered that. But then why it is not released when the underlying processes are terminated? There is no need for those pages any longer, and one would think that the page file would release its contents.

This is on FreeBSD 6.3, FWIW.
Reply With Quote
Old 10th July 2008
robbak's Avatar
robbak robbak is offline
Real Name: Robert Backhaus
VPN Cryptographer
 
Join Date: May 2008
Location: North Queensland, Australia
Posts: 366
Thanked 40 Times in 39 Posts
Default

What makes you think that X, gnome, the daemons or even the kernel is not the culprit? Indeed, it is these, long-running, largely-unused processes that often have bits of them swapped out, and, as the memory is idle, give no reason for the system to page them back in.
__________________
The only dumb question is a question not asked.
The only dumb answer is an answer not given.
Reply With Quote
Old 10th July 2008
DrJ DrJ is offline
ISO Quartermaster
 
Join Date: Apr 2008
Location: Gold Country, CA
Posts: 506
Thanked 39 Times in 39 Posts
Default

They are too small. Usually these take about 100MB of memory; the swap used is larger. Something else has to be in there.
Reply With Quote
Old 10th July 2008
BSDfan666 BSDfan666 is offline
Real Name: N/A, this is the interweb.
Helpful companion
 
Join Date: Apr 2008
Location: Ontario, Canada
Posts: 2,223
Thanked 193 Times in 184 Posts
Default

"Too small", congratulations.. you found a memory leak.

If memory is allocated, and the program loses track of it.. (i.e: poorly managing pointers, it remains until the program is terminated..)

Because nothing is using it, makes sense that the kernel would swap it off to secondary storage.
Reply With Quote
Old 10th July 2008
DrJ DrJ is offline
ISO Quartermaster
 
Join Date: Apr 2008
Location: Gold Country, CA
Posts: 506
Thanked 39 Times in 39 Posts
Default

Quote:
Originally Posted by BSDfan666 View Post
.. you found a memory leak.

If memory is allocated, and the program loses track of it.. (i.e: poorly managing pointers, it remains until the program is terminated..)
I'll see if it is anything with X or Gnome, but the swap has always occupied so far. The gecko-based browsers all seem to have memory leaks, this this one is something else.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to swap partitions Help revzalot OpenBSD Installation and Upgrading 2 1st September 2009 07:44 AM
swap partition lumiwa FreeBSD General 6 11th September 2008 03:57 PM


All times are GMT. The time now is 03:31 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick