Hi all,
Lots of thanks to the following for clearing up the swap issue:
Steven Sakata "sakats@buzzeo.com"
Marc S. Gibian <gibian@stars1.hanscom.af.mil>
David Thorburn-Gundlach <david@bae.uga.edu>
Todd Boss <boss@netcom.com>
Daniel Dunn <dunn@sled.gsfc.nasa.gov>
Chris Marble <cmarble@orion.ac.hmc.edu>
<robin.landis@exim.gov>
"Brion Leary" <brion@dia.state.ma.us>
Jeff Wasilko <jeffw@smoe.org>
Srinivasa Rao Duddupudi <sduddupu@cvimail.cv.com>
Ju-Lien Lim <julienlim@rocketmail.com>
Aleksandar Milivojevic <alex@srce.hr>
Matthew Stier <Matthew.Stier@tddny.fujitsu.com>
Stephen Harris <sweh@mpn.com>
David Evans <DJEVANS@au.oracle.com>
Roland Grefer <btirg@ui.uis.doleta.gov>
SARDELLA Matteo <sardella@mains.fiat.it>
Matt Reynolds <reynolmd@aston.ac.uk>
Mariel Feder <mfeder@central.meralco.com.ph>
Jay Morgan <jmorgan@qualix.com>
All were very helpful. I can happily document that we have 65 megs of
swap space, and that is all we need at the moment.
Here are bits of the replies. It is lengthy but contains valuable and
interesting information. Original posting at tail end.
Thanks all!!!!
Andy Townsend
-- In Solaris 2.5.1, swap space is made up of both RAM and the disk swap space. The "swap -s" command is probably what you can use to find out your answers. It'll give you an idea as to how much swap you have and how much is being used. -- The REAL challange is the calculation of the amount of swap space needed for a given system. This boils down to first understanding what swap space is, and what it is not. Swap space simply is disk space mapped into the virtual memory address space of all executing software on your machine. The total amount of swap space needed is that necessary to hold the largest cumulative virtual memory address space the system needs at any point in its operation. Now, that is a very hard number to come up with. It is hard enough to figure out the virtual memory address space needs for a single application... near impossible, actually, and I am a developer of these beasts. Then, you have to figure out the largest combination of applications that will be run at the same time on the machine. I doubt you can come up with that list, either. If you could, then all you have to do is take the list of the largest combination of applications run at the same time, add up their maximum virtual memory address space needs, and the result is the maximum swap space you need for that system. Complicate this by the fact that most system administrators handle dozens of systems, and you see why no sane individual attempts to go at this problem the "right" way.Most people simplify the problem of deciding how much swap space to configure by coming up with simple rules of thumb. The most common of these is that one needs X times the physical RAM size of your machine, where X is frequently 3 or 4. This is generally based on the assumption that if you have more than X times the physical RAM in allocated virtual memory address space, your system will be running into so much paging activity that it will effectively grind to a halt.
Thus, even if you could allocate more virtual memory space, it would be to no effect since no real work is actually being accomplished on the machine at that point. This line of reasoning only works for applications with specific relationships between virtual memory address space usage and working set, or active virtual memory address space usage... the latter being that region in "constant" usage. It is a rash assumption for any arbitrary set of applications, but it does provide a rule of thumb that generally produces enough swap space for people to get their work done.
Ultimately, you only know you have enough swap space allocated when you have a system up and running and no one is running out of virtual memory. With disk space as inexpensive as it is, the safe thing to do is intentionally over estimate and then in 99% of all cases things work just fine. In those remaining 1% of cases, you configure additional swap space on a filesystem or add another disk (if you can't re-install) and everything is fine. -- First, the answer to your second question: yes, 65M -- or even 0M, in this case -- of swap "should" be enough. If you believe 'em, Sun reports that you only need a total of 48M of RAM+swap for a system, so systems with >48M RAM needn't have *any* swap. Now, I won't go that far, but here's some history that explains how swap space needs have changed:
- long ago, it was considered safest to load a program from disk by first copying it from disk to swap and then loading it from swap to RAM, because any corruption that might happen should then, theoretically, happen to the copy in swap and the original would be safe. - AFAIK, nobody had ever seen this happen in the history of the world :-) - with Solaris 2.x (and many other *NIX flavors, I'm sure), programs are loaded directly from disk, so half of your old swap requirement is unnecessary
Thus, you should be able to get by with swap = RAM instead of swap = 2*RAM.
Meanwhile, as mentioned above, Solaris is designed to run completely within 48M, so you should be able to get away with swap+RAM => 48M. Of course, I don't believe this too much -- I have personally seen simulation code run and eat up 1G RAM + 2G swap space and complain about needing more!
In your case, however, you're not running a lot on the machine, so it doesn't have to swap much; you need RAM for data structures, perhaps, but swap space won't help you there. You should be fine with whatever swap you have.
And, speaking of that first question...
My guess is that the blocks listed in `swap -l` are 512, since I'd be inclined to trust to number from the format table (unless your / is 125M and your /usr is 800M). I've never trusted that much, though.
The easy way I use to figure out swap space is to run top, it will report used swap + free swap (eg "152M swap, 376M free swap"), and the total is pretty close to swap + RAM (eg, a 32M machine with 512M swap (a partitioning default, I assure you!) -- near enough for government figures, anyway :-)
The biggest reason for me to have a big swap is because it gives me a big /tmp, so that I can use /tmp for *big* files as well as, in all probability, not run out of /tmp space (which = swap space which = problems) if the machine is up for a year and a day, cuz I'm a lousy garbage collector. -- Well, in Sunos 4.1.3 you should have 2-3 times your RAM in swap. But in Solaris, you really don't need as much. Solairis is much more efficient w/ its memory management, and you can get away w/ 1xRAM in swap. That of course doens't help you much in your situation, where you have 1/2 of your RAM in swap...but at least now you only hafve to find 60 meg instead of hundreds. -- Look for the swap space columns by Adrian Cockroft at this web site:
http://www.sun.com/sunworldonline/common/swol-backissues-columns.html#perf -- Not having swap is a problem if you're doing savecore on startup - you need the size of real memory plus enough to save startup messages in to support savecore (guess-timate real memory + 32Mb). If you don't have it you could get into an endless loop of panics - because when savecore crashes it causes a panic.
So if you save system crash core files you should increase swap, but if you don't and things are running okay - you seem to have enough memory to support what you're running, and you don't need to increase swap. -- Some good references to get more info on the topic: http://www.sun.com/sunworldonline/swol-12-1997/swol-12-insidesolaris.html http://www.sun.com/sunworldonline/swol-01-1998/swol-01-insidesolaris.html http://www.sun.com/sunworldonline/swol-10-1995/swol-10-perf.html http://www.sun.com/sunworldonline/swol-04-1996/swol-04-perf.html http://www.sun.com/sunworldonline/swol-05-1997/swol-05-perf.html -- When you looked at the "format" command, you saw the actual disk space used for swap. Swap -l showed the blocks of swap (in 1/2K blocks in most cases). Depending on how long the system has been up, the fact that you have 80kblocks available is pretty good. Ideally, one would want to have enough RAM that swap wouldn't be necessary. -- I'd highly recommend 2 books on performance tuning and sizing. One by Brian Wong (on server sizing) and the other by Adrian Cockroft (on tuning). -- You have got 65MB swap. You can graphically see the usage of the swap memory using the '/usr/openwin/bin/wsinfo' command. -- If you find in logs that your machine was sometimes out of memory during normal operations, add more swap.
If you are affraid that somebody will put lot of large files in /tmp and "eat" all available memory, there is an option for tmpfs to restrict total amount of memory available to tmpfs. I use following to limit size of /tmp to 256 megs on one of our public machines (it have 512 megs of RAM):
swap - /tmp tmpfs - yes nosuid,size=256m
"nosuid" option is documented as valid only for ufs, but it also works for tmpfs (at least on 2.5 and higher) in case that you are considered with security. -- swap -s can lie a little, since demand loaded pages (ie executables) can add space temporarily. I did a summary to the list on this about 6 months back, but after further emails with a couple of good listers it turns out that the "swap -s" output is really hiding a lot of deep dark secrets :-) -- These could be of great help for you.
SunWorldOnLine : Dec 1997 issue : http://www.sun.com/sunworldonline/swol-12-1997/swol-12-insidesolaris.html
SunWorldOnLine : Jan 1998 issue : http://www.sun.com/sunworldonline/swol-01-1998/swol-01-insidesolaris.html -- Original: Hi,
I apologize that this is "non-emergency" but I have been confused about something for several days now. I looked around for a more appropriate list but couldn't find one. If anyone can point me to one, please do; I don't have access to newsgroups.
I have searched the Sun managers archive to no avail. Many closely related items, but nothing head on.
I am trying to determine _exactly_ how many megs of total swap space I have, and whether or not it is enough for my system. I have inherited a Solaris 2.5.1 box with 128M of RAM. Here are what I believe to be all the relevant tables to make the determination:
Part Tag Flag Cylinders Size Blocks 0 root wm 0 - 336 250.12MB (337/0/0) 512240
1 swap wu 337 - 423 64.57MB (87/0/0) 132240
2 backup wm 0 - 2732 1.98GB (2733/0/0) 4154160 3 unassigned wm 0 0 (0/0/0) 0 4 unassigned wm 0 0 (0/0/0) 0 5 unassigned wm 0 0 (0/0/0) 0 6 unassigned wm 424 - 2732 1.67GB (2309/0/0) 3509680 7 unassigned wm 0 0 (0/0/0) 0
In the format table it states that the swap partition is only ~65 megs, which alarmed me as 65 megs is hardly 2-3 times our 128MB RAM. Still digging, I looked at:
eris# more vfstab #device device mount FS fsck mount mount #to mount to fsck point type pass at boot options # #/dev/dsk/c1d0s2 /dev/rdsk/c1d0s2 /usr ufs 1 yes - fd - /dev/fd fd - no - /proc - /proc proc - no - /dev/dsk/c0t0d0s1 - - swap - no - /dev/dsk/c0t0d0s0 /dev/rdsk/c0t0d0s0 / ufs 1 no - /dev/dsk/c0t0d0s6 /dev/rdsk/c0t0d0s6 /export ufs 2 yes - swap - /tmp tmpfs - yes -
So, the system is using the tmpfs fs type.
swap -l yields:
swapfile dev swaplo blocks free /dev/dsk/c0t0d0s1 32,1 16 132224 87552
I can't be sure what size blocks those are... 512 or 1024? The man pages discuss both.
swap -s yields:
total: 59256k bytes allocated + 49872k reserved = 109128k used, 50784k available
Is that telling me that there are 59 megs allocated, plus 50 reserved, for a grand total of 109 megs? Of which, 50 megs are available? If that is the case, then 109 megs is better than the original 65 megs of swap I had seen in the format table, but it still doesn't come close to the recommendation of 2-3 times your RAM. Does that recommendation still hold true? The server is primarily a web server with moderate traffic.
Additionally, I ran a vmstat 30 2 and received the following:
procs memory page disk faults cpu r b w swap free re mf pi po fr de sr f0 s0 s6 -- in sy cs us sy id 0 0 0 18008 9168 0 0 0 0 0 0 0 0 0 0 0 113 33 23 0 0 100 0 0 0 51024 9184 0 0 0 0 0 0 0 0 1 0 0 117 37 30 0 0 100
Which looks promising as it doesn't look like much paging is going on.
Do I have enough space? Can anyone tell me how many megs of swap I _do_ have, total, so that I might document it?
Please help. I know this isn't an emergency but my brain is falling out.
Thanks for your time,
Andy Townsend Division of ADP Management Employment and Training Administration US Department of Labor (202) 219-5146, x131 atownsend@doleta.gov
This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:12:32 CDT