Disclaimer: I’m not a pro megabase builder, I have no impressive megabase to my name and wouldn’t know how to get myself there. But I am interested in the technical details of Factorio, and so I’m interested in the UPS discussion. In short, I’m just a theory crafter testing things.
Goal/scope
The goal is to understand better what causes a design to be efficient or inefficient in terms of computations, based on what is in the design and how it’s operating.
Factorio has a huge number of ways that things can interact, not all of which are intuitive. So I certainly didn’t test everything. But I tried to cover the situations that are most relevant for me, should I finally decide to build large.
I didn’t look at belts or pipes, because they are complex and highly optimized. Moving items onto and from belts is usually the costly part, not the belt transport itself.
Some background
UPS, meaning Updates per Second, refers to the refresh rate that Factorio normally keeps at 60 Hz. This means the computer has 16.666 millisecond to calculate the next update. If this takes longer, the game slows down dropping your UPS to 59, 58… some people even play at 15 UPS. So naturally players are looking for ways to grow their factory without slowing the game. Skipping for a moment what hardware improvements (red paint) might make your computer faster, there is also a lot of advice how to build your base.
Naturally some of that advice is outdated and some of it is people helpfully repeating each other. Surprisingly, at the megabase level all major logistics systems are still viable: logibots, belts and especially trains. Beacons make things better, and inserters are a complex and necessary evil. Splitters and nuclear get more hate than anyone really deserves.
The systems are so different that depending on circumstance, one or the other might be optimal. For example, bots are great for moving short distances, bringing many different items from many different sources to many different destinations. And while the mall is not the point of the megabase, bots are fine for distributing science to labs for this reason.
But in some cases, it might be better to belt the 1-2 inputs for something straight from the producer(s), span the distance with belt, more belt and a bit of belt, and finally feed into the user(s) with some filter inserters.
Direct insertion from assembling machine to assembling machine is often shown to be effective. Trains, which are basically big chests that move, are also popular. But how to compare it, and design something? Time to measure something.
The way I’ll be thinking about it is like a budget. If you want to make 1000, 10000 or even more science per minute, you have 1 minute to do it in. Smelting ore in a furnace will cost the computer some calculation time. Getting the iron into an assembler also takes calculation time. And running the assembler will also take calculation time. For all of the things we need to do to get 1000 of each science, we have a grand total of 60 000 000 000 (60 billion) nanoseconds.
So the next question is obvious. How can you run your whole science supply chain and stay within budget? Which ways to we have to run the furnaces/assemblers/etc and which of those will get us the items we need the cheapest?
What I was missing is some hard numbers to compare these methods, as well as some context. So I tried to estimate how many nanoseconds the methods cost.
Method
I used editor extensions and no other mods for this.
To test the time, I made very basic designs to repeat 10000-100000 times, put them in the situation I wanted to measure, and checked the F4 F5 show-time-usage and show-entity-time-usage options. Then I divided by the number of times I was running the design in parallel. This is a bit rough, not everything scales linearly, but it’s good enough for me and I found some surprises.
I used my own PC, ryzen 3900x with some OK 32 GB RAM. A good PC but not Factorio optimized.
I added some pictures of how I tested it to clarify, but not everything because I'm lazy.
Results
time in ns (nanosecond) per tick that something is active. Lower is better.
- 140-190ns - Logistic Bot in the air. Increases slightly with bot speed, and with complexity (faster is still better)
- 100ns - Assembler making 1 RCU per 120s
- 108ns - Assembler making 1 RCU per 2.18s
- 106ns - Assembler making 2 cable per 2s
- 500ns - Assembler making 55 cable per 1s. I only looked at assembler class, not all entities.
- 160-230ns - Idle refinery/chemplant with only liquid input recipe. Cannot sleep, see below. Extra expensive.
- 100-110ns - Working refinery/chemplant
- None - Sleeping assembler/refinery/chemplant/centrifuge. Only if insufficient solid input.
- 108ns - Furnace smelting copper
Inserter stuff: - 440ns - Inserter looking at blue belt sushi
- 188ns - Inserter looking at grass
- 137ns - Inserter direct inserting. average cost of 26 ticks. 26 ticks per stack. Direct insertion efficiency is proven again: 26 ticks * 137 ns = 3.56 microsecond to move up to 12 items.
- 260ns - Inserter putting items on empty belt. 52 ticks for 12 item stack.
- 430ns - Inserter taking items from opposite lane, simple belt. Smarter people than I have optimized this, it's complex.
- 54ns - circuit network connection to inserter. Constant circuit network overhead on top of inserter cost. Even with no signal.
- 0 + 54ns - Inserter disabled by network
- None - Inserter dumping item on full, stalled belt
- 232ns - Same inserter, but belt is full and moving In the following situations, the inserter sleeps. This is good.
- Inserter looking at empty belt or chest
- Inserter looking at full, stalled, useless belt
- Filter inserter without filter
- Inserter holding too many items to fit in chest, wagon, rails. I read on the internet that this wastes UPS but when testing myself they always go to sleep.
- Inserter feeding Assembler/refinery/chemplant/centrifuge working but enough ingredients
- Inserter feeding Assembler/refinery/chemplant/centrifuge, full output
Sleeping buildings with liquids was surprising.
I found that a building with the following insomnia recipes cannot sleep: - Basic Oil Processing
- Advanced Oil Processing
- Solid Fuel (all 3)
- Lubricant
- Sulfur
- Oil Cracking (both)
And these can sleep, if they have 1 or more solid ingredient shortage AND outputs are empty: - Coal Liquefaction
- Sulfuric Acid
- Explosives
- Battery
- Plastic Bar
Most of the buildings will cost 100-110 ns per tick while operating, and outside of that go to sleep.
With some exceptions.
Inserters depend heavily on how you use them.
I now have most of the info I wanted to compare designs, for example is it better to have more speed beacons and more inserter actions? From crafting time and item amounts, I can now make a fair estimate.
I was surprised by the chemical recipes' behaviour, and the differences between good and bad ways to use inserters.
I was also positively surprised by in how many situations the inserter can sleep.
For very fast recipes, there seems to be diminishing return on additional speed (beacons).
I hope it is also helpful for you.