Logo Rob Buckley – Freelance Journalist and Editor

Turbocharge your Mac

Turbocharge your Mac

Suffer sluggish performance from your Mac no longer. This detailed feature will show you how to make your Mac run faster, how to streamline your OS for top performance and maximum disk space, and reveals some Unix trickery to make your system really fly.

Page 1 | Page 2 | Page 3 | Page 4 | All 4 Pages

Remember the first time you saw a Mac running OS X? Wasn’t it beautiful? Wasn’t it amazing to see a computer that didn’t make you want to head for the toilet with a nauseous feeling in your stomach?

Most people would be more than content to have computer that didn’t make them think they’d been wearing beer-goggles when they’d bought it. But what few Mac owners realise is that the 10 they picked up at the local electronics boutique pretty much has the equivalent of a doctorate in astrophysics, an in-depth knowledge of the works of Shakespeare and a fascination with pre-Columbian art. There are many layers to a Mac.

Beneath all the eye-candy, there is a whole lot going on in OS X. At its heart is something called Unix, which is a computer expert’s system of choice. Worked on over decades, Unix is very powerful and has thousands of tools and applications written for it. Even more importantly, it’s very customisable and the power user can usually just edit a text file or add a few items to a command to make Unix do exactly what he or she wants it to do. The trouble is Unix is also very complicated. For one thing, by default, there’s not really any graphical way of using it – you just have to memorise whole series of arcane commands, just as if you were learning a foreign language. And instead of there being a logical, consistent way of doing things, almost every element of Unix has its own way of doing things that’s very much dependent on the original programmers that designed it 30 years ago.

So, when Apple decided to build OS X using a Unix core, Steve Jobs and his associates knew that the computer for “the rest of us” couldn’t really expose “the rest of us” to the full-on Unix experience without “the rest of us” running away in horror. They hid it, simply letting the eye-candy do all the heavy lifting for us. Unix is still there, it’s just we don’t have to worry about it.

There’s always a trade off, however, between simplicity and power in the computer world. Sure, the OS X interface with its collection of utilities and system preferences can configure parts of the Unix core. But it can’t configure all of them, since there would be literally hundreds of different choices to pick from and no novice user would be able to use a Mac. For power users, though, this can be frustrating since they often want to be able to change the way a Mac runs in a way that Steve and co didn’t think was necessary, suitable for the general Mac-using population or which they didn’t think of at all. Fortunately, there are still ways to get to the Unix underneath to make your Mac go faster, remove bits you don’t want and run in the way you want it to. And that’s what we’re going to show you in this article.

There are, essentially, four big bottlenecks in your Mac’s performance: its processor, its hard drive, its memory and its interface. The processor (or processors in some Macs) makes all the calculations necessary for programs to do their jobs, so the faster the processor, the faster the programs go. There’s not much you can do to make your processor go faster: while you can upgrade some Macs with better processors, most of the time you have to stick with what you’ve got. But there is some room for performance improvements here.

The processor doesn’t do everything at once. In conjunction with a part of OS X called the “kernel”, it schedules tasks, determining how many times per second it will perform calculations for each program. So, there are two ways of cranking more performance out of your processor: run fewer programs or give a higher priority to the programs you care about.

Running fewer programs may seem an obvious way of speeding things to most people; after all, having full-screen movies playing at the same time as you’re running Virtual PC, Photoshop and Word generally brings most Macs to their knees and once you’ve tried something like that once, you rarely try it again. But there are a whole load of programs you may not realise are programs at all since they don’t show up in the Dock. These include the various “daemons” that manage things like Printer Sharing, Personal Web Sharing, Windows Sharing and so on. Some of these sit in memory the whole time, while others wait until a “master daemon” (on earlier versions of OS X, it was the “inetd” daemon but Jaguar and Panther use the “xinetd” daemon) spots a request for your printer, files, et al and launches the appropriate daemon. Even when these daemons aren’t actually doing anything, the processor still donates some of its time to them so they can work out what to do with their lives.

