Tuning MacOSX

cmr164cmr164 Registered Users Posts: 1,542 Major grins
edited February 8, 2005 in Digital Darkroom
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 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)



Charles Richmond IT & Security Consultant
Operating System Design, Drivers, Software
Villa Del Rio II, Talamban, Pit-os, Cebu, Ph

Comments

  • dkappdkapp Registered Users Posts: 985 Major grins
    edited February 7, 2005
    Nice hint, I'll have to give it a try. Once question tho. What does this do?

    Thanks,
    Dave
  • fishfish Registered Users Posts: 2,950 Major grins
    edited February 7, 2005
    dkapp wrote:
    Nice hint, I'll have to give it a try. Once question tho. What does this do?

    Thanks,
    Dave
    This is what it does.

    Nice work, Charlie.
    "Consulting the rules of composition before taking a photograph, is like consulting the laws of gravity before going for a walk." - Edward Weston
    "The Edge... there is no honest way to explain it because the only people who really know where it is are the ones who have gone over."-Hunter S.Thompson
  • JohnRJohnR Registered Users Posts: 732 Major grins
    edited February 7, 2005
    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?
  • dkappdkapp Registered Users Posts: 985 Major grins
    edited February 7, 2005
    JohnR wrote:
    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
  • DavidTODavidTO Registered Users, Retired Mod Posts: 19,160 Major grins
    edited February 7, 2005
    fish wrote:
    This is what it does.

    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!
    Moderator Emeritus
    Dgrin FAQ | Me | Workshops
  • AndyAndy Registered Users Posts: 50,016 Major grins
    edited February 7, 2005
    alright you geeks
    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?
  • cmr164cmr164 Registered Users Posts: 1,542 Major grins
    edited February 7, 2005
    DavidTO wrote:
    This is one of the posts on macosxhints.com in reference to Charles' patch.
    But I have more kernel devel experience than he has thumb.gif 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.
    Charles Richmond IT & Security Consultant
    Operating System Design, Drivers, Software
    Villa Del Rio II, Talamban, Pit-os, Cebu, Ph
  • cmr164cmr164 Registered Users Posts: 1,542 Major grins
    edited February 7, 2005
    andy wrote:
    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.
    Charles Richmond IT & Security Consultant
    Operating System Design, Drivers, Software
    Villa Del Rio II, Talamban, Pit-os, Cebu, Ph
  • AndyAndy Registered Users Posts: 50,016 Major grins
    edited February 7, 2005
    cmr164 wrote:
    But I have more kernel devel experience than he has thumb.gif 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?
  • cmr164cmr164 Registered Users Posts: 1,542 Major grins
    edited February 7, 2005
    andy wrote:
    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.gif

    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.gif
    Charles Richmond IT & Security Consultant
    Operating System Design, Drivers, Software
    Villa Del Rio II, Talamban, Pit-os, Cebu, Ph
  • fishfish Registered Users Posts: 2,950 Major grins
    edited February 7, 2005
    cmr164 wrote:

    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.gif
    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.gif
    "Consulting the rules of composition before taking a photograph, is like consulting the laws of gravity before going for a walk." - Edward Weston
    "The Edge... there is no honest way to explain it because the only people who really know where it is are the ones who have gone over."-Hunter S.Thompson
  • JohnRJohnR Registered Users Posts: 732 Major grins
    edited February 7, 2005
    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?
  • dkappdkapp Registered Users Posts: 985 Major grins
    edited February 7, 2005
    JohnR wrote:
    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
  • cmr164cmr164 Registered Users Posts: 1,542 Major grins
    edited February 7, 2005
    cmr164 wrote:
    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 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
    Charles Richmond IT & Security Consultant
    Operating System Design, Drivers, Software
    Villa Del Rio II, Talamban, Pit-os, Cebu, Ph
  • ruttrutt Registered Users Posts: 6,511 Major grins
    edited February 8, 2005
    cmr164 wrote:
    But I have more kernel devel experience than he has thumb.gif 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 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?
    If not now, when?
  • cmr164cmr164 Registered Users Posts: 1,542 Major grins
    edited February 8, 2005
    rutt wrote:
    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 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.
    Charles Richmond IT & Security Consultant
    Operating System Design, Drivers, Software
    Villa Del Rio II, Talamban, Pit-os, Cebu, Ph
  • ruttrutt Registered Users Posts: 6,511 Major grins
    edited February 8, 2005
    cmr164 wrote:
    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?
    If not now, when?
  • cmr164cmr164 Registered Users Posts: 1,542 Major grins
    edited February 8, 2005
    rutt wrote:
    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.
    Charles Richmond IT & Security Consultant
    Operating System Design, Drivers, Software
    Villa Del Rio II, Talamban, Pit-os, Cebu, Ph
Sign In or Register to comment.