#How do you find out how many threads you should be using when trying to improve performance?

19 messages · Page 1 of 1 (latest)

tight robinBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

glossy bobcat
#

well firstly everything will lead to diminishing returns because of how inverses work
e.g. the difference between 1/100 and 1/99 is tiny, but the difference between 1/2 and 1/3 is large

#

but secondly once you start getting a lot of threads you start being bottlenecked by synchronisation and the number of cores

#

also just because you have N cores on your computer doesn't mean your process is using all N cores, you're running other things

pseudo compass
#

what is the cost of moving data from 1 core to another?

#

if you don't know your cache heirachy and costs... you are lost.

marsh crypt
#

you bench ofc

#

don’t guess

#

it always depend obviously

#

so you have to benchmark every time the workload changes

glossy bobcat
#

Well you would use that if you wanted to use all cores. But using all cores is going to get you diminishing returns as you noted. I would make it use all cores by default (maybe minus 1 or 2 to allow debugging things to run alongside) but then also let a user decide

#

you ever played a game where they have a benchmark thing you can run. This is the sort of things its doing

#

what

#

what do you mean "the number of threads currently running"

marsh crypt
#

yup. or you could go with veeloxfire's suggestion if this is too complex or you decide it's not worth to do it: let users decide how many threads they want to use

glossy bobcat
#

you either meant:

  • the number of threads this process is running: which yes you should subtract at least 1 since you always have a main thread, and 1 for every other thread you're using if you just want to get the total number of threads you could run at once
  • the number of threads running on the system: which unfortunately there are likely 1000s of threads running so thats not particularly helpful
#

this is currently running 5000 threads lol
You can see you have a lot of other processes to content for time with

tight robinBOT
#

Thank you and let us know if you have any more questions!

This thread is now set to auto-hide after an hour of inactivity

pseudo compass
#

lol.. how many threads are currently running on your machine? (look at your Task Manager)