9.01.2007

Trimming the Fat Off Universal Binaries

Here are 2 good ways to speed up some apps. First I describe "lipo", then I talk about "ditto".

Universal binaries (or .dmg installers that can run in old and new Macs), contain unneeded code. If you have an Intel Macbook, you won't need PPC (powerpc) code, and vice versa. So you can trim down the code with these two commands.

lipo (aptly named) is a utility that manipulates universal binaries in Mac OS X. A lot of (almost all) programs these days ship, or download as “Universal”, meaning they have binary code that both the powerpc and the intel chips can understand. But since you probably don’t care about one of the two, you want to use lipo to “thin” down your binaries. For example if you wanted to thin the “Stickies” application to only contain intel (i386) code:
cd /Applications
lipo Stickies.app/Contents/MacOS/Stickies -thin i386 -output Stickies.app/Contents/MacOS/Stickies.i386
cd Stickies.app/Contents/MacOS/
rm Stickies
mv Stickies.i386 Stickies


ditto. An even better command is "ditto" which is really a backup tool. ditto takes only one step. Note: backup your App before you try this, or don't delete your original App until you're absolutely sure your thinner App is working fine!

ditto --rsrc --arch i386 /Applications/Foo.app /Application/Foo-386.app


Explanations:

--arch i386
means to keep only the Intel code
Foo-386.app is the new Intel-only App. Try opening this and if it runs, then it means you've successfully thinned down your App. Keep your old universal app for a few weeks or days and observe the thinned down app. If you're happy, you may delete the old fat app.

I used ditto to thin down Firefox. From 47.9 Mb, FF is now just 27 Mb. Leaner means faster and less disk space!



Readings:
http://osxdaily.com/2006/11/22/ten-os-x-command-line-utilities-you-might-not-know-about/
http://www.tuaw.com/2006/07/20/tuaw-tip-how-to-tell-if-an-application-is-a-universal-binary/
http://www.macosxhints.com/article.php?story=20050810112422666

No comments:

Post a Comment

Thank you for commenting! Your comment will be submitted for review and approval. Please return soon!