Wednesday, August 03, 2011 4:59 PM
Addressing brush lag in Service Pack 1
We designed Painter 12 with multi-core computers in mind. A modern multi-core computer should see significant improvements in performance over Painter 11. In Painter 12, the work for the brushes can be split up and run in parallel on each of your CPU's cores.
Splitting the code to run on multiple cores (Multithreading) is designed to target the scenario where a single CPU core does not have enough power to run the brush smoothly on its own. It is not free to split the work up on to multiple threads but by dividing the task in to smaller chunks the end result should give you faster performance. It is usually worth the extra cost to split things between multiple cores because what you were trying to do was basically too expensive to get done in real-time with single-threaded software.
Let's say that, for the sake of argument, a given brush requires 800 'units of CPU power' in order for it to render in real-time. It costs 100 units to create a thread. So, if we want to split the work in to two, we would have to process 1000 units to render the brush. If your particular CPU has 2 cores each providing 500 units, then by threading the brush code to run on both cores, we're able to achieve real-time rendering. The result is that this brush is now faster than it was in Painter 11.
However, after the release of Painter 12, we began to hear feedback from some of our users that Painter 12 was not as fast as expected. After some investigation, we found two common reasons why things might get slower:
- The amount of work needed to render a brush is so small that the added cost of multi-threading is not worth it.
- Multiple threads can interfere with each other when sharing hardware resources. This is a problem when you have very few cores available or are running many processor-intensive applications at once.
To address issue #1, the release build of Painter 12 included the Multicore checkbox in the General brush controls panel.
A challenge we've got is that there are so many combinations of brush settings available that it was impossible for us to consider all the different cases where it made sense to disable the multicore checkbox. We benchmarked every brush variant in the application and we believe that we've correctly identified the variants that should and should not have the multicore checkbox enabled. However, your individual hardware configuration and preferences come in to play so it's important to make your own determination on whether you prefer having the multicore feature enabled for each of your favorite variants.
A simple guide is that the bigger the radius, the more likely multicore will have a positive impact. If you use small brushes, or find that a few variants don't perform as well as expected, turning off this checkbox will prevent Painter from trying to split up the brush operations on multiple threads. You will save the cost of the threading overhead and your brush performance may improve. (Chris has some thoughts about the multicore checkbox in his blog here.)
Issue #2 is more interesting. Extending the example from above, let's say that on your particular computer you're simultaneously running another CPU-intensive application. Perhaps you're recording your work in Painter using a screen capture utility or maybe you're playing back a script in Photoshop. Now Painter is in competition with that other software. Painter mistakenly believes that it has exclusive access to all the CPU resources available on your computer. But, if that other application subtracts 200 units of your available CPU power, Painter still requires 1000 units to complete and your CPU no longer has enough units available. The more cores you have, the messier this can get as each additional core adds another possible point of contention with another program.
We have no way of knowing what kind of programs you're running on your computer and so balancing Painter's CPU usage with other programs is a big challenge. So, to address this problem, we have added a new feature to Service Pack 1: The Multicore Usage Slider.
The Multicore Usage Slider allows you to manually configure the maximum number of cores you want to allow Painter to use.
To change the multicore usage slider value on your copy of Painter go to Edit > Preferences > Performance... (on Windows) or Corel Painter 12 > Preferences > Performance... (on Mac).
You must restart Painter to see the effect of your change.
By default, we now use 1 core less than the maximum on your system. Out of the box, this will ensure a good level of threading and leave one core free for operating system functions and other applications. If you're a heavy multi-tasker, you may want to try lowering your Usage slider slightly. If you have an 8-core machine, you may choose to play with setting the slider to any number from 1 through 8. On my machine, I have been finding that a value of 7 gives pretty good results.
Running Painter this way will reduce the amount of CPU cores that Painter tries to use. This should result in a smoother sharing of resources between Painter and other applications on your system.
Hopefully, you'll find that Painter 12 performs better with this change.
Filed under: tips, performance, multicore