Some things I tested for UPS

Clever and beautiful constructions, bigger than two chunks
- Defense: killing biters as an art
- Castles, Throne Rooms, Decorations (comfortable living in the Factorio World)
- Main Bus Concepts
- Modular Systems, Factory Streets, show how all works together
- Megabases
Please provide us with blueprints or saves, if that makes sense of course.
Forum rules
Clever and beautiful constructions, bigger than two chunks
subjectivelyimproved
Manual Inserter
Manual Inserter
Posts: 3
Joined: Wed Aug 09, 2023 9:26 pm
Contact:

Some things I tested for UPS

Post by subjectivelyimproved »

Hi guys, I tested some things and I’d like to share my findings with you.
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)
    bots.png
    bots.png (1.09 MiB) Viewed 5476 times
  • 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
    inserter looking at sushi.png
    inserter looking at sushi.png (263.58 KiB) Viewed 5476 times
  • 188ns - Inserter looking at grass
    inserter looking at grass.png
    inserter looking at grass.png (14.78 KiB) Viewed 5476 times
  • 137ns - Inserter direct inserting. average cost of 26 ticks. 26 ticks per stack.
    direct insert.png
    direct insert.png (67.87 KiB) Viewed 5476 times
    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.
    inserter from belt.png
    inserter from belt.png (74.37 KiB) Viewed 5476 times
  • 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
    inserter to stalled belt.png
    inserter to stalled belt.png (115.41 KiB) Viewed 5476 times
  • 232ns - Same inserter, but belt is full and moving
    inserter to full belt.png
    inserter to full belt.png (112.27 KiB) Viewed 5476 times
    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
Conclusion
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.
coppercoil
Filter Inserter
Filter Inserter
Posts: 502
Joined: Tue Jun 26, 2018 10:14 am
Contact:

Re: Some things I tested for UPS

Post by coppercoil »

AFAIK timings are not linear, they also depends on hardware: CPU speed, RAM throughput, CPU cache size etc.
subjectivelyimproved
Manual Inserter
Manual Inserter
Posts: 3
Joined: Wed Aug 09, 2023 9:26 pm
Contact:

Re: Some things I tested for UPS

Post by subjectivelyimproved »

coppercoil wrote: Thu Aug 10, 2023 9:48 am AFAIK timings are not linear, they also depends on hardware: CPU speed, RAM throughput, CPU cache size etc.
So the second part of what you say makes sense to me, a different computer would have different performance. And probably some stuff is more dependent on memory/cache while other stuff is more dependent on processor speed.
I have no way to test that, so I didn't. The relative performance on my system is at least something.

But I don't understand the first part of what you said.
What do you mean by not linear? Does doubling the number of entities not double the calculation time?
User avatar
disentius
Filter Inserter
Filter Inserter
Posts: 694
Joined: Fri May 12, 2017 3:17 pm
Contact:

Re: Some things I tested for UPS

Post by disentius »

subjectivelyimproved wrote: Thu Aug 10, 2023 11:01 am
What do you mean by not linear? Does doubling the number of entities not double the calculation time?
No.because with big builds, not all entities are in the same state for the same amount of time.
Btw, factorio has a benchmark function that output exact timings. See https://wiki.factorio.com/Command_line_parameters
The UPS guys hang out at the technical factorio reddit, there you can find a lot of info too. https://discord.gg/Vh4wP8yT
subjectivelyimproved
Manual Inserter
Manual Inserter
Posts: 3
Joined: Wed Aug 09, 2023 9:26 pm
Contact:

Re: Some things I tested for UPS

Post by subjectivelyimproved »

Thank you!
Post Reply

Return to “Medium/Big/Gigantic Sized Structures”