Tutorial:Diagnosing performance issues: Difference between revisions

From Official Factorio Wiki
Jump to navigation Jump to search
Line 110: Line 110:


* '''AssemblingMachine''': This isn't just assembling machines, but every building where you have to select a recipe (e.g. chemical plants, refineries, etc., but not furnaces). For this cost, the number of machine counts, not their speed. Fewer but faster machines (with beacons and modules) will cost less than many slow machines.
* '''AssemblingMachine''': This isn't just assembling machines, but every building where you have to select a recipe (e.g. chemical plants, refineries, etc., but not furnaces). For this cost, the number of machine counts, not their speed. Fewer but faster machines (with beacons and modules) will cost less than many slow machines.
* '''Inserter''': Look into "inserter clocking" to reduce this. This cost is also affected by the size of containers [https://www.reddit.com/r/Seablock/comments/14kllvp/warehouse_vs_chests_ups_testing/ (See this thread)].
* '''Inserter''': Look into "inserter clocking" to reduce this. Using containers with a large amount of slots will also negatively impact this cost [https://www.reddit.com/r/Seablock/comments/14kllvp/warehouse_vs_chests_ups_testing/ (See this thread)].
* '''Unit''': This is biters. Removing biters will remove this cost.
* '''Unit''': This is biters. Removing biters will remove this cost.


If you've ran out of things to optimize in this section, then you're just suffering from a factory that has grown bigger than your PC can handle. Congratulations!
If you've ran out of things to optimize in this section, then you're just suffering from a factory that has grown bigger than your PC can handle. Congratulations!

Revision as of 06:10, 3 September 2023

Accessing the "time usage" screen

The "Debug settings" menu with the options we need to enable

Press F4 to open the "Debug settings" menu. This will show you a variety of options. You need to enable 3 of them:

  • show-fps: This will show your FPS and UPS counter in the top right of your screen.
  • show-time-usage: This will show details of many systems of the game and how much they are impacting the performance of your game. The majority of this tutorial will be about how to decrypt this information.
  • hide-mod-guis: Sometimes, windows and buttons from mods can hide the information from show-time-usage. This option hides them so we can read everything.

Tip: To read the numbers more easily, open your map and scroll to an area you haven't explored yet, so the information is on a black background. Though beware that your zoom level and what you're currently looking at can influence your render time.

For more info on debug options and the debug settings menu, check out Debug mode.


FPS vs UPS

The first thing to look at is your FPS/UPS counter in the top right.

  • FPS stands for Frames Per Second and relates to the work your graphics card is doing to display the picture on your screen. If your FPS is low, your screen will update less frequently, but your game will continue at regular speed.
  • UPS stands for Updates Per Second and relates to the calculations needed to advance the state of your world. If your UPS is low, your game will run in slow motion. Factorio always aims to have 60 FPS and UPS.

FPS can never be higher than UPS. Which leaves you with 2 cases:

  • Low FPS, High UPS: Your problem is graphical. Go to Factorio's graphics settings and reduce some settings here, particularly the "Sprite resolution" setting. Upgrading your graphics card will help with this.
  • Low FPS, Low UPS: This is the issue in 99% of cases. Your problem is low UPS. Continue following this tutorial to figure out what could be the cause and where you can save some UPS.

Decrypting the "time usage" screen

How it works

You should see a bunch of text and numbers like this:

Time usage screen.jpg

Each line follows this format:

System name: average ms/minimum ms/maximum ms

Those numbers are in milliseconds per tick. A tick is one update step, it is for UPS what a "frame" is for FPS. Since Factorio aims for 60 ticks per second, the game has 16.667ms to calculate each tick. If it takes longer than this, then your UPS will drop below 60.

The 3 numbers for each line are the average time, minimum time, and maximum time taken by the system over the last 100 ticks.

This information is only telling you about the last 100 ticks, which is a little less than 2 seconds of gameplay. If your performance issues only happen some of the time or when you do something specific, you need to have the screen open while it is happening. If it happens too fast, you can take screenshots to read later. You can also use the "/perf-avg-frames 1000" command to increase the number of ticks considered to 1000 (or another number).


Now that you understand what this information is, look for large numbers. If you are experiencing consistent UPS issues, look at the average times. On the other hand, if you are experiencing occasional freezes or large stutters, look at the maximum times.

Remember, since 60 UPS is equivalent to 16.667ms per tick, you can think of it as 1ms of time costing you about 3.5 UPS. Anything above 1ms may be worth looking into, and anything above 5 is very significant.

When you've found some suspiciously large numbers, refer to the table below to see what the line means, whether you should worry about it, and how you can help:

Table of notable "time usage" lines

Name Explanation How to solve
Last save This is how long your last save took, and is not related to UPS -
Frame cycle This is the total time it took to render a frame. This can't ever be lower than 16.667ms. This doesn't give you any information that your UPS counter wouldn't tell you. -
Wait For Update This is the time your GPU waited for the world update. This should be roughly equal to the "Update" line below. Don't worry about it. -
Render preparation (and sub-lines) This is related to the rendering of the frame on your screen, costing FPS. This will increase if you zoom out or if you're looking at a particularly busy part of your factory. Lower graphical settings.
Render (and sub-lines) Same as "Render preparation". -
Flip[on] I'm not entirely sure what this is, but it's related to Vsync. Try toggling Vsync on or off.
Sleep When it took less than 16.667ms to prepare a tick, the game sleeps. This is normal and good. If this is above 0, then congrats, you have 60 UPS. -
Update This is where we get into the meat of things. The Update line is purely about the world tick and not about rendering the screen frame. This is usually where most of your frame time will be. Look at the sub-lines to get more details.
Game update The core systems of the game. Look at the sub-lines to get more details.
Circuit networks Self-explanatory. Use fewer combinators 🙃. Realistically this shouldn't be a big performance hog unless you're building a ray-tracer.
Transport lines Related to belts. Optimizing belt UPS is a dark art that is out of scope of this guide. Check out /r/technicalfactorio.
Fluid manager Self-explanatory. Reduce your amount of pipes. Use underground pipes (2 fluid entities) wherever they could replace 3 or more pipes. Replace nuclear power with solar power.
Heat manager Self-explanatory. Replace nuclear power with solar power.
Entity manager Related to "entities", which are a lot of things. This will usually be the largest number in your list. To dig deeper into this, continue to the next part of the tutorial.
Electric networks Self-explanatory. This is particularly affected by the number of different electric networks, not their size. A single electric pole connected to nothing else is an electric network and is a performance cost. A mod like Puppy's UPS Tools can help you find all your small or isolated electric networks so you can connect them or remove them.
Trains Self-explanatory. Use fewer but bigger trains. Use a train network optimized for UPS, which is also a dark art, out of scope of this guide.
Chart update Related to refreshing chunks of your map, usually done by radars. Reduce your number of radars.
Lua garbage incremental This is related to mod scripts, but it's hard to find which is responsible. First, try and solve any issue in the "Script update" lines. If there is nothing there but you still have a high "Lua garbage incremental" cost, you will have to remove mods 1-by-1 until you find the culprit.
Script update The time taken to run mods' Lua scripts. Each "mod-XXX" sub-line is the cost to run the scripts of a particular mod. Uninstall offending mods. If the performance is worse than expected, consider filing a bug with the mod's author.

Hidden mod costs

A mod's line on the "Script update" section is not always the entirety of its cost! Mods can indirectly affect the time of core systems. For example, a mod that makes trains repath a lot (such as LTN, or SE's space elevator) might increase the Trains cost, and a mod that creates a lot of different electric networks (such as the Ruins mod) would increase the Electric network cost.

Digging deeper with the "entity time usage" screen

The entity time usage screen

Return to the "Debug settings" menu, enable show-entity-time-usage and disable show-time-usage (It will get in the way).

On this screen, the "Entity manager" cost from the previous screen is split between each class of entity. The first number of each line is the time cost this tick, the second number is the number of active entities of this class.

Most lines are self explanatory, but a couple notes:

  • AssemblingMachine: This isn't just assembling machines, but every building where you have to select a recipe (e.g. chemical plants, refineries, etc., but not furnaces). For this cost, the number of machine counts, not their speed. Fewer but faster machines (with beacons and modules) will cost less than many slow machines.
  • Inserter: Look into "inserter clocking" to reduce this. Using containers with a large amount of slots will also negatively impact this cost (See this thread).
  • Unit: This is biters. Removing biters will remove this cost.

If you've ran out of things to optimize in this section, then you're just suffering from a factory that has grown bigger than your PC can handle. Congratulations!