View Full Version : Tuning MacOSX
cmr164
Feb-07-2005, 03:25 PM
Memory usage on the Mac can improve markedly with the following. I first wrote this up for the Apple forums, had it picked up by macosxhints (http://www.macosxhints.com/) Here is the tuning:
In a terminal or xterm window: sudo vi /etc/rc
go to the line that starts: # System tuning and change to 512 multiplier into a 2048 multplier.
# System tuning
#ORIG-CMR
#sysctl -w kern.maxvnodes=$(echo $(sysctl -n hw.physmem) '33554432 / 512 * 1024 +p'|dc)
#NEW-CMR
sysctl -w kern.maxvnodes=$(echo $(sysctl -n hw.physmem) '33554432 / 2048 * 1024 +p'|dc)
dkapp
Feb-07-2005, 03:33 PM
Nice hint, I'll have to give it a try. Once question tho. What does this do?
Thanks,
Dave
fish
Feb-07-2005, 03:37 PM
Nice hint, I'll have to give it a try. Once question tho. What does this do?
Thanks,
Dave
This is what it does. (http://www.macosxhints.com/article.php?story=20030712130414339&query=tuning)
Nice work, Charlie.
JohnR
Feb-07-2005, 03:57 PM
Tried reading through some of those posts over at MacOSXhints but didn't make it. The Apple Discussion Boards was a bad link.
In laymens terms what does this do?
dkapp
Feb-07-2005, 03:59 PM
Tried reading through some of those posts over at MacOSXhints but didn't make it. The Apple Discussion Boards was a bad link.
In laymens terms what does this do?
From what I understand. It caches more to your RAM than to the HD, helping speed things up a bit.
Dave
DavidTO
Feb-07-2005, 04:29 PM
This is what it does. (http://www.macosxhints.com/article.php?story=20030712130414339&query=tuning)
Nice work, Charlie.
This is one of the posts on macosxhints.com in reference to Charles' patch.
I found the following discussion in the archives of the Darwin development email list:
http://lists.apple.com/archives/darwin-development/2002/Aug/msg00441.html
The writer is/was apparently one of Apple's kernel developers and so presumably knows what he/she is talking about.
Summary:
Increasing the value of maxvnodes will increase the number of files that get cached in RAM. This will make subsequent access to those files much faster.
But the downside is that more of your RAM will be used up for this disk caching and thus you will have less RAM available for normal application use. Therefore you should only consider increasing maxvnodes if you always have lots of "free memory" as shown in 'top' or "Activity Monitor", and if you hardly ever get pageouts (also shown in 'top' or "Activity Monitor").
The default value is a compromise that is expected to result in the best overall performance for people using OS X as a "desktop OS" - i.e. for running GUI applications, etc.
If you are running OS X primarily for use as a server, or if your usage differs significantly from the norm, you might find it useful to tune the maxvnodes number. But only if you have a lot more RAM than is needed for the apps you run!
Andy
Feb-07-2005, 04:43 PM
and so, if one is using say, a powermac g5 2.5ghz proc, 3.5 gigs or ram, 500 gigs of hd, and one's primary use of the machine is for photoshop and internet, then would you recommend doing this modification?
cmr164
Feb-07-2005, 04:48 PM
This is one of the posts on macosxhints.com in reference to Charles' patch. But I have more kernel devel experience (http://www.iisc.com/cmr/) than he has :thumb What happens is that the MacOSX memory usage has lots of available ram but does not properly release vnodes so the system starts doing dramatic paging when there is still lots of ram. This is really exasperated by a really bad idea in the weekly scripts which touch every file for the man pages and the locate database every sunday, sucking up every possible vnode. Later I will show how to move that to the monthly but one thing at a time.
cmr164
Feb-07-2005, 04:50 PM
and so, if one is using say, a powermac g5 2.5ghz proc, 3.5 gigs or ram, 500 gigs of hd, and one's primary use of the machine is for photoshop and internet, then would you recommend doing this modification?
Yes.
Andy
Feb-07-2005, 04:50 PM
But I have more kernel devel experience (http://www.iisc.com/cmr/) than he has :thumb What happens is that the MacOSX memory usage has lots of available ram bu does not properly release vnodes so the system starts doing dramatic paging when the is still lots of ram. This is really exasperated by a really bad idea in the weekly scripts which touch every file for the man pages and the locate database every sunday, sucking up every possible vnode. Later I will show how to move that to the monthly but one thing at a time.
charles, i seriously doubt if the average joe has any clue as to what you are talking about. put it in layman's terms, so that the rest of us can understand, will you?
cmr164
Feb-07-2005, 05:01 PM
charles, i seriously doubt if the average joe has any clue as to what you are talking about. put it in layman's terms, so that the rest of us can understand, will you? I'll try :deal
Because of the default Apple tuning, when the system want to open a new file (and everything is file in UNIX) it has no available resource. The vnodes are used up but everything needs a vnode. So the system pages out and acts just like it ran out of memory even though plenty is available.
Think of it this way... You have 25 magnum of champagne (ram) and 100 guests (files) but only 30 glasses (vnodes) so when someone needs a drink you take someone elses glass (vnode) and toss their champagne out to get some for the new drinker. Because every one want to drink the host (system) spends all the time rotating glasses and dumping/filling them.
I actually think I did a good gob with this :D Who will buy me a drink? :1drink
fish
Feb-07-2005, 05:15 PM
Think of it this way... You have 25 magnum of champagne (ram) and 100 guests (files) but only 30 glasses (vnodes) so when someone needs a drink you take someone elses glass (vnode) and toss their champagne out to get some for the new drinker. Because every one want to drink the host (system) spends all the time rotating glasses and dumping/filling them.
I actually think I did a good gob with this :D Who will buy me a drink? :1drink
Can't you just buy more glasses? I like the analogy...and now I'm thirsty. Oh look at the time! It's beer:15. :1drink
JohnR
Feb-07-2005, 05:40 PM
Interesting. Though it's above my head!
I'm assuming that my Dual 2ghz G5, 2.5GB ram, 320GB Hard drive would also need this.
If, for some reason, this turns out to make my mac run slower, is there a reversal?
dkapp
Feb-07-2005, 05:47 PM
Interesting. Though it's above my head!
I'm assuming that my Dual 2ghz G5, 2.5GB ram, 320GB Hard drive would also need this.
If, for some reason, this turns out to make my mac run slower, is there a reversal?
Change it back to 512 :D
Dave
cmr164
Feb-07-2005, 06:17 PM
Memory usage on the Mac can improve markedly with the following. I first wrote this up for the Apple forums, had it picked up by macosxhints (http://www.macosxhints.com/) Here is the tuning:
In a terminal or xterm window: sudo vi /etc/rc
go to the line that starts: # System tuning and change to 512 multiplier into a 2048 multplier.
# System tuning
#ORIG-CMR
#sysctl -w kern.maxvnodes=$(echo $(sysctl -n hw.physmem) '33554432 / 512 * 1024 +p'|dc)
#NEW-CMR
sysctl -w kern.maxvnodes=$(echo $(sysctl -n hw.physmem) '33554432 / 2048 * 1024 +p'|dc)
There is one more detail... The /etc/rc will not run until you reboot so if you want this to take effect right away, cut/paste the following into a terminal or xterm window and press return
sudo sysctl -w kern.maxvnodes=$(echo $(sysctl -n hw.physmem) '33554432 / 2048 * 1024 +p'|dc)
Enter the admin password when prompted
rutt
Feb-08-2005, 04:14 AM
But I have more kernel devel experience (http://www.iisc.com/cmr/) than he has :thumb What happens is that the MacOSX memory usage has lots of available ram but does not properly release vnodes so the system starts doing dramatic paging when there is still lots of ram. This is really exasperated by a really bad idea in the weekly scripts which touch every file for the man pages and the locate database every sunday, sucking up every possible vnode. Later I will show how to move that to the monthly but one thing at a time.
So does you tuning hint actually help in the face of the weekly complete file search? Once that is done, won't all the vnodes be used up even if there are 4 times as many?
BTW, I haven't been using your hint (just out of laziness) but this second part is interesting. Did you read this post (http://www.dgrin.com/showthread.php?t=5485) of mine? I am forming a new theory. PS gets into the state where it can't save files if it is open over a Sunday night. That's when these scripts run, right? Does that make any sense to you?
How to change the frequency, time when the man pages and locate database are updated?
cmr164
Feb-08-2005, 04:53 AM
So does you tuning hint actually help in the face of the weekly complete file search? Once that is done, won't all the vnodes be used up even if there are 4 times as many?
BTW, I haven't been using your hint (just out of laziness) but this second part is interesting. Did you read this post (http://www.dgrin.com/showthread.php?t=5485) of mine? I am forming a new theory. PS gets into the state where it can't save files if it is open over a Sunday night. That's when these scripts run, right? Does that make any sense to you?
How to change the frequency, time when the man pages and locate database are updated? It does help even in the face of the Sunday runs but a once a week reboot on Monday morning would add to the help or just block it from running I show below.
Here is the section of the /etc/weekly script that is the problem:
#if [ -x /usr/libexec/locate.updatedb ]; then
# echo ""
# echo "Rebuilding locate database:"
# locdb=/var/db/locate.database
# touch "${locdb}"; chown nobody "${locdb}"; chmod 644 "${locdb}"
# echo /usr/libexec/locate.updatedb | nice -5 su -fm nobody 2>&1 | sed -e '/Permission denied/d'
# chmod 444 "${locdb}"
#fi
#if [ -x /usr/libexec/makewhatis.local ]; then
# echo ""
# echo "Rebuilding whatis database:"
# if [ -d /usr/X11R6/man ]; then
# #MANPATH=${MANPATH:-/usr/share/man:/usr/X11R6/man:/usr/local/man}
# else
# MANPATH=${MANPATH:-/usr/share/man:/usr/local/man}
# fi
#
# makewhatis.local "${MANPATH}"
#fi
You will notice that I have completely commented out these. There isn't anything Mac users do that need a complete update of the locate database and whatis database. The normal Mac user probably NEVER uses either. If this was a once a year script it would be enough.
rutt
Feb-08-2005, 05:04 AM
It does help even in the face of the Sunday runs ...
Can you explain why? Perhaps too technical for this forum?
Here is the script that is the problem:
What file is this script in?
cmr164
Feb-08-2005, 05:35 AM
Can you explain why? Perhaps too technical for this forum?
Here is the script that is the problem:
What file is this script in?
I will go back and edit the previous post also...
/etc/weekly
It is a link to /etc/periodic/weekly/500.weekly , but ignore that.
vBulletin v3.5.2, Copyright ©2000-2008, Jelsoft Enterprises Ltd.