Similarly, the menu bar icons for things like AirPort signal strength, sound, iChat, Bluetooth, and battery charge all take up a little bit of extra processing power.

And that’s just on a standard OS X installation. Once you start installing other programs, the daemons start to proliferate, particularly if you’ve installed System Preference panels, do things at specific times, or intercede for specific actions: back-up software Retrospect has a daemon to tell it when to launch; Norton Utilities and Norton Anti-Virus have a massed army of daemons to scan for disks being launched, files being used, files being thrown out, et al; and Stuffit Deluxe has daemons for it its Archive Via Rename tool, its “magic menu” and its Archive Assistant.

So if your Mac starts to feel a bit sluggish compared to when you first had it, you might want to start looking around to see what programs you typically have running and whether you need them. One of the best ways to do that is to use the Activity Monitor application in your Utilities folder, and set it to display “My processes”. If there are many more processes than you thought there would be, look into ways of disabling them, by uninstalling software you don’t need, or removing programs from your Startup Items (in the Accounts system preference pane) or from your StartupItems folder (in both your own Library folder and the main Library folder).

The other way to speed up your programs is to reschedule them. There are some programs that you leave running in the background that you might not want to get much share of the processor time and there are others that you might want to give more to. To change the priorities, you need to “re-nice” these programs.

“Re-nicing” is a reference to the Unix command “renice”, which allows you to change the priorities of your programs. Unix grew up in a time when all computers were multi-user systems and you had to pay for the time you used on a machine, so being able to dictate which programs got priority was quite important. It’s less important on a single-user Mac but the Unix legacy is still there for power-users.

Most Mac users don’t want to have to learn Unix though – probably rightly so – and there’s a small cottage industry growing up in developer circles of creating applications that provide simple, graphical way of performing Unix commands. Re-nicing – a single Unix command – already has at least four programs to manage it from a graphical interface, including BeNicer, Speed Freak, Prio and Renicer, and that’s pretty much a norm for some of the more useful Unix commands. Run any of these, pick which applications you want to give greater priority to and you should notice a speed improvement.

Surprisingly though, despite all those Intel adverts, it’s not the processor that’s the biggest bottleneck on most Macs. Memory and hard drive can exert more of an influence, and fortunately they’re far more easy to affect on a continuing basis than the processor.

If you bought a Mac and haven’t added any memory, get some more added now. It’s quite easy to do yourself if you follow the instructions, but there are plenty of Mac shops willing to add memory for a price. The base memory on most Macs is still lamentably low and the bare minimum should be at least 256MB, but 512MB to 1GB of RAM are far more palatable.

If you don’t have enough memory, OS X will start trying to juggle your applications around using some sophisticated compression techniques and eventually “virtual memory”. Virtual memory is a euphemism for great big files, known as a swap files, on your hard drive into which OS X will dump memory content when it doesn’t have enough space to keep it in memory. When it needs it back, it’ll read the data from the swap files into main memory again. The thing is, not only is your hard drive a lot slower than your memory, you’re also using your hard drive for storing files; if you’re constantly reading and writing files and constantly using the swap files, your Mac’s going to get very slow indeed as the hard drive reader jumps around reading and writing information from all the different locations on your hard drive.

So what can you do, other than add more memory, to solve this problem? If you have a lot (at least 1GB of memory, but preferably 2GB), you could think about turning off the swap files altogether, but since your Mac will freeze completely the very second you run out of free memory, that’s not a good idea for most people. (For advanced users only: It is possible by editing the file /etc/rc to remove the commands that activate the swap files). The other option is to move the swap file. If you’ve partitioned your hard drive (that is, split it up using Disk Utility so that it appears in the Finder as two or more separate disks), you could reconfigure the swap file to appear on a partition other than the one you have OS X installed upon. This will avoid any performance drops caused by disk fragmentation. However, the performance gains from this are slight since the swap file is still on the same hard drive and so the hard drive reader will still have to jump between the different areas to read and write to the swap file.

