I’m sure I’ve said before how much I love Shark. (Shark, for those who don’t know, is Apple’s awesome tool for figuring out performance problems.)
Here’s the thing: it seemed like the Combined View in the latest NetNewsWire betas was faster on Tiger than on Leopard. I would have expected the other way around, of course, as Apple tends to make new operating systems feel like hardware upgrades.
So I ran the app using Shark to see what the problem was.
I found that 37.7% of the time in the main thread was spent in
-[WebView(WebPrivate) _preferencesChangedNotification:]. That seemed really suspicious. (It totally didn’t match any of my theories—but the beauty of Shark is that it tells you where the slow-down is, no matter what your theories are.)
Your first guess may be that it’s a WebKit bug, since it appears in WebKit code. But it’s not.
_preferencesChangedNotification does a bunch of preferences look-ups—it uses NSUserDefaults to look up a bunch of values. The slow-down is looking up the values.
To get a comparison, I did the same thing on a machine running Tiger—an older, slower machine, actually—and found that it spent just 15.6% of its time in
Holy farts! Shark rules.
Then I created a little command-line app that would tell me how long it takes to do a bunch of preferences look-ups. To get a fair comparison, I ran the app on a dual-boot machine.
The code calls
CFPreferencesGetAppBooleanValue 100,000 times to read a pref from Safari’s preferences.
Leopard (10.5.1): 2.10 seconds
Tiger (10.4.11): 0.06 seconds
You can download the project if you want to. The bug has been filed with Apple as rdar://5608561.