Page 1 of 1

[2.1.12] Performance regression from 1.1 with calculate_tile_properties

Posted: Tue Jul 21, 2026 5:26 pm
by darkszero
In Nullius, shooting an Arboriculture drone makes numerous calls to LuaSurface.calculate_tile_properties. The code that does so remained untouched from what it was at 1.1 era, where it ran fast enough to not cause a significant lag spike.

In latest 2.0, and also latest 2.1, this causes a massive lag spike that I've traced down to the `calculate_tile_properties` api call, which is called 200+ times. I know it's not ideal. I have a change made to minimize this to one call with 16 points and I interpolate the rest which is a lot faster, but I think it was still rather expensive.
Someone ran a C++ level profiler and it seems most of the time is spent in CompiledMapGenSettings::createContext.

You can use the attached save file with latest 2.0 and mods from the mod portal. To the far south there's a spidertron next to a character, there's a recent ping for it. Use that spidertron to shoot the drone at your feet and you'll get the lag spike. You can probably mouse over the body and press U to take it to use more easily.

The same save with the WIP 2.1 port of nullius I've attached can be used to load on Factorio 2.1.12.

Re: [2.1.12] Performance regression from 1.1 with calculate_tile_properties

Posted: Tue Jul 21, 2026 7:25 pm
by zhuyifei1999
To clarify regarding CompiledMapGenSettings::createContext:

In 2.0 and 2.1 it is called from luaSurface::luaCalculateTileProperties. This function calls into CompiledMapGenSettings::addDefaultControlSettingConstants which iterates on every TilePrototype, EntityPrototype, and DecorativePrototype (and others but they have negligible cost), and calls CompiledMapGenSettings::addFsrControlSettingConstants, which performs lots of std::map operators, where the vast majority of time in this lua wrapper is spent.

In 1.1, the call site from luaSurface::luaCalculateTileProperties -> CompiledMapGenSettings::createContext is not there. I did not profile 1.1 but I assume it is simply not called at all within this lua wrapper.

Re: [2.1.12] Performance regression from 1.1 with calculate_tile_properties

Posted: Wed Jul 22, 2026 2:28 pm
by Rseding91
Thanks for the report. I found some things to optimize however the noise-logic rework that happened in 2.0 means this logic is always going to be slower than 1.1. It's intended usage is you make a list of positions you want the info for and then call it once - it looks like the mod usage is calling it per-position it wants info for.