August 21, 2009
Photoshop & 64-bit registers
When reading about the advantages of 64-bit computing, you’ll sometimes hear that 64-bit chips offer more processor registers, and that using these registers will make apps faster. As I wrote last year when revealing Adobe’s 64-plans for Photoshop, PS does see a slight performance gain in 64-bit mode:
In our testing, when the app isn’t using a large data set (one that would otherwise require memory swapping), the speedup due to running in 64-bit mode is around 8-12%.
I asked some of the senior Photoshop engineers for background on why the impact of extra registers is pretty low.
“Most of the code we’ve identified as performance bottlenecks was long ago optimized, and in some cases hand-optimized,” replied Jon Clauson. “Such code really doesn’t get any faster because the processor/compiler has more registers to play with. We were happy we saw a general 8-12%.” He also noted that in many cases, Photoshop is not processor-bound, but rather memory bandwidth-bound.
Photoshop architect Russell Williams offered a bit longer answer:
Much of the performance-critical code is tuned not just for few general-purpose registers, but to use SSE, and those registers don’t change size with the move to 64 bits: SSE registers are still 128 bits.
The speedup on compiled C code when going from 32 to 64 bits on Intel varies widely depending on how much the compiler needs those extra registers and how much of the cache is taken up by pointers and bigger ints. Even when it looks like you ought to be getting a bigger win because of the extra registers, the win is less than you’d think because of the heavy hardware and compiler emphasis put on optimizing the loads and stores generated by temporary register spillage. (They’ve been trying to minimize the impact of that limited register set for a long time.)
Russell also pointed out some ExtremeTech benchmarks showing a mixed bag for running real-world apps in 32- vs. 64-bit mode.
Again, to be clear, none of this means that 64-bit isn’t great. It is. It’s just not some magic can of go-fast juice.
A 64-bit reality check
To the less technically-knowledgeable folks out there: Please stop asking for a 64-bit version of iTunes or DVD Player or Fireworks or whatever, blindly assuming that “number of bits” equals “goodness.” This is, of course, all coming up as Apple’s Mac OS X Snow Leopard release is due shortly. Let’s refer to Apple’s developer documentation on the subject:
From Apple’s MacOS X Technology Overview:
For many developers, however, compiling their code into 64-bit programs may not offer any inherent advantages. Unless your program needs more than 4 GB of addressable memory, supporting 64-bit pointers may only reduce the performance of your application.
Not convinced? Let’s try Apple’s 64-bit Transition Guide, “Common Misconceptions”:
Myth: My application will run much faster if it is a “native” 64-bit application.
Fact: Some 64-bit executables may run more slowly on 64-bit Intel architectures because of increased cache pressure.
On Intel-based Macintosh computers, you may see some performance improvement. The number of registers and the width of registers increases in 64-bit mode. Because of the increased number of registers, function call parameters can be passed in registers instead of on the stack. The increased register width makes certain performance optimizations possible in 64-bit mode that are not possible in 32-bit mode. These improvements will often (but not always) offset the performance impact caused by increased cache pressure.
It bums me out that I’ll be seen as “The 64-Bit Wet Blanket Guy,” especially when Adobe has been way out ahead of the pack on the Mac*, shipping the 64-bit-native Lightroom 2 for more than a year. I think 64-bit is great, and it can yield huge performance gains in Photoshop–sometimes 10x or more—when you’re using huge files that demand very large amounts of RAM (4+ GB). But I’m not willing to blow a bunch of smoke on the subject, nor do I like seeing developers–Apple, Adobe, or otherwise–get browbeaten due to ignorance.
By the way, someone will pop up momentarily to talk about how having access to more processor registers makes apps faster. That’s true in some cases (e.g. Apple touts that you can open PDFs 20% faster in 64-bit mode), but it’s not a big win for a highly tuned application like Photoshop. I’ve supplied more details about that in a separate post.
* Up until now (the release of Snow Leopard), who else is even shipping 64-bit Mac apps? My searches have turned up almost nothing.