Apple & GCC

Egh, I've gotten a bunch of emails about while I'm so rabid regarding Apple and compilers. Since I have no burning desire to actually fix stuff on this site (uh, like the comments) at the moment so that they aren't so ugly, below is an explanation of why I am so rabid about Apple and compilers.

Plus, it saves me having to email it to 15 people. It's a little long, but fairly easy to read... but after reading it you should have a fairly good understanding of why I'm so annoyed. If I'm wrong on anything, please let me know.

To begin simply...

The compiler is what turns human readable programming languages (c, c++, objective-c, java, etc) into code that the computer can understand... how optimized that code is for the processor architecture and how wisely it makes use of the resources of the machine drastically affect performance- with OSX only more so... with something like the itanium, it's make-or-break.

To give you an idea, Linux users have already had to go through this years ago... they use GCC (an open source compiler) and Linux was feeling the burn compared to windows. Over time it has become heavily optimized for x86 (more-so than any other platform), to the point where it really is a decent compiler for that platform (though they're still improving it).

That said, it's ~30% slower than Intel's commercial compiler for run-time code. In other words, take an x86 app, run it through GCC and then Intel's compiler and the program using Intel's program will often be about 30% faster as it uses the architecture better.

GCC for PowerPC is pretty brain dead at the moment, but Apple has to use it as it's the only thing out there that understands objective-c (cocoa). It goes something like this:

  1. Apple announces PowerPC. IBM has an AIX compiler, but it's pricey. Around the same time, Apple announced an initiative with symantec to create mrC, a heavily optimized PowerPC compiler. This is a big deal, as Apple is going from CISC to RISC.
  2. PowerPC launch time comes around, and Apple is way behind with their compiler... it's fast as _hell_, kicking ass and taking names against anything else out there (prolly still) but doesn't quite work correctly and really can't be shipped. Enter metroworks, with a native powerpc compiler who really saves Apple's ass. In spades. Can't be stressed enough.

    From this point on, Metroworks (or powerplant) becomes the de-facto IDE for the mac.
  3. Around this time, MrC dies as does the whole Apple/Symantec partnership. A lot of Apple partnership were doing that in these days... ;) Metro's powerplant wasn't the best, but it was reasonably good, although many companies (Apple, Adobe, etc) would use IBM's AIX compiler for a lot of things as they needed the speed boost.
  4. Enter OSX, and openstep being shoe-horned into OSX. Openstep has _always_ primarily been a CISC operating system, going from moto chips, but by the time Apple picked them up they'd primarily been on x86 for 3-4 years or so (from memory). Large parts of everything are in obj-c, and the only thing that really understands obj-c at this point is GCC as Apple is really the only large user of it (or medium sized, or possibly small).
  5. GCC is remarkably brain dead when it comes to PowerPC, as well not a lot of open source people use PPC, and _especially_ not many of the uber-elite people I wish I was half as smart as. How brain-dead?

    Um, well, pretend for the sake of this that a 1GHz PPC is as fast as 1GHz pentium, both running identical versions of Linux and both using GCC. The 1GHz PPC will actually have the speed of a 700MHz PPC. IE, GCC compiled code for x86 is roughly 30-32% faster. On x86, the same code using intel's compiler is often ~30+% faster. Hence, you take a 30%, or the PPC has to be inherently 30% faster than the same x86 hardware for stuff to feel/run the same using linux.

    Apple was able to improve compile times (how long it takes your code to be optimized and turned into stuff the comp can understand) by a factor of 2-3 within one release.

    In other words, if GCC was up-to-par with x86 GCC, and you could magically recompile your OS, things would pretty much run code ~30+% faster. With a heavily optimized best-of-breed compiler that really took advantage of the PPC, Apple could probably get 40-70% improvement. I don't know about you, but it pisses me off a little to be running hardware that could be _that_ much faster. Hence, the rabidness.

  6. The current state is a little muddied, as no one has any real incentive to optimize GCC for PPC except Apple, and IBM to a much smaller extent as AIX is used for much of their higher-end PPC stuff while they push Linux hard they mostly push it on x86 offerings.

Apple sort of has their hands full, as they have to do 2 things:

  1. Since they're the only ones using obj-c, they're pretty much responsible for the entire side of it. Maintaining it, making sure it works correctly from release to release, improving the language, etc. This also affects (ii), as a compiler really has to evaluate 2 parts- what it thinks you're wanting to do and how to best do it on the system you're targeting. Hence, Apple is the only one really telling the compiler how to interpret cocoa stuff.
  2. They're pretty much responsible for getting PPC GCC more optimized as there aren't cheap linux boxes out there running PPC, in which case lots more people would be. This includes (i), plus generating better runtime code and also compiled code performance.

There have been rumblings that Apple has hired some of the old mrC team, so we could be in for some real improvements... but whether or not they put the resources behind it to make it shine is unknown, and it'll be a little out.

Of course the compiler problem has been compounded by Apple shipping so many different configurations- do you optimize for the machine to have an L3 cache? Or a 1meg cache? Or 2meg? Dual or single processor?

Intel has learned that lesson, it's one of the big reasons for pushing hyper-threading. If/when Intel starts pushing dually's on the average desktop, or goes to quads, or even multi-core CPU's there are going to be a ton of apps that will use it better due to increased threading to optimize for hyperthreading. Apple seems to decide when to release generations of dual boxes willy-nilly.

Hell, I know I won't believe Apple won't be possibly transitioning to x86 until they optimize the hell out of mach for RISC & not CISC...

yummy alcohol posted button Posted by drunkenbatman
    July 07, 2003, at 07:24 PM


Comments (0)




Post a comment



Anonymous comments are allowed, but please enter something for a name.

And do endeavor to appear sane.









Remember personal info?