OS X Snow Leopard to Use ULE Scheduler?

Ever since Steve Jobs first unveiled the next version of OS X, dubbed “Snow Leopard,” the internet has been abuzz with excitement and wondering about the supposed “evolutionary” qualities of OS X 10.6. One of the most-hyped improvements is the promised revamp of the SMP capabilities of OS X, with a “breakthrough” in SMP performance.

The codename for the technology behind the SMP improvements in OS X Snow Leopard has been named “Grand Central,” which Apple describes best:

“Grand Central,” a new set of technologies built into Snow Leopard, brings unrivaled support for multicore systems to Mac OS X. More cores, not faster clock speeds, drive performance increases in today’s processors. Grand Central takes full advantage by making all of Mac OS X multicore aware and optimizing it for allocating tasks across multiple cores and processors. Grand Central also makes it much easier for developers to create programs that squeeze every last drop of power from multicore systems.

Our guess is that these SMP “breakthroughs” are going to be delivered in two blows:

  1. Improvements to the OS X kernel intended to boost multi-threading & multi-tasking performance and better-distribute the loads across multiple CPU cores more intelligently.
  2. Provide an SDK (perhaps as improvements to XCode) that allows developers to more-easily write multi-threaded code, handle forking, and provide load-balancing features on a per-core basis.

The first feature is what’s exciting – we believe there’s a good chance Apple will be using some form of FreeBSD’s ULE scheduler or the other in OS X.

There isn’t much info available on what scheduler(s) OS X is currently using as of 10.5 (the only question we could find on the topic remains unanswered). But OS X has its roots firmly planted in the *nix world, and it’s possible to make some educated guesses on the topic. The XNU Kernel that OS X uses is a mesh of the Mach Kernel and large portions of the FreeBSD project, and OS X uses the Mach kernel’s scheduler – or at least it did back when OS X was first launched.

The FreeBSD project has long been working on alternative scheduler intended to replace the default and aging 4BSD scheduler: the ULE scheduler. ULE is now scheduled to become the default scheduler in the upcoming FreeBSD 7.1 release. ULE has shown significant improvements in multi-core environments, and was designed from the ground up to provide increased SMP scalability. Most importantly is ULE’s overhauled support for per-processor queuing of tasks and the ability to set CPU affinity per-processor-per-thread.

If Apple were to implement a form of the ULE scheduler in OS X 10.6, Snow Leopard would be a formidable OS indeed. Using ULE guarantees huge performance benefits for multi-threaded applications, and would help address the second point listed above: the SMT affinity options provided in ULE would make creating an SDK intended to allow developers to use multiple cores efficiently and evenly quite easy. OS X has always been close to the FreeBSD project, and something like this is a natural fit for an OS looking for improvements to SMP/SMT performance.

Of course any time Apple offers a feature, it has a twist of its own. In this case, it’s OpenCL – a technology Apple says will allow developers to use the GPU as a number-crunching processor right from the usual code without much effort. This lies squarely in ULE’s playing field, since the ULE scheduler was designed with full support for load-balancing and threading across processors of varying performance, clock speeds, and fortés – which isn’t something that other schedulers can do, and would make OpenCL simply a matter of interfacing with the ULE scheduler and add the GPU to the list of CPU cores available for the ULE thread scheduler to take advantage of.

The bottom line is, the history of OS X and the XNU Kernel, the features promised in Snow Leopard, and the design and architecture of the ULE scheduler all point to a high likelihood of Apple using a redesigned thread scheduler that is either an implementation of the ULE scheduler or at least based around it in OS X 10.6. And if this is the case, OS X 10.6 will be one heck of a powerhorse.

Further Reading