Performance - Multiple Questions
Posted: Tue Jun 16, 2020 8:02 am
Hi,
We have strong Gaming PC's.
But our Base is down to 40 UPS, and the game only uses 24% of the (4 Cores, 8 Threads) CPU.
Because Factorio do not scale with more CPU Cores, it is not even possible to buy a better CPU with 8, 12, 16, 32 Cores to speed it up.
Any tipps for me, what I can do to speed up our base?
So my Questions and requests are:
Multithreading:
I know converting a Game loop from Single to Multithreading include a massive change for locks for the main data structures.
This will even lead to overhead for those locks - even using user space spinnlocks because it is not to be expected to have much locks in lock state.
But this can be avoided.
The assumption is, that a giga base is spread across a huge area or multiple surfaces.
Futher assumption is, that every entity can only interact with other entitys which are close (100 Tiles?) to other ones. For example I think an assumption/Assertion can be made, that no inserter pick from more than distance x (coose a big one - 100 Tiles?).
So the Base can be splittet in sections, and all of them updated individually, even without the need for locks.
One of the sections is the "grid" between the tiles, which need to be updated single threaded afterwards, because there could be overlaps.
That also should not break deterministic multiplayer... Because it shouldn't update the order in which you update the tiles..
Example:
So Multithread tiles:
100<x<100.000 100<y<100.000
-100<x<-100.000 100<y<100.000
100<x<100.000 -100<y<-100.000
-100<x<-100.000 -100<y<-100.000
And then serial the remaining grid...
-100<x<100 -<y<+
-<x< -100<y<100+
Can be done for 8, 12, 16 Cores as well...
Or:
Transport lines take currently about 50% of the load.
Our complete Base is belt based and no robots.
Maybe it would be easier to give each connected belt one job for a thread pool?
Dont know your data structures, but I can imagine a connected belt will be some sort of merged to one update entity...
Or:
Entity updates.
I cant image the progress update of one factory affects another? Only if there are goods finished there is interaction to import/export the items.
So the updates without creating or consuming stuff can be fully parallel?
LuaJIT:
For huge Mod, this would be a really great improvement. Currently our mods take ~8ms.
Benchmarks for LuaJIT show 25 times faster as LUA interpreter (in perfect condition).
Multithread mod:
Allow Multiple threads for heavy load mods.
Maybe as an option in the mods info.json.
It "Use Multithreading" is set to true, just put a fassade with a guard in eacht interface call in between.
This can be generated automatically and do not need to be hand written by you.
I think your c++ bindings to LUA are generated anyway?
Benchmark for Factorio
I think currently there is no Database, which CPU/RAM/... will have how many UPS.
That would allow me to compare and buy a new CPU for Factorio.
Can a benchmark be done to get such a Database?
Think some sort of really massive Gigabase would be enouh, then post UPS including used Hardware as the CPU.
I would spent a big amount for a new CPU if this would help, but I dont think a 12, 16 ... core CPU is significant faster compared our current 4 Core one..
I think it would be a huge improvement to Factorio to allow even bigger bases.
And to scale (at least a bit) with CPU count, because then players like me can just buy a bigger CPU to continue the base instead of starting a new one.
Would be a shame to use only 2% of the performance of a 64 Core Threadripper 3990X CPU...
Thank you for your time and this great game!
We have strong Gaming PC's.
But our Base is down to 40 UPS, and the game only uses 24% of the (4 Cores, 8 Threads) CPU.
Because Factorio do not scale with more CPU Cores, it is not even possible to buy a better CPU with 8, 12, 16, 32 Cores to speed it up.
Any tipps for me, what I can do to speed up our base?
So my Questions and requests are:
Multithreading:
I know converting a Game loop from Single to Multithreading include a massive change for locks for the main data structures.
This will even lead to overhead for those locks - even using user space spinnlocks because it is not to be expected to have much locks in lock state.
But this can be avoided.
The assumption is, that a giga base is spread across a huge area or multiple surfaces.
Futher assumption is, that every entity can only interact with other entitys which are close (100 Tiles?) to other ones. For example I think an assumption/Assertion can be made, that no inserter pick from more than distance x (coose a big one - 100 Tiles?).
So the Base can be splittet in sections, and all of them updated individually, even without the need for locks.
One of the sections is the "grid" between the tiles, which need to be updated single threaded afterwards, because there could be overlaps.
That also should not break deterministic multiplayer... Because it shouldn't update the order in which you update the tiles..
Example:
So Multithread tiles:
100<x<100.000 100<y<100.000
-100<x<-100.000 100<y<100.000
100<x<100.000 -100<y<-100.000
-100<x<-100.000 -100<y<-100.000
And then serial the remaining grid...
-100<x<100 -<y<+
-<x< -100<y<100+
Can be done for 8, 12, 16 Cores as well...
Or:
Transport lines take currently about 50% of the load.
Our complete Base is belt based and no robots.
Maybe it would be easier to give each connected belt one job for a thread pool?
Dont know your data structures, but I can imagine a connected belt will be some sort of merged to one update entity...
Or:
Entity updates.
I cant image the progress update of one factory affects another? Only if there are goods finished there is interaction to import/export the items.
So the updates without creating or consuming stuff can be fully parallel?
LuaJIT:
For huge Mod, this would be a really great improvement. Currently our mods take ~8ms.
Benchmarks for LuaJIT show 25 times faster as LUA interpreter (in perfect condition).
Multithread mod:
Allow Multiple threads for heavy load mods.
Maybe as an option in the mods info.json.
It "Use Multithreading" is set to true, just put a fassade with a guard in eacht interface call in between.
This can be generated automatically and do not need to be hand written by you.
I think your c++ bindings to LUA are generated anyway?
Benchmark for Factorio
I think currently there is no Database, which CPU/RAM/... will have how many UPS.
That would allow me to compare and buy a new CPU for Factorio.
Can a benchmark be done to get such a Database?
Think some sort of really massive Gigabase would be enouh, then post UPS including used Hardware as the CPU.
I would spent a big amount for a new CPU if this would help, but I dont think a 12, 16 ... core CPU is significant faster compared our current 4 Core one..
I think it would be a huge improvement to Factorio to allow even bigger bases.
And to scale (at least a bit) with CPU count, because then players like me can just buy a bigger CPU to continue the base instead of starting a new one.
Would be a shame to use only 2% of the performance of a 64 Core Threadripper 3990X CPU...
Thank you for your time and this great game!