Author Archive: Edward Kandrot

Photoshop Beta Performance

Adobe cares about performance. How do I know? Because there is a team of us on Photoshop whose only job is performance. I spent all of my time for this cycle doing nothing but performance, a lot of it on start up time. I thought spending my time to make the product launch faster would be valuable, and it looks like that was the correct decision.

Any application can be made faster and Photoshop is no exception. As I have mentioned in the past, it is my responsibility to make sure that Photoshop’s performance improves with every release. The beta was released while I was away on vacation, and I see that a few questions came up on the bulletin boards during that time, which were effectively answered by people on the team. Still, I am want to throw my voice into the ring to answer and help where I can.

One of the biggest questions that I have seen, and one I hope to tackle here now: 64 bit. The question seems to be: Why isn’t the beta 64 bit? My answer to this is: Why does it matter?

Photoshop will run on 32 and 64 bit OSes well. It will take advantage of the hardware you have as best it can. That is the most important thing to keep in mind – Photoshop will run well on the hardware that you have.

If we shipped a version of Photoshop that was 16 bit, but still ran on all of the 32/64 bit OSes, would that matter? If we determined that a 16 bit application would run users tasks faster on these OSes, wouldn’t you want that version? I and others here verified what would give our customers the most bang for their buck on this release (since, I really am the person who says this all of the time here, since that is who I am and why I am here at Adobe). I could have spent this whole cycle moving us to 64 bit rather than working on startup time, but would that give you more of what you want? Add 20 seconds to the startup time you are seeing for the beta for all versions/platforms of Photoshop and compare the value of that version to one where the histogram would be 10% faster on 64 bit machines (and most of the rest of Photoshop being 5% slower). It is true, there are some things, like histogram, that would be 10% faster, I wrote the code to verify this. But, the rest of the product would have been slower without a few people spending the whole cycle going over all of the slow parts and bringing them back to where they were on 32 bit. Most operations on a 64 bit application like Photoshop are actually slower by a small amount if time isn’t spent optimizing them.

So, remember, while most of the people on Photoshop are bringing you way cool new features, I and the handful of people on my team are in the backroom trying to save you time and make your work go faster. We made choices based on bringing you the best that we could out of the various choices of where to spend time – at least that is my belief. As Scott said in his blog, most of the benefit and the reason most people ask about 64 bit isn’t because of a known technical advantage, but of a marketing advantage, while here on the team we would use whatever technology that would bring advantage to you, even if it were 16 bit.

I hope I have addressed your concerns over 64 bit at least. I’ll be on the public boards and the beta boards looking to answer your questions about performance – there are quite a few performance minded people already there, so I will chime in when I can.

Edward Kandrot

Coding Tip: Separate

I’ve been trying to put together a rather long list of coding tips to post here, so as to share what I’ve learned about coding for performance. I found it hard to put them all together and keep the post down to a few pages, so I’ve decided to post the tips over time. So, here goes my attempt at a first tip!

Separate your concepts – one operation per line. So instead of:

a[x] = b[x]*c[x]

do this:

temp1 = b[x]
temp2 = c[x]
temp3 = temp1 * temp2
a[x] = temp3

“Why?”, you might ask. Well, this simple code breaks down into 2 loads, one multiple, and one store. Putting all of it on one line might save you space in your .cpp file, but in an inner loop you will want to expand it as I have done for better performance.

The performance for this code in an inner loop is gained by hinting to the compiler and the CPU what is going on and what depends on what. Putting all of the loads up front allows it to possibly stream the loads better, and the same with the stores at the end. The compiler can look at this code and have an easier time figuring out how to unroll it. At run-time, it is possible that other instructions could be put in-between some of the operations to use the time wasted waiting for operations to complete (out of order execution). So, if your loads take too long and if it knows that the operations are independent of each other, it might be possible for it to do something else while waiting.

Well, that is my first tip. We’ll see how it goes as to whether I will do more programming tips or something else. I hope this helps.

-Edward

Some tips and stories