A better option is to move the swap file to a different hard drive altogether, if you have one, since your Mac will be able to read and write to both drives simultaneously. It’s possible to do this using standard Unix commands and a text editor, but a number of applications exist to do the hard work for you, such as Xupport, Swap Cop and Swap Relocator.

You’ll get similar performance gains for similar reasons if you move your Users directory to a separate drive. But unlike moving your swap file, no one has written a utility to automate the process, so you’ll need to use the Terminal.

Terminal is a direct conduit to Unix and is quite frightening. Do not be frightened however. With a few rules to guide you, the Terminal is not that scary. And it has lots of advantages once you get used to it. For one thing, it’s free, unlike many “tweaking” applications, and is available on every OS X Mac, including those without an Internet connection. You can use it to log into other Macs that have Remote Login enabled in their Sharing system preference pane and you’ll be able to use the exact same commands on those Macs. It can be a lot quicker than working your way through menus, tabs and other graphical delights. And if no one’s written an application yet to tweak your Mac the way you want it, you can almost always use Terminal to achieve the result you want.

So rule number one of Terminal: all commands are case sensitive, so typing “cd” is not the same as typing “CD” – one will change your directory, the other won’t. So be sure to follow any instructions exactly when dealing with Terminal.

Rule number two: if in doubt, check the manual first. In typical Unix fashion, typing something obvious like “help” (or “HELP”) won’t work. To get help, you need to type “man” which is short for manual, logically enough. And you can only get help about specific commands, not about using Unix in general, so don’t bother typing “man” by itself. If you’re not sure what command you want, type “apropos” and a subject (for example, “apropos network”) to get a list of possible commands.

Rule number three: always follow the instructions exactly. “rm” – short for “remove” – is the Unix delete command and will delete lists of files. So if you type “rm cow1 cow2”, the files “cow1” and “cow2” will disappear immediately (not into the Trash – there is no Trash in Unix, just oblivion) from your current directory (type “pwd” to work out what that is). If there’s an error, it will keep going. Now, you can also use things called “wildcards” to save on the typing: typing “rm cow*” will delete any file beginning with “cow”, including “cow1” and “cow2”. So what happens if you accidentally slip in a space and type “rm cow *”? You guessed it: first, Unix will try to delete the file “cow”. Even if you don’t have one, it will carry on with the next item in the list, which is “*”. Since every filename consists of one or more characters, Unix will delete every file in your current directory (except for files beginning with a full stop). So make sure that you’ve typed the command exactly (if you’re not sure, go back to rule two).

With that in mind, you can safely use Terminal to move your Users directory to another disk. Type the following, substituting your username for “username” and the name of the other disk for “OtherDisk” :

“sudo ditto -rsrcFork /Users /Volumes/OtherDisk/Users”

“sudo niutil -createprop / /users/username home /Volumes/OtherDisk/Users/username”

The “sudo” command lets you run any other command as if you are the super-user; “ditto” duplicates a file; and “niutil” accesses your Mac’s NetInfo database to make changes. These two commands have copied your whole Users folder over to the new drive and then instructed the Mac to modify the NetInfo database to look in the new location for your home directory. (You’ll need to repeat the second command, similarly modified for each user, if there’s more than one of you using the Mac)

Don't go on until you're sure the new user directories are working OK. You should log out/back in to check this. Once you’re sure everything is okay, type the following to remove the old Users directory and put an alias to the new one in its place:

“sudo rm -dr /Users”

“sudo ln -s /Volumes/OtherDisk/Users /Users”

The last and most overlooked aspect of performance boosting is interface customisation. Yes, you might be able to shave a couple of seconds off your Mac’s swap file performance using Terminal hacks and third-party apps. But if it the user interface hides things from you or isn’t arranged in the way you like to work, those couple of seconds will be nothing compared to the time lost each day due to bad usability. It’s why Mac users always turn out to be more productive than Windows users in surveys of working practices: it’s just easier to get things done on a Mac.

