Factory Inspector


Measures per-recipe consumption and production for all items. Want to know which recipe is consuming all your green circuits? This mod can tell you. Designed for complex modded games where each item has many producers and consumers.

Utilities
12 days ago
1.1
3.64K

FAQ

Q: Help! This mod slowed down my game, or makes it pause every few seconds. What gives?

This mod is computationally intensive. Every tick, it needs to:

  • check if any entity has changed activity, including but not limited to: had its recipe changed, switched to a different fuel, run out of minable resources, etc.
  • check if any entity has produced something, and update internal records.

Updating 1000+ assembling machines, mining drills and furnaces per tick is too expensive, so the approach taken is to update batches of X entities per tick to spread the processing load. On a given tick, the mod will choose the next batch to process, fetch the entities in question, make the necessary updates and save the data. Each batch might have only a few tens of entities in it.

The mod's performance management is a tradeoff between small batches, which are quick to process and less likely to cause a stutter on the tick the processing occurs, and large batches, which are expensive on the tick in question but can get through the base's entities much faster.

There are multiple batching systems used in the mod:

  • The global entity collection uses a low batch size. This collection governs how often the mod checks for recipe and fuel source changes on each entity it's aware of. In general, it doesn't matter if the game only responds to recipe changes every 30-100s
  • Assembling machine and furnace production checks uses a medium batch size. Assembling machines have a propery called "products_finished" so it doesn't matter if we "miss" a craft, but if it takes 10s+ to analyse the entire factory, the mod loses accuracy and becomes less useful.
  • Mining drills results recording uses a large batch size. Mining drills don't have products_finished so mining drills that cycle very fast will cause the mod to "miss" crafts and therefore estimate the drill's production with less precision. To maintain accuracy, it's usually necessary to process all of the base's mining drills every second (60 ticks)

More on mining drills

It's likely that even large batches, with batches processed very often, won't be enough for modded games or games with very fast mining speed due to modded entities or very strong modules.
To be clear: the mod is unlikely to track produced or consumed resources accurately from mining drills if the mining cycle time is less than 0.5 seconds.

Checking for new entities

To add a final layer of computational expense, the mod also needs to periodically check for new entities being added that did not fire an onBuiltEntity event.
This typically happens when other mods create entities via script.
Some common mods do not fire https://lua-api.factorio.com/latest/events.html#script_raised_built which would prevent the need for this additional check.

The only option to deal with this is to scan every entity on the map, compare it with the mod's internal records and add any entities not present internally. This activity cannot be batched and is currently hardcoded to run every 60 seconds. If your experience is normally smooth but stutters every 60 seconds, then it's likely being caused by the "missing entity check".