Before I get to my tip story, here is another story: in the three+ years I have been on the Photoshop team, I seem to have been absent whenever someone showed up to take a team picture. 2 weeks ago (I was on vacation last week) Photoshop TV was here to visit while I was actually here! So, I am in episode 32, which is very exciting for me. Though at the time, I didn’t know who was filming and why, so I was more nervous than my usual funny.

My tip story: I was at a local computer store with some friends as they were buying USB memory cards that were deeply discounted. A friendly woman was helping out my friends, since she found the good cards with a great discount. She said that she was buying them for her work on some project involving Photoshop. My friends told her that I worked on Photoshop, which was my first time that I ever really told anyone in public (I’ve been trying to keep it under wraps until recently). So this was my first positive experience with a real customer! Most people when they hear I work on performance want to tell me where their pain points are with Photoshop, no one is ever happy with how fast something runs, including me.

She said that she recent bought a new machine and the salesperson from this other store told her to buy things that would make Photoshop run faster, which would have been nice if the advice was accurate. I gave her some pointers, but realized that this blog is probably a good place to do some of that as well.

The tips:

1) If you only have one hard drive and work with large files, consider getting at least a second hard drive and set that to be your scratch drive. If you can pack three drives into your machine, I would recommend one with your system and Photoshop folders and the other two drive RAIDed together and make that your scratch disk. RAIDing the two drives lets the OS treat them as one large drive but with almost half the access time (double the speed). Very nice.

2) Multicore or mutliprocessor machines. When Photoshop is working with images that are in memory, it will divide up the tasks across as many processors as you have. There is a curve associated with the number of processors and the speed up that you see, because past a certain point, overhead of communication takes more and more of your speed. So, with each processor you add, it will be faster, it is just a matter of how much faster per processor. Two processors is a nice area to be in, four if you can afford it. Around eight or more, I do not have enough experience with that configuration to comment.

3) Get the fastest memory and memory bandwidth motherboard that you can. Many of the Photoshop operations are memory bandwidth bound. This is very true with multiple processors, since each processor needs a certain amount of memory bandwidth to move image data around for processing. Also the more memory you get, the better. Photoshop will use up to 2 Gig of memory (or 3 Gig depending on the OS and machine), but anything beyond that amount, the OS uses for either other applications or caching. So, if you are switching applications a lot or working with a lot of image data, there is a big win for more memory.

4) GPU. For now, this doesn’t matter that much. A recent video card is good, GPU doesn’t really matter. True, GPUs matter more and more, and many applications use GPUs, so having one might help you in the future or it might not, but it really will not do you any good right now. I’d say wait until you know you need one, because by then, the performance per price will be much better. Until then, a video card with fast 2-d will be the biggest win in this area.

We try to make Photoshop do the most the hardware that you have. So, the better the hardware, the better the performance, with the exception of GPU.

-Edward

Why?

I love performance. Features are nice, but if they are not fast, then I consider them unusable. The point of performance is to allow someone to accomplish a task in the minimum amount of time. If you are operating on a multi gigabyte file (ie a file that is larger than the memory you have available), the fastest solution is to have a fast RAIDed harddrive for scratch. If all of your work is large but fits within memory, then the best speed ups probably come from highly optimized code. If you are working on many small files, then a clean UI with quick access to functions that you want to perform is where you will find wins.

What can I do? Well, I can offer advice for the first case, but it is a pretty well defined space already. For the third case, features that combine operations or ease accessibly, I’m not much of a feature man. But, for the second case, I can do something about this.

What do I want? I want to help people. I want their experience with Photoshop to be the best that I can make it. If there is a performance issue in Photoshop, it bothers me. If I find someone on the team has introduced a slowdown, I can darken their door until it is fixed. If there is a key algorithm than can be optimized for a specific processor, I can write that assembly code. This is my area, and I will do what I can to make sure that users of Photoshop are having the fastest experience that we can give.

Sure, it is a large project, lots of code written well before I even heard of Adobe, but I want to make it better. Quality first. This is where this blog comes in for you and me. I want to find out what I can do and let people know that someone is focused on this area. And I never sleep. Okay, up until that sleep part, I’m serious, I will do what I can, as will the rest of the team.