Grokking concurrency, message passing and Co
sybrandy
sybrandy at gmail.com
Sun Jul 11 18:50:22 PDT 2010
>>>>> The rule of thumb is don't bother spawning more threads than you
>>>>> have cpus. You're just wasting resources mostly.
>>>>>
>>>> You REALLY don't want more threads trying to run than you have cores.
>>>> Threads in a wait state, are less of an issue, but they still use up
>>>> resources.
>
> Personally I'd never use more threads than cores as a program design,
> but I'm a performance whore. ;)
>
Could you explain why you believe this a bit more? I'm curious because
I've worked with databases and the rule of thumb there was you should
configure them to use twice as many threads as number of cores/CPUs.
The reasoning, I believe, is that if one thread on the CPU is stalled,
another thread can execute in it's place. And yes, I believe this was
before hyperthreading.
Though I wasn't informed of the specifics as to why, I'm guessing it's
mainly because with a database, there's a good chance you have to
perform some sort of disk I/O. Therefore instead of having the CPU wait
while the I/O is occurring, another thread can start executing while the
original is waiting.
Casey
More information about the Digitalmars-d-learn
mailing list