[Interest] how to run 21 threads concurrently

Thiago Macieira thiago.macieira at intel.com
Thu Oct 4 15:51:51 CEST 2012


On quinta-feira, 4 de outubro de 2012 15.46.57, André Somers wrote:
> If you think that running 21 threads on an 8 core system will run make 
> your task go faster, then Thiago is right: you don't understand your 
> problem.

If you run 8 threads on an 8-core system and they use the CPU fully, then 
you're running as fast as you can.

If you have more threads than the number of processors and if all threads are 
ready to be executed, then the OS will schedule timeslices to each thread. 
That means threads get executed and suspended all the time, sometimes 
migrating between processors. That adds overhead.

If it adds overhead, it's slower. Depending on your OS, it might be 
considerably slower.

If you do not understand what I said, understand this: there's a reason why 
QtConcurrent runs as many threads as there are processors.
-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20121004/efc0071f/attachment.sig>


More information about the Interest mailing list