Mac OS X: beautiful but...

The Mac OS X (Server) operating system can't be described easily. Apple:

"Mac OS X Server starts with Darwin, the same open source foundation used in Mac OS X, Apple's operating system for desktop and mobile computers. Darwin is built around the Mach 3.0 microkernel, which provides features critical to server operations, such as fine-grained multi-threading, symmetric multiprocessing (SMP), protected memory, a unified buffer cache (UBC), 64-bit kernel services and system notifications. Darwin also includes the latest innovations from the open source BSD community, particularly the FreeBSD development community."

While there are many very good ideas in Mac OS X, it reminds me a lot of fusion cooking, where you make a hotch-potch of very different ingredients. Let me explain.


Hexley the platypus, the Darwin mascot

Darwin is indeed the open Source project around the Mach kernel 3.0. This operating system is based around the idea of a microkernel, a kernel that only contains the essence of the operating system, such as protected memory, fine-grained multithreading and symmetric multiprocessing support. This in contrast to "monolithic" operating systems, which have all of the code in a single large kernel.

Everything else is located in smaller programs, servers, which communicate with each other via ports and an IPC (Inter Process Communication) system. Explaining this in detail is beyond the scope of this article (read more here). But in a nutshell, a Mach microkernel should be more elegant, easier to debug and better at keeping different processes from writing in eachother's protected memory areas than our typical "monolithic" operating systems such as Linux and Windows NT/XP/2000. The Mach microkernel was believed to be the future of all operating systems.

However, you must know that applications (in the userspace) need, of course, access to the services of the kernel. In Unix, this is done with a Syscall, and it results in two context switches (the CPU has to swap out one process for another): from the application to the kernel and back.

The relatively complicated memory management (especially if the server process runs in user mode instead of kernel) and IPC messaging makes a call to the Mach kernel a lot slower, up to 6 times slower than the monolithic ones!

It also must be remarked that, for example, Linux is not completely a monolithic OS. You can choose whether you like to incorporate a driver in the kernel (faster, but more complex) or in userspace (slower, but the kernel remains slimmer).

Now, while Mac OS X is based on Mach 3, it is still a monolithic OS. The Mach microkernel is fused into a traditional FreeBSD "system call" interface. In fact, Darwin is a complete FreeBSD 4.4 alike UNIX and thus monolithic kernel, derived from the original 4.4BSD-Lite2 Open Source distribution.

The current Mac OS X has evolved a bit and consists of a FreeBSD 5.0 kernel (with a Mach 3 multithreaded microkernel inside) with a proprietary, but superb graphical user interface (GUI) called Aqua.

Performance problems

As the mach kernel is hidden away deep in the FreeBSD kernel, Mach (kernel) threads are only available for kernel level programs, not applications such as MySQL. Applications can make use of a POSIX thread (a " pthread"), a wrapper around a Mach thread.


Mac OS X thread layering hierarchy (Courtesy: Apple)

This means that applications use slower user-level threads like in FreeBSD and not fast kernel threads like in Linux. It seems that FreeBSD 5.x has somewhat solved the performance problems that were typical for user-level threads, but we are not sure if Mac OS X has been able to take advantage of this.

In order to maintain binary compatibility, Apple might not have been able to implement some of the performance improvements found in the newer BSD kernels.

Another problem is the way threads could/can get access to the kernel. In the early versions of Mac OS X, only one thread could lock onto the kernel at once. This doesn't mean only one thread can run, but that only one thread could access the kernel at a given time. So, a rendering calculation (no kernel interaction) together with a network access (kernel access) could run well. But many threads demanding access to the memory or network subsystem would result in one thread getting access, and all others waiting.

This "kernel locked bottleneck" situation has improved in Tiger, but kernel locking is still very coarse. So, while there is a very fine grained multi-threading system (The Mach kernel) inside that monolithic kernel, it is not available to the outside world.

So, is Mac OS X the real reason why MySQL and Apache run so slow on the Mac Platform? Let us find out... with benchmarks, of course!

