[Qt-interest] Some thoughts about QThread::idealThreadCount()

Yves Bailly yves.bailly at sescoi.fr
Fri Mar 6 08:54:27 CET 2009


Thiago Macieira wrote:
> Yves Bailly wrote:
> We're still Trolls :-)
> [see the t-shirts in the 4.5 release blog]

I missed that... my apologizes :-)

> [skip]
> In general, the main thread is the GUI thread, so it also can't be used 
> for CPU-intensive tasks, as that could freeze the UI. Instead, the main 
> thread should sleep waiting for the other ones to be finished or for there 
> to be another event to react to.

I understand that.

>> Another approach. Consider an algorithm that bounce everywhere in a
>> huge memory array, for example a simple QuickSort implementation. This
>> type of algorithm will cause many cache misses on the processor, thus
 >> [...]
>> return 1 (haven't tried yet), my "ideal thread count" for my specific
>> problem would be around 8.
> 
> In that case you're correct. But that would also mean that "ideal thread 
> count" is actually dependent on the actual job you're trying to make.

And that's precisely my point: "ideal" depends on the job. My "problem"
(but it's not really a problem, this is just for the please of arguing) is
that the word "ideal" more or less implies the returned value is really
the best value in every case. But that's not true: as you said yourself,
in some case it's true, in some others it's more, in some others it's
less... maybe a name like "availableHardwareThreads()" would avoid this
semantic shift...

Bah, it's not that really important. Maybe the doc should reflect what
you just said, to avoid any misunderstanding.

Anyway, thanks for you answer :-) and don't feed the troll... (sorry,
couldn't resist)

Best regards,

-- 
     /- Yves Bailly - Software developper  -\
     \- Sescoi France http://www.sescoi.fr -/
"The possible is done. The impossible is being done. For miracles,
thanks to allow a little delay."




More information about the Qt-interest-old mailing list