DirectNET

Data Center Management Solutions including UPS Systems, Data Center Cooling, KVM over IP & IP Power Strips, Server Racks and Server Rack accessories; KVM Switches and KVM Extenders; Rackmount Monitors and Rackmount Keyboards.


NAVIGATION
Home
Store
INSIDE MAC
Television Shows
Broadcast Shows
Daily News Shows
Special Shows
EVENTS
DAILY TIPS
Design
Mac OS X
Mac OS X UNIX
COMMUNITY
Forums
Surveys
NEWS
Current
Press
Archive
FEATURES
Editorial
Dr. Mac
Reviews
Reader Reports
RESOURCES
FAQ
Documentation
Learning Center
MAN pages
Glossary
Tutorials
Tips
Links

OUR PARTNERS

Reader Reports 

Swap Performance on OS X

    I had a problem with OS X; performance would diminish
(in a huge way) as I loaded more programs, even if the programs
were inactive.

    I eventually worked it out - it was due to the swapfiles
created by the dynamic pager (the virtual memory part of Darwin).
OS X creates 80MB files under /var/vm. When you first start up
the machine, it will create swapfile0, and as you load more programs
it will create swapfile1, et cetera.

    My OS X volume's free space was heavily fragmented, which
meant that these subsequently created swapfiles were causing very
slow paging (basically, the process of writing inactive programs'
memory to, and reading running programs' memory from disk).

    Now, I thought of three solutions to this problem:

1) Run a utility like Norton SpeedDisk from MacOS 8/9 to defragment
   the OS X disk. I only have Norton Utilities 4.0, which is not
   compatible with OS X HFS volumes, so this wasn't an option

2) Copy all files from the OS X volume, reformat, and copy them back.
   back. Easy, but time consuming, and the problem may come back.

   Nikolaus Heger cautions against this solution:
        it doesn't work. i had to reinstall the system after this.
        as i found out, the OS X finder cannot - i repeat _can not_ - 
        restore an OS X system disk. the reason is that it simply
        screws up symlinks and hidden files by not copying them. 

3) Use a different disk to store the swapfiles.

    The third option is the one I used. I created a new volume
under Mac OS 8 called "swap", booted the machine into OS X to find
out its pathname (in my case, /dev/disk0s7), and modified the startup
script, /etc/rc, to mount and use it for the swapfiles. The changed
lines are near the end of that file:

   % sudo vi /etc/rc
   ...
   ConsoleMessage "Starting virtual memory"
       
   #Nigel - 28/3/2001
   #swapdir=/private/var/vm    # OS X Final Release
   #swapdir=/swap        # OS X Public Beta
   swapdir=/Volumes/swap
   
   # Make sure the swapfile exists
   if [ ! -d $ ]; then
       ConsoleMessage "Creating default swap directory"
       mount -uw /
       mkdir -p -m 755 $
       chown root:wheel $
   else
       rm -rf $/swap*
   fi
   
   #Nigel - 28/3/2001
   mount_hfs /dev/disk0s9 $
   
   dynamic_pager -H 40000000 -L 160000000 -S 80000000 -F $/swapfile
   ...


Notes:

1) Performance will be best if the partition containing your newly
   created volume is the first volume on your fastest disk

2) The partition's Unix device (/dev/disk..) depends on the software
   the disk was formatted under. OS 8's "Drive Setup" creates several
   driver partitions (7) before the first usable volume. Other disk
   formatters seem to create less driver partitions.(Under FWB Hard
   Disk Toolkit, for example, the first volume is /dev/disk0s5)

3) Most other Unixes (e.g. Linux) use a dedicated partition to hold
   their kernel swap "files" (actually a disk volume formatted with a
   special filesystem type). OS X's approach is better in one way,
   in that if the system runs out of virtual memory space, the user
   can easily delete some files so that there is 80MB available for
   the next swapfile

4) The size of your swap volume depends on your workload, and the
   amount of RAM your Mac contains. It is best to run OS X for a
   while and see how many swapfiles it places in /private/var/vm.

   For the sort of programs I run (programming, not much RealPC or
   PhotoShop), when I had 128MB RAM, OS X never created more than
   3 swapfiles, and when I upgraded to 384MB RAM, OS X usually only
   creates 1 swapfile. In my case, the total memory footprint has
   always been less than 440MB (384MB + 80000000).

   If you are too lazy to work all this out, about 500MB free space
   in your swap volume should be plenty.


-- 
| Nigel Pearson, nigel@ind.tansu.com.au | "Reality is that which,   |
|   Telstra NW-D, Sydney, Australia.    |  when you stop believing  |
| Office: 9206 3468    Fax:  9212 6329  |  in it, doesn't go away." |
| Mobile: 0408 664435  Home: 9792 6998  | Philip K. Dick - 'Valis.' |

Copyright © 2000-2009 Inside Mac Media, Inc. All rights reserved.
Apple assumes no responsibility with regard to the selection, performance, or use of the products or services. All understandings, agreements, or warranties, if any, take place directly between the vendors and prospective users.
Apple, the Apple logo, Mac, PowerMac G4, PowerMac G5, Xserve, Xserve RAID, PowerBook, iBook, Airport, AirPort Extreme, iMac, eMac, iLife, iMovie, iCal, iPhoto, iTunes, QuickTime, FireWire, iPod, iSight, AppleWorks, Macintosh, Jaguar, Panther, Mac OS, Mac OS X and Mac OS X Server are trademarks of Apple Computer, Inc.