[1.1.70] Poor performance when large quantities of spidertrons congregate in one location

Bugs that are actually features.
jeff.s
Inserter
Inserter
Posts: 22
Joined: Thu Jan 10, 2019 10:49 pm
Contact:

[1.1.70] Poor performance when large quantities of spidertrons congregate in one location

Post by jeff.s »

If a large number of spidertrons attempt to stand in the same location, game update starts taking longer and longer.

Steps to reproduce:

Spawn 1000 spiders in a 2x2 chunk area (fully paved and free of any obstructions):

Code: Select all

for i=1,1000 do
  local x = -32 + 64*math.random()
  local y = -32 + 64*math.random()
  local e = game.surfaces.nauvis.create_entity({name="spidertron", position={x,y}, force=game.forces.player, create_build_effect_smoke=false})
end
This idles with entity update taking around 1.0ms. Now let's send all the spiders to stand in one spot:

Code: Select all

for _, spider in pairs(game.surfaces.nauvis.find_entities_filtered{name="spidertron"}) do 
  spider.autopilot_destination = {0,0}
end
As the spiders approach the location, entity update rapidly rises. It quickly peaks around 2500ms and then slowly settles down to about 1200ms.
cbhj1
Fast Inserter
Fast Inserter
Posts: 169
Joined: Tue Apr 25, 2017 2:53 pm
Contact:

Re: [1.1.70] Poor performance when large quantities of spidertrons congregate in one location

Post by cbhj1 »

I get the feeling they are all trying not to step on each other's toes, that is a lot of feet.
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 3015
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: [1.1.70] Poor performance when large quantities of spidertrons congregate in one location

Post by boskid »

Thanks for the report. I am not seeing any crashes here so this is not a bug.

Poor performance cannot be considered as a bug unless it would be a regression. Here it is one of those "player does weird things, gets weird results" things. Under the profiler i see the code spends 85% trying to find a non colliding positions and because there are a lot of entities on some of the advanced tiles, those operations take time that is linear to the amount of entities on the advanced tile which causes your experiment to effectively become something like O(N^2) which simply does not scale well.
Post Reply

Return to “Not a bug”