Follow Slashdot blog updates by subscribing to our blog RSS feed

 



Forgot your password?
typodupeerror
×
OS X

Journal TheRaven64's Journal: OS X Thread Performance

There have been a lot of arguments recently about why OS X sucks for some things, and the blame is often laid at the door of OS X's threading performance. This seemed odd, since OS X gets its threading system from Mach, which was designed to support threading from the ground up. As it turns out, the reason is somewhat more subtle.

OS X sucks at system calls. Due to the Mach+BSD kernel design, system calls are very expensive on OS X. On Mach, the system call cost is around 10x the cost on BSD - on OS X it's some combination of the two depending on what you do. The next thing to realise is that all of the POSIX thread synchronisation mechanisms are implemented using Mach-level synchronisation primitives. This means every time you lock a mutex (for example) you need to dive down through the BSD layer to the Mach layer. This gives you the horrible overhead of checking the permissions on a Mach port (something that sane Microkernels like L4 abandoned), and is expensive. This makes locking operations on OS X much more expensive than on BSD-like kernels. This, in turn, can make threaded code much slower. If you are Adobe, and you are rendering an entire image transformation in a small number of threads, then you will only lock at the beginning and the end of the operations, so it will be nice and fast. If you are doing low-level parallel operations for scientific computing (when not bitching about the OS X kernel), then you should really try harder to persuade someone to buy you a nice Solaris box.

This discussion has been archived. No new comments can be posted.

OS X Thread Performance

Comments Filter:

As long as we're going to reinvent the wheel again, we might as well try making it round this time. - Mike Dennison

Working...