Qt thread problem with single core CPU on Windows XP
I am developing a cross-platform fractal explorer using Qt. I am experiencing a performance problem specifically when running on a single core CPU under Windows XP (program compiled with MSVC Express 2010), I haven't tried other versions of Windows. With two cores the program runs fine. It also runs fine under Linux with either one core or two cores (compiled with GCC).
The performance problem is something to do with calling a slot in the widget via the signal in the calculation thread. The widget contains a QImage and I pass a pointer to its pixels to the calculation thread. The thread calculates the fractal and plots the pixels to the image. At the end of each row, the thread emits a signal to the widget to tell it to update the display in the main thread. As I understand it, this is a queued connection.
With Windows and a single CPU the update is very slow, much slower than the calculation. It makes the program unusable.
The relevant code is similar to the Mandelbrot example in the Qt docs, except my signal has no arguments because the Qimage is located in the widget not the thread and I do not convert the QImage to a QPixmap.
Doe开发者_StackOverflow社区s anybody have any ideas of what the problem could be and how to go about solving it? Is it something to do with scheduling, time slicing allocation? Is there a compiler flag in MSVC that I need to set? Or do I need to modify my program some how?
Thanks very much!
You say the update is slower than the calculation - how much slower? Have you done any comprehensive profiling to see where exactly the bottleneck occurs? A cursory google finds this profiler which may help you.
Remember that for older CPU's, thread context switching is very expensive. This may be part of your problem, though again I don't know specifics.
精彩评论