number of threads decreases rendering performance.

hello,

in my game i have a number of threads, which accomplish other tasks, like networking, ressource loading, soundplaying, etc.

i noticed that from a certain number of threads, the frame rate decreases significantly.
4 seems to be the magic number. with up to 3 threads the framerate is pretty constant, but as soon as i start a 4th thread ( no matter which one) the framerate goes down to about 25%.

i have set all other threads to MIN_PRIORITY and i have set my animator thread to animator.setRunAsFastAsPossible(true); but without any change.

has anyone experienced the same and has a solution for this? thanks!

You didn’t say what type of system you were running on, was it a single processor, single processor with SMT, dual core, etc…

Normally you would expect to there to be a drop in performance with each additional thread on a single processor system due to context switches, but it’s interesting that you didn’t experience a drop until four threads.

context-switches are relatively cheap. You can have lots of threads (~dozen) and don’t notice a performance decrease over 1-2%.

It all ofcourse depends on what those threads are doing, that’s where the cpu-cycles go - not the context-switches.