• We should now be fully online following an overnight outage. Apologies for any inconvenience, we do not expect there to be any further issues.

moving swap files in OS X.3

dchakrab

Senior member
Apr 25, 2001
493
0
0
I followed the instructions here.

The problem is, my swap files appears to have not moved. This is the break condition of the mod...basically, if it has a problem loading the swap file into the "moved" location, it goes back and loads it where it was before.

So what's the problem? Any ideas? I'm using a laptop with two partitions, one main, one swap, both on the local hard drive. The objective is to put the swap file on the partition labeled "swap" to improve performance and help with fragmentation issues.

Thanks,

Dave.
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Are you getting any errors?

Moving the swap to a different partition will probably not help performance at all.
 

dchakrab

Senior member
Apr 25, 2001
493
0
0
Actually, many reviews including one with benchmarks shows immediate results after moving a swap file. Why do you think it won't help at all?

No errors...read the script for the mod. It basically reverts to the original swap file location if there's a problem, so there wouldn't be any errors, theoretically...it would just revert, like mine did.

Any ideas?

-Dave.
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: dchakrab
Actually, many reviews including one with benchmarks shows immediate results after moving a swap file. Why do you think it won't help at all?

Unless it swaps to an unformatted partition it is doing the exact same thing the original setup is doing. It still uses the same hard drive (putting it on another drive is another matter, and I doubt the benefits are truly worth it), it still writes the same data, it still reads the same data. Fragmentation issues are the only reason I can see this being even remotely worthwhile.

By results, you mean something over 20% right?

No errors...read the script for the mod. It basically reverts to the original swap file location if there's a problem, so there wouldn't be any errors, theoretically...it would just revert, like mine did.

Any ideas?

-Dave.

If it's a well written script (I haven't looked, the page is LONG), it should error and move on to reverting to the original swapfile.

It's probably on the page that I'm reading, but how did you determine your swapfile is exactly the same as before?
 

dchakrab

Senior member
Apr 25, 2001
493
0
0
Benchmarks here..

They show a major improvement for "real world" use using seperate drives, predicts 15-20% increases using the same drive but seperate partitions. Immediate visible increases in performance are also quoted by others using the single-drive setup, and the person who wrote that script mentions somewhere that he's using a notebook with a single drive for it, and still lists it as a must-do hack for installing OS-X.

Based on that, I'm willing to give it a shot to see if it makes a difference.

I'm using ActivityMonitor...if i open a million things I can make my swap file size larger than my intended swap volume, which shouldn't be possible if it worked. I can also open my swap volume, and finder shows almost all of it is empty, which wouldn't be the case if i had a resident swap file.

-Dave.
 

dchakrab

Senior member
Apr 25, 2001
493
0
0
Using two drives, I believe the advantages would be major, because the read-arm on the second drive would remain over the swap file data almost continuously, resulting in lower seek times (assuming you didn't use the second drive for anything that was always in use)...since swap files are accessed often, this would result in a performance boost.

Using a single drive, I'm not sure where the advantages would come from, other than in disk searching. It is simpler for an operating system to locate a swap file on its own partition, so this would reduce the OS having to search for the swap file among other accessed-files in memory-intensive operations, or in multitasking situations. This search overhead reduction is probably the main benefit of switching to a seperate swap partition, though defragmentation would also be a potential advantage, since I'm pretty sure swap files are a major source of fragmented files.

The same logic applies to photoshop's scratch disks...if you have a scratch disk set to the same volume as your main boot disk, performance suffers. Switching this to a different volume, even one on the same physical drive, results in a performance increase, and is actually recommended by Adobe (i think the latest versions of Photoshop even prompt you to switch your scratch disk volume on install, if possible).

-Dave.
 

dchakrab

Senior member
Apr 25, 2001
493
0
0
Ok, here are the scripts I've been using...

From rc, here's the part dealing with virtual memory:

echo "Starting virtual memory"

swapdir=/private/var/vm

#swap mod

if [ -f /etc/rc.swapfile ]; then . /etc/rc.swapfile; fi # inserted locally


if [ "${netboot}" = "1" ]; then
sh /etc/rc.netboot setup_vm ${swapdir}
fi

# Make sure the swapfile exists
if [ ! -d ${swapdir} ]; then
echo "Creating default swap directory"
mount -uw /
mkdir -p -m 755 ${swapdir}
chown root:wheel ${swapdir}
else
rm -rf ${swapdir}/swap*
fi

Then here's the rc.swapfile code it should be inserting:


##
# After the line in the system startup script /etc/rc
#
# swapdir=/private/var/vm
#
# insert the line
#
# if [ -f /etc/rc.swapfile ]; then . /etc/rc.swapfile; fi # inserted
# locally
##

swapvolume=swap

if [ ! -d /Volumes/${swapvolume}/.Trashes ]; then
swapcount=1
ConsoleMessage "Waiting for ${swapvolume} to mount"
while [ "$swapcount" -le 30 ]; do
sleep 1
if [ -d /Volumes/${swapvolume}/.Trashes ]; then
ConsoleMessage "${swapvolume} mounted after $swapcount seconds"
break
fi
swapcount=`expr $swapcount + 1`
done
fi

if [ -d /Volumes/${swapvolume}/.Trashes ]; then
ConsoleMessage "Using ${swapvolume} for swapfile"
if [ -f ${swapdir}/swapfile0 ]; then
rm -rf ${swapdir}/swap*
fi
swapdir=/Volumes/${swapvolume}/.vm
else
ConsoleMessage "Unable to use ${swapvolume} for swapfile"
fi

This results in a console log that tells me how long it took to mount my swap volume, and claims my intended swap volume loaded fine. However, loading a bunch of applications results in ActivityMonitor showing a larger swap file size than my swap partition, and Finder shows my partition as being virtually empty, so I'm assuming the script is reporting a false-positive somehow.

Ideas?

-D.

 

Navid

Diamond Member
Jul 26, 2004
5,053
0
0
Originally posted by: dchakrab
Benchmarks here..

They show a major improvement for "real world" use using seperate drives, predicts 15-20% increases using the same drive but seperate partitions.

Correct me if I'm wrong. I read the first few paragraphs and the chart description. The improved performance is for placing the swap file on a separate physical drive.

"The first column lists the benchmark results for a swapfile located in the standard location /private/var/vm while the second lists the results from the swap partiton located to it?s own contiguous space on the secondary drive".
 

dchakrab

Senior member
Apr 25, 2001
493
0
0
Directly after that is an estimate for 15-20% improvement using the same physical drive but on seperate partitions. This estimate is verified by other powerbook users, including the writer of the tutorial i used, who lists it as a must-do hack after installing OS X.

-D.

 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
They show a major improvement for "real world" use using seperate drives, predicts 15-20% increases using the same drive but seperate partitions

Those benchmarks also round to the nearest second which is ludicrous and skews the results to the point of making them invalid IMO. And on top of that the 15-20% prediction in a single drive setup is just that, a prediction based upon nothing. Pure speculation with no facts to back it up.

Want an even easiser hack to speed launch times? Launch the app once and close it before benchmarking the startup time, that'll make those numbers really low.