TL;DR
Outsource pathfinding to idle cores, to optimize the main loop which is using one core 100% on server with multiple cores but low performance per core.What ?
Instead of running the A* inside the main loop, i would suggest to implement some kind of event driven scenario for multicore usage.- Spawn as many "pathfinding procceses" (PP) as needed/cores available, to prevent main loop using one core 100%
- Provide these PPs with "walkable area" data and changes (if needed, e.g. used landfill, a blocking placable)
- If main loop needs to calculate a path, just trigger a event with coordinates
- One of the (least used) PPs catches and handles the event and presents the result to the main loop
This would spread some of the calculation burden from main loop to other cores
Why ?
This suggestion happens because: TrainsI'm running a Factorio dedicated multiplayer server and got blamed for low performance, so i looked into it.
The CPU used is a INTEL Celeron J4125 at 2 GHz, 4 physical cores
There are about 200 trains (mainly 1-2-1) on a mostly loop based track system with a mixture of end-stops and roro-stops
Factory running at full throuput (buffer chests/tanks for trains) somewhat arround 1k science per minute
Result: One core at 100% nearly all the time (see picture) and therefore increadable low ups (e.g. walk using 3 exoskeletons still slower then "normal" walkspeed)
Test: I figured that if i stop (or delete) all trains, then the server instantly goes "back to normal" with full ups (while factory still running from/into buffer chests full throughput) at around 30% one core usage
There would lie the benefit for the game.. better multicore support == bigger factories
(Except i missed something or got it horrobly wrong )
-- EDIT: Save attached