Click here to Skip to main content
15,887,485 members
Home / Discussions / C#
   

C#

 
GeneralRe: Threading for multicore applications Pin
harold aptroot21-Aug-10 7:11
harold aptroot21-Aug-10 7:11 
GeneralRe: Threading for multicore applications Pin
Steven Solberg21-Aug-10 7:25
Steven Solberg21-Aug-10 7:25 
GeneralRe: Threading for multicore applications Pin
harold aptroot21-Aug-10 7:27
harold aptroot21-Aug-10 7:27 
GeneralRe: Threading for multicore applications Pin
Steven Solberg21-Aug-10 7:47
Steven Solberg21-Aug-10 7:47 
GeneralRe: Threading for multicore applications Pin
harold aptroot21-Aug-10 7:57
harold aptroot21-Aug-10 7:57 
GeneralRe: Threading for multicore applications Pin
Steven Solberg21-Aug-10 8:03
Steven Solberg21-Aug-10 8:03 
GeneralRe: Threading for multicore applications Pin
harold aptroot21-Aug-10 8:28
harold aptroot21-Aug-10 8:28 
AnswerRe: Threading for multicore applications Pin
Luc Pattyn21-Aug-10 10:02
sitebuilderLuc Pattyn21-Aug-10 10:02 
I do not really agree with the simple concept of launching all the jobs on the ThreadPool at once. AFAIK the ThreadPool has a dynamic number of threads at its disposal, and will launch more threads (at a speed of 2 new ones per second) when queued jobs remain too long in the queue (that seems true for client Windows, and probably is different on server Windows). The potential problem I foresee with that is, it does not care about the number of cores, so given enough work you will end up with many more threads than there are cores, and that in turn is likely to result in bad performance, due to either memory bandwidth limitations or cache trashing (data needlessly going in and out all the time as threads get switched out of fairness by the Windows kernel).

So what I suggest, assuming lots of work are (or could be) available: create a loop that launches the jobs on the ThreadPool, however rather than launching them all at once, let it wait once N jobs are outstanding, N probably being equal to the number of cores.

A further optimization may take into account that, on some CPUs, not all cores are equal. For instance, the cores on core i5 and i7 are basically paired (using hyperthreading), whereas AFAIK Xeon cores always are individual cores. So you might go for twice as many/half as many outstanding jobs depending on CPU characteristics.

Smile | :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.


GeneralRe: Threading for multicore applications Pin
Steven Solberg22-Aug-10 8:17
Steven Solberg22-Aug-10 8:17 
GeneralRe: Threading for multicore applications Pin
Luc Pattyn22-Aug-10 8:47
sitebuilderLuc Pattyn22-Aug-10 8:47 
GeneralRe: Threading for multicore applications Pin
Steven Solberg22-Aug-10 8:57
Steven Solberg22-Aug-10 8:57 
QuestionC# Getting Responce From Form1 Pin
C.CoderCreator21-Aug-10 2:24
C.CoderCreator21-Aug-10 2:24 
AnswerRe: C# Getting Responce From Form1 Pin
Abhinav S21-Aug-10 2:51
Abhinav S21-Aug-10 2:51 
GeneralRe: C# Getting Responce From Form1 Pin
C.CoderCreator21-Aug-10 2:55
C.CoderCreator21-Aug-10 2:55 
AnswerRe: C# Getting Responce From Form1 Pin
venomation21-Aug-10 3:16
venomation21-Aug-10 3:16 
GeneralRe: C# Getting Responce From Form1 Pin
C.CoderCreator21-Aug-10 3:24
C.CoderCreator21-Aug-10 3:24 
GeneralRe: C# Getting Responce From Form1 Pin
venomation21-Aug-10 3:33
venomation21-Aug-10 3:33 
AnswerRe: C# Getting Responce From Form1 Pin
DaveyM6921-Aug-10 6:14
professionalDaveyM6921-Aug-10 6:14 
GeneralRe: C# Getting Responce From Form1 Pin
Pete O'Hanlon21-Aug-10 7:59
mvePete O'Hanlon21-Aug-10 7:59 
GeneralRe: C# Getting Responce From Form1 Pin
C.CoderCreator21-Aug-10 14:00
C.CoderCreator21-Aug-10 14:00 
GeneralRe: C# Getting Responce From Form1 Pin
Pete O'Hanlon21-Aug-10 21:13
mvePete O'Hanlon21-Aug-10 21:13 
GeneralRe: C# Getting Responce From Form1 Pin
C.CoderCreator21-Aug-10 21:51
C.CoderCreator21-Aug-10 21:51 
GeneralRe: C# Getting Responce From Form1 Pin
Pete O'Hanlon22-Aug-10 3:17
mvePete O'Hanlon22-Aug-10 3:17 
GeneralRe: C# Getting Responce From Form1 Pin
DaveyM6922-Aug-10 4:32
professionalDaveyM6922-Aug-10 4:32 
GeneralRe: C# Getting Responce From Form1 Pin
DaveyM6922-Aug-10 5:14
professionalDaveyM6922-Aug-10 5:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.