Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the '10.4: Move swap files to another drive' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.4: Move swap files to another drive
Authored by: TigerKR on Feb 10, '06 06:26:44PM

Interesting, I'm not having any issues with my relocated swap in Tiger. I'm using the same process that we worked out for Panther.

Maybe its because my swap partition is on the same physical drive as my boot partition?

I have two internal 10k rpm u160 scsi drives:

-HD1, internal SCSI (via PCI card) bus1:
--partition1: swap (vm)
--partition2: MacOSX (boot)
-HD2, internal SCSI (via PCI card) bus2:
--partition1: scratch (for photoshop scratch and ~/Library/Caches)
--partition2: users (for /Users)
-HD3, external Firewire (via onboard port) bus3:
--partition1: av (for ~/Movies and ~/Music)

I'm using a DP1.25GHz G4 Tower running 10.4.4 w/all updates, and I haven't had any problems relocating my swap using the Panther method.



[ Reply to This | # ]
10.4: Move swap files to another drive
Authored by: TigerKR on Feb 10, '06 07:02:51PM

To maximize performance: you typically want your swap/vm to be on the fastest part of the HD, and you want your vm files to be unfragmented. You can accomplish this by partitioning your boot drive into two partitions, the first (the first partition is faster) for vm/swap, and the second for your boot disk.

You also typically want your scratch to be on the fastest part of the HD, and you want your scratch files to be unfragmented. Basically scratch is vm for specific applications (such as photoshop). You also want your scratch partition on a separate HD (and a separate bus if you can) from your vm and boot disk (your boot disk also contains the application). But it is advantageous to keep your scratch and your data storage on the same HD because an inner-drive copy is going to be faster than an inter-drive copy (once photoshop is done with a file - which is temporarily stored in scratch - it then will write the file to a more permanent file).

Of course, if you can have multiple HDs (and possibly have multiple busses) you might want to consider RAID0 (striping) for even more speed.



[ Reply to This | # ]
10.4: Move swap files to another drive
Authored by: TigerKR on Feb 10, '06 07:11:28PM

On the hardware side, more RAM should always be your first upgrade, so you can avoid VM swapping as much as possible. Faster spinning HDs (more Rpm) with more lanes for traffic (more MBps) are also a good upgrade (although they can get expensive) so that when you do swap, at least it won't take as long. Besides, with a faster HD, everything is faster, from boot-up, to app launch, to file reads, to file writes.

Another way to keep your system Snappy™ is to keep your files and filesystem de-fragmented. Tiger has some limited de-fragmentation built in.



[ Reply to This | # ]
10.4: Move swap files to another drive
Authored by: DavidRavenMoon on Feb 14, '06 07:59:45AM

Just keep in mind that the performance you might gain from having a VM partition on the same physical drive as your OS, as far as not having fragmented files, is (probably) lost by the drive head having to travel farther.

This is true of partitions in general. You keep files organized and unfragmented (maybe), but you make the drive do more work.

You also have to make sure the VM partition is large enough. Five times the installed RAM is ideal... double is the bare minimum.

And that brings me to the last point... load up your Mac with enough RAM and you won't have to worry about swap files. I have 1.5 GB on this G5 (my work machine), and right now, with a bunch of apps open, including Photoshop CS2, Illustrator CS2, Quark 6.5, Acrobat 7 Pro, Classic, Safari, Entourage, etc. I have one 64 MB swap file. Putting that file on another partition, or drive for that matter, won't speed up a thing!

:)

---
G4/Digital Audio/1GHz, 1 GB, Mac OS X 10.4.4
www.david-schwab.com
www.imanicoppola.net



[ Reply to This | # ]
10.4: Move swap files to another drive
Authored by: TigerKR on Feb 14, '06 06:07:05PM

Forgive me, but I'm not following you. How would reading a non-continuous stream of data be just as fast as reading a continuous stream?

In a continuous stream of data, the read-head does not need to jump around the platter. Every time the read-head jumps around the platter, your performance is decremented. If you have a really large file that is in many different chunks in different places of your drive's platter, then that theoretical decrement of performance increases in magnitude. If you have several large files that you are currently using, that are in many different chunks in different places of your drive's platter, then your read-head is doing a virtual square dance, and you have to wait for it to finish the Do-si-do. That's not even considering the overhead of having a file-system b-tree that's so bogged with extents branches that it looks like willow tree.

I'm not saying that any of this matters for most users - it doesn't matter for most users. But this hint isn't for most users.



[ Reply to This | # ]
10.4: Move swap files to another drive
Authored by: TigerKR on Feb 14, '06 06:36:44PM

I'm not sure where you have come up with the idea of having 5x RAM as a size for your VM partition. I have always read that 2x RAM is ideal.

"Choosing the right amount of swap space can be a bit of an art. A good rule of thumb is that your swap space should be two or three times as much as the available physical memory (RAM). You should also have at least 64 MB of swap, so if you have less than 32 MB of RAM in your computer then set the swap amount to 64 MB." - FreeBSD install guide

"Your swap partitions should total at least twice the size of the amount of RAM memory you have installed in your machine." - vmunix install guide

"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. Use what is appropriate for your needs... your swap space should be [at least] slightly larger than the amount of main memory you are likely to ever have in the system." - OpenBSD FAQ

I used to have 1.5 GB of RAM and I used to use swap a bunch. I have 3 GB of dedicated swap space, but I've never hit the ceiling on that. Since I've upgraded to 2 GB of RAM, I almost never go beyond the initial 64 MB swapfile. But occasionally I do. And when I do, I'm usually on a deadline, and I need things to move as quickly as possible.

I think that you may be confusing swap space with scratch space. Applications like photoshop use scratch files (basically VM for a specific application). And yes, for photoshop, it is recommended that you allocate at least 5x - of your largest file size that you'd ever work with in photoshop. So if you work with 5 200 MB photoshop files concurrently (200MB is a really big file - for comparison a 7.1 megapixel RAW file is about 10 MB), you should have 5 GB of dedicated scratch space. But you should not typically have your swap and scratch in the same place. In fact, no only do you want them on different partitions, but if you can, you want them to be on different drives, or better yet, different busses.



[ Reply to This | # ]
10.4: Move swap files to another drive
Authored by: syzygies on Feb 11, '06 10:12:06AM

10.3 methods didn't work for me in 10.4. If one looks at the previous 'Hint' on this subject, the 10.3 methods didn't work in 10.4 for other people, either. That hint described moving the swap code to the end of /etc/rc, after the drives had a chance to mount, but also after a slew of other processes started without the benefit of virtual memory. I didn't like the idea of extensively editing /etc/rc, it's much cleaner to insert one line into /etc/rc, that does nothing if the helper file /etc/rc.swapfile isn't present.

What baffles me is why my new approach only works in 10.4, not also in 10.3. The snippets of code I experimented with and put together all come from ideas batted around since 10.0.



[ Reply to This | # ]
10.4: Move swap files to another drive
Authored by: TigerKR on Feb 11, '06 08:55:44PM
uhh... just looked in my /etc/ directory, and I found some interesting "rc" files:
$ dir | grep rc
-rw-r--r--    1 root  wheel    187B Mar 20 18:39:12 2005 bashrc
-rw-r--r--    1 root  wheel    189B Mar 20 19:04:08 2005 csh.cshrc
-rw-r--r--    1 root  wheel    587B Aug 22 09:55:31 2005 efax.rc
-rw-r--r--    1 root  wheel    106B Mar 26 22:54:41 2005 mail.rc
-r--r--r--    1 root  wheel     11B Mar 20 19:03:29 2005 nanorc
-r--r--r--    1 root  wheel      7K Jul  4 23:46:54 2005 rc
-r--r--r--    1 root  wheel      7K Jun 10 00:43:49 2004 rc.10_3_4
-r--r--r--    1 root  wheel      8K Jan  1 12:08:47 2004 rc.bak
-rw-r--r--    1 root  wheel      1K Mar 23 20:49:08 2005 rc.common
-r--r--r--    1 root  wheel     10K Jan  1 21:29:19 2004 rc.*censored*ed
-rw-r--r--    1 root  wheel      4K Mar 23 20:49:08 2005 rc.netboot
-r--r--r--    1 root  wheel      7K Dec 29 01:45:11 2003 rc.orig
-r--r--r--    1 root  wheel      7K Jul  4 23:40:59 2005 rc.saved
-rw-r--r--    1 root  wheel    183B Mar 23 20:49:08 2005 rc.shutdown
-rw-r--r--    1 root  wheel    606B Jul  4 23:42:37 2005 rc.swap
-rw-r--r--    1 root  wheel      1K Mar 18 02:58:14 2004 rc.swapfile
That one that is censored starts with an f and rhymes with duck. Anyone else have this kind of variety in their etc folder?

[ Reply to This | # ]