The interface is actually a lot more customisable than you might think, from the few options in the Appearance preference pane. Apple’s programmers have often taken executive decisions to hide certain things from us, because the average user won’t need them and would probably be confused by them. One of the default settings of the Finder, for instance, is to hide a whole slew of Unix directories and any files beginning with a full stop. It’s probably a good thing it does, because those directories would confuse the hell out of most people and files beginning with a full stop in Unix typically are quite important or store configuration data: indeed, OS X installs a directory called .DS_Store into any directory the Finder has looked at to maintain preferences on how the directory should be displayed in the Finder – the average user would probably delete any .DS_Store directory they found and then be mystified as to why the folder no longer displays the correct way.

But frequently the programmers leave the features in and just remove the parts of the interface that would have let activate the feature.

Now, virtually every OS X application has a preference file that it stores in the Preferences folders of your Library folders. Their filenames end in “.plist”, short for property list, so they’re easy to spot. Inside the files are lists of settings and their values. Often, you activate hidden features by altering the preference file. For example, if you alter Safari’s plist to include a string property called “IncludeDebugMenu” with value 1, the next time Safari opens, it will have a Debug menu that lets you do all sorts of useful things. To do this, you can use a text editor, such as TextEdit or BBEdit; if you have the Apple developer tools installed, you can double click on the plist file and it will open in an application called Property List Editor especially designed for editing plist files; and Terminal addicts can use the command “defaults write com.apple.Safari IncludeDebugMenu 1”. Tools such as OnyX, Cocktail, Tinkertool and Xupport that provide these features are simply changing the property list files for particular applications through a nice, user-friendly interface.

Plist files, though, are OS X specific. Most Unix preference files have their own formats, from the relatively easy “/etc/ftpusers” file used by the FTP Access daemon that Apple appropriated from standard Unix, to the utterly baffling preference files of Sendmail (so baffling, it actually has two preference files: one you write yourself, and the one Sendmail actually uses which it generates from your file using a separate program).

Programs such as Broadband Optimizer and Cocktail are able to use the Terminal command “sysctl”, which accesses the deeper Unix system preferences (type “sysctl –a” to see them all). They can use this capability to tailor OS X’s networking capabilities to a far greater degree than the standard Network system preference pane can, potentially speeding up OS X’s networking by a considerable amount. But unless you understand have to configure your TCP packets’ memory space, it’s best to stick with the graphical interface than try to use sysctl yourself.

Given the vastness of Unix, not just in terms of what’s installed by default in OS X, but also the tools in the Apple developer toolkit and the thousands of pieces of free software you can download from the Internet, it would be impossible to list all the ways you can tweak and tinker with your Mac to get it running exactly the way you want it to. OS X doesn’t stand still either. There were no hidden hacks to change the way Exposé worked until it arrived on the scene with OS X 10.3, aka Panther, which also updated a considerable portion of the Unix core.

OS X 10.4 aka Tiger should be no different, with Unix enhancements promised aplenty. Since Apple is taking a more leisurely pace getting Tiger out the door than it did with 10.2 or 10.3, there should be more features and more consideration of what aspects of the Mac a user should be able to configure. There will also probably be more utilities to replace the command-line tools power-users have had to fall back on, just as Activity Monitor replaced “top” and “df” and Network Utility replaced “ifconfig”, “ping”, “traceroute” and “whois”. But unless Apple loses the plot and destroys the simplicity of the Mac interface with the multitude of incomprehensible options that plague the Windows and Linux interfaces, there will always be a place for customisation utilities and Terminal hacks in OS X.

Page 1 | Page 2 | Page 3 | Page 4 | All 4 Pages

Interested in commissioning a similar article? Please contact me to discuss details. Alternatively, return to the main gallery or search for another article: