My game uses a multi-threading architecture, with the threads laid out like this:
Right now, there are (hardware_threads - 3) worker threads, one for each unused hardware unit, but I'd like to add one more by combining the "Resources" and "Network" threads onto one unit since both threads are going to spend a lot of time idling.
You're right, in that this is a bad idea. Having a one thread for one job design sounds simple, but it's really not- particularly when some jobs are heavier than others. Also, you have made not enough threads. Usually you want a couple more than that to account for slack in other threads which aren't running right now.
The fundamental problem here is that you are implementing your own threading backend. This is a bad idea. You need to move to something like TBB, which will deal with all of this stuff for you, and those engineers at Intel spent way, way longer profiling and working on it than you.
As for whether this is a worthwhile optimization, well, probably not. Just make enough workers and keep them loaded, and the resources/network thread which are blocking won't really make much difference.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With