The G5 as Server CPU Mac OS X versus Linux
Comments Locked

116 Comments

View All Comments

  • michael2k - Friday, June 3, 2005 - link

    Well, it shouts to stay away from the XServe unless you happen to have vectorizable code that you have the resources to properly vectorize!
  • erwos - Friday, June 3, 2005 - link

    Excellent comparison of the platforms, although I actually wish they would have spent more time analyzing the graphs.

    Like the others, I would have liked to see a G5 / Linux benchmark (now that FC4 has a PPC version, you could run a fairly reasonable one), but I do admit it's not a very popular option compared to x86. My curiosity is whether MacOS X is the problem, or whether it's some sort of issue with the CPU itself. Seems unlikely the G5 would have such a fundamental flaw, but it does shout to stay the hell away from the Xserve until these issues are resolved.

    -Erwos
  • Thresher - Friday, June 3, 2005 - link

    As the owner of intel, AMD, and Mac based computers, I have to say this is one of the best and most thorough comparisons I've seen.

    You did an excellent job of isolating CPU and OS performance.

    That being said, if performance were the only indicator, there is no doubt in my mind that AMD would be ruling the roost. However, personal preferences come into play to a great deal. Businesses like the reputation behind intel. I prefer the usability of Mac OS X. People have strong feelings about Microsoft that may color their decisions.

    When it comes down to it, performance is important, but not the only reason people buy what they buy. I would say more often than not, the decision is made with only a modicum of logic.
  • Cruise51 - Friday, June 3, 2005 - link

    I'd be interested in seeing how it performs on yellowdog aswell.
  • IntelUser2000 - Friday, June 3, 2005 - link

    People, in case some of you misunderstand, the 10.8GB/sec Full Duplex bus means that its two 32-bit 1350MHz bus, rather than one 64-bit bus in the PCs. Its not, 10.8GB/sec x 2 =21.6GB/sec bus, its 10.8GB/sec bus(or more correctly stated 5.4GB/sec x 2). Plus, it says in Apple site that it has TWO(yes two!!!) of the 10.8GB/sec buses, per CPU.

    Summary: Per CPU=10.8GB/sec
    Per Dual Processor System=21.6GB/sec


    Johan, about the AMD TDP number, they never state that its max power, they say its maximum power achievable under most circumstances, its not absolute max power.
  • JohanAnandtech - Friday, June 3, 2005 - link

    Porkster: It is a little geekisch Unix joke. Where is your geekish you man spirit?

    Wessonality: Our next project if we can keep the G5 long enough in the labs.

    Ailleur2: indeed, I agree. The G5 is a potent CPU with a lot of potential. Just give it a bigger L2 and a better memory subsystem. This is an architecture that could last very long by applying a few tweaks, like the P6.

    Methodical: All of the benchmarks are trustworthy, they should be looked upon as a whole to get a good picture, not just pick one. About After affects, I indicate that the G5 does very well here (seen other reports on the web), I just didn't have the software in the lab.

    I also warned that this was not about "should I buy an Apple or not?". It is just "if performance is what counts for me, where should I position the G5/Mac os X combiantion compared to x86/Linux/Windows ?".

  • StuckMojo - Friday, June 3, 2005 - link


    hmph. you say it yourself in the last paragraph...how come you didn't try it?
  • StuckMojo - Friday, June 3, 2005 - link

    yes, it seems you've left out a very good method of testing if OSX is the issue: run a powerPC linux distro with the mysql and apache benchmarks and see what happens!

    i'd be _really_ interested in the results. see if you can update the article with them.
  • porkster - Friday, June 3, 2005 - link

    "Root Me" in Australian slang is the same as "Fxxk Me" in common language. Some people my find a picture in this review offensive.
  • wessonality - Friday, June 3, 2005 - link

    What about installing Yellow Dog Linux on the XServe?

Log in

Don't have an account? Sign up now