How many threads is too many for a game?

Soldato
Joined
1 Apr 2014
Posts
19,253
Location
Aberdeen
Should every AI object - spaceship, soldier, battleship, whatever - have its own thread? How many threads is too many?

Desktop CPUs can have up to 32 threads (and HEDT up to 128) at 4 GHz. Why not make use of them? Let's say you're redoing Freespace 2 and have a 64 ship battle, each with its own thread. At 4 GHz on a Ryzen 3950 each ship gets half a full core. (Yes, I'm simplifying) Surely that's more than enough? Even a 100 ship battle gives 1 GHz per ship (at 60 fps that's 16.5 million clock cycles per frame) - more than enough for AI.

But how about 1000 threads? Beef up that battle 10 times. Is 1.6 million clock cycles per frame enough for a decent AI? How about thread management overhead? How does CPU cache impact this?

Paging @Rroff.
 
Ah, you're talking deadlocks and blocking. I remember those from my degree days. Aren't there easy ways around them? Especially when in this case it doesn't matter if a thread fails to complete in time. IIRC the core thread just polls the other threads for updates and if it doesn't get one just moves on. But this was the point of my asking if the available number of clock cycles were sufficient
 
Back
Top Bottom