Hi, Jay Cox <jaycox@xxxxxxxx> writes: > Here are some results for you: > > Dual 2.5ghz g5 mac, mac os x 10.3.8 > CVS gimp Changelog revision 1.10539 > > Linear Gradient blend on a 3000x3000 pixel image (Dithering on) > 1 Processor: 7.98 seconds 1x > 2 processors: 5.20 seconds 1.5x > 3 processors: 5.23 seconds 1.5x > > Linear Gradient blend on a 3000x3000 pixel image (Dithering OFF) > 1 processor: 3.89 seconds 1x > 2 processors: 2.37 seconds 1.7x > 3 processors 2.40 seconds 1.7x > > Clearly the gradient code could use some tuning. A linear blend > shouldn't take much more than 1/2 a second even with dithering. > > The reason why the dithering case gets less of a speedup is because the > threads are fighting over the GRand state. Each thread needs to have > it's own GRand state. > > It looks like the threads are also fighting over gradient->last_visited. > My guess is that fixing this will get us much closer to the ideal 2x > speed up. Eeek, I didn't think about gradient->last_visited. While the use of GRand is MT-safe, accessing the gradient obviously isn't. So this is not only slowing things done, it is a race condition that can lead to broken results. We definitely need to fix this or revert back to a non-parallel version of gimp_gradient_blend(). BTW, thanks for fixing my threads code and also thanks for these benchmarks! Sven