I wonder if multi-threaded game can be faster than single (or double) threaded game. What do you think, is using multiple threads for game logic good idea in projects in which the CPU performance is the most important?
No. Flat out plain no. If you mean running every object in a game on a different thread, then no. But if you mean multi-core suppport, then yes. If you have too many threads running at one time, it may actually do more harm then good. It would be super hard to manage and just nasty to clean up. Using a couple threads for world generation and the such is a good idea, but beyond that, I wouldn’t use any other threads.
It depends on how well you do it. It’s can work to have a rendering thread, a logic thread, a resource loading thread, a world generation thread (if applicable), and even an input thread if you do it right, as well as threads for connections, etc. It all depends on how your game works and how well you know how to implement multithreading though.
If you have a problem which can be easily threaded and said problem is also a bottleneck then it’s a good idea. Threading game logic can be difficult since it might not be easily threaded since objects may depend on each other. A simple example of something slow, CPU-limited and threadable is bone interpolation for skeleton animation. Each skeleton only depends only on itself, so they can be interpolated in parallel for an almost linear increase in performance with the number of cores. It’s also possible to do things like collision detection on multiple cores. I have a test program simulating 20 000 balls in 2D with collision detection running at 118 FPS on one thread vs 445 FPS on 8 threads (4 cores with hyperthreading). That’s a scaling of 3.77x for 4 cores. I’d say it all depends on the cost-effect ratio of implementing it.