The Mac "Fast Path": Safari 4 vs. Chrome 5




I did a quick benchmark of scroll speed in Safari 4 vs. the new Chrome 5.

My benchmark is, "Drag the scrollbar up and down furiously in Google News while running Shark."

And Chrome feels a lot faster than it did before. A lot.

But, Chrome still pegs the CPU during my test. Amazingly, Safari doesn't use all of a core. Scrolling in Safari is a relaxed day for the CPU.

The shipping version of Firefox has a profile more like Safari's--apparently it's using the system functions to scroll bits. However, a new experimental Firefox that uses layers (aka hardware textures) experiences a bottleneck quite like Chrome's.

Maybe in this case, people are slowly reading back from hardware textures instead of blending to surfaces in memory. I don't really know the details, but my experience as a coder is that there are a lot of slow ways to do things on a Mac.

It occurs to me that one of the things that Windows has done well is to expose layers of abstraction and optimize a ton of permutations, so when you want to go "one level deeper" you can, and you can make it as good as the function built into the OS. If you want to write your own DirectShow filter to be in the native pipeline to the hardware, you can. If you use a weird mode in Direct3D, it is often still fast. You can mostly understand the profile and what's holding you up.

Apple provides tons of options for drawing bitmaps: blend modes, color calibration, ways of drawing bits to the screen. But not many of them are fast. If you turn on the wrong color-management bits, your app can become 50x slower, and this is no good.

In the early days of graphics workstations, vendors would optimize one or two "fast path" ways to draw to the screen,. But in the world of awesome NVIDIA drivers, now a lot more of those options are fast, because we've had the benefit of 15 years to work out all the details.

MacOS X seems to have some "fast paths" and a lot of slow ones that developers are getting tripped up on. But it is one thing to make a few abstractions that do a few things well, and another thing to make a platform that does anything you want to do well.

Today, it is difficult for Flash to get the best video decoding (my 10.1 "Gala" build of Flash chews CPU like a pig while Quicktime is nearly idle), and it has taken a year for a team of really smart people at Google to get a browser to scroll almost as fast as the one Apple provides. Picasa draws its UI 10x faster on Windows. The trend is not so good, unless you use Apple's widgets all the way up and down.

Steve Jobs should very simply stop criticizing other companies' performance until he makes his platform fast by default. Whether it takes sample code or performance tuning help or improvements to the OS, Apple's own apps shouldn't be running 10x faster than other apps that do the same things.

If the other companies really were actually lazy or incompetent, you'd understand, but honestly, Netscape Navigator back in 1995 scrolled fast, on Windows 95, on XWindows, on System 7. It's not a new, hard problem for an OS to do something like this well.

It's probably time for some new benchmarks, because when some of the bottlenecks are below the level of the applications, it's hard for people to understand who's at fault.