C ++ Jobqueue: is there a rule for the number of worker threads?

I just implemented a very simple multi-threaded result in C ++, and I thought (and read) that it would be nice to use one worker thread for each hardware thread (in my case it will be 4). Basically, my application just downloads a lot of images (at the same time) from the Internet right now, and I notice that I get tremendous speed if I increase the number of workflows to 8 or even 16 instead of 4.

Is there a general rule how many threads should be used in such a task? My assumption would be that 4 would be a large number if I were creating new jobs for each frame, and workflows had a constant workload for each frame, and if I want to process many things at once (for example, upload 50 images or so of that) more threads than this can give more speed. However, is there a rule for the correct number in different scenarios?

thank

+3
source share
3 answers

. , , - .., . , .

" ", . , , ( Win32) - .

+2

Microsoft threadpool ( , .net) , 1,5- . , , ( i/o ..), , . , , , 2x, 3x .

, .

+2

, msdn, , 16 . , , 16 .

0

Source: https://habr.com/ru/post/1778430/


All Articles