Performance problems with tagging entities

Place to get help with not working mods / modding interface.
Post Reply
Dragony
Long Handed Inserter
Long Handed Inserter
Posts: 77
Joined: Sun Jul 09, 2017 8:13 pm
Contact:

Performance problems with tagging entities

Post by Dragony »

I am reporting this performance issue not as the author of the mod.

The mod Panodon Alien Life uses map tags for showing actual positions of caravans (replacements for trains not depending on rails).

The call used seems to be extremely slow (30ms for 50 calls).

Their Changelog shows:

"removed caravan map tags. this results in a 15x UPS improvement. for some reason that API call is extremely laggy"

Source: https://github.com/pyanodon/pyalienlife ... 869030c133
Repo: https://github.com/pyanodon/pyalienlife

Since it is quite important to see where your "trains" are, this would be serious downgrade. I wonder if it is just a bug in your internal API and you could fix it?

Rseding91
Factorio Staff
Factorio Staff
Posts: 13239
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Performance problems with tagging entities

Post by Rseding91 »

Thanks for the report. Destroying chart tags is an O(N) operation based on the number of tags on that chunk. So destroying tags every time every one of the entities moves slightly will be very expensive.

Tags were designed from the start to be stationary (one of the reasons there's no current way to move them) and to live for long periods of time. I don't see that changing any time soon.

Trains already render on the map unconditionally so I don't see the reason to also have a tag following them around. There's also an entire GUI dedicated to showing every train in the game.
If you want to get ahold of me I'm almost always on Discord.

Dragony
Long Handed Inserter
Long Handed Inserter
Posts: 77
Joined: Sun Jul 09, 2017 8:13 pm
Contact:

Re: Performance problems with tagging entities

Post by Dragony »

Just to clarify a few things in case you got me wrong.

The entities are train replacements. In fact they are like friendly biters with extra graphics having an inventory and accepting commands. So you can have all sort of animals (aerials can even fly over oceans) having an inventory and order them to fly there, load items, fly there, unload items etc. Just like trains, but they don't use the train api.

The update takes place only once per second. So if you have 50 animals, every second there will be 50 api calls, which cause a delay of 30ms on that frame, which manifests in a slight lag every second. They dont call it every frame or on every update. Only if it's normal for a "draw tag" call to take nearly 1ms, then there is nothing to be done except for the devs of the mod having to load balance. It just seems to be quite long for a simple "draw icon" call imho.

User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 2253
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: Performance problems with tagging entities

Post by boskid »

If you want an accurate answer what exactly is slow, please provide an easy to use save file with all required mods to reproduce the issue.

-- edit:
When using the py alienlife (2.1.7) mod, i placed 3200 of the "caravan" entities and they were updating their chart tags every second, update time of pyalienlife was peaking at 45ms.

Dragony
Long Handed Inserter
Long Handed Inserter
Posts: 77
Joined: Sun Jul 09, 2017 8:13 pm
Contact:

Re: Performance problems with tagging entities

Post by Dragony »


Rseding91
Factorio Staff
Factorio Staff
Posts: 13239
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Performance problems with tagging entities

Post by Rseding91 »

I loaded the save and it's using at most 8 MS, I then un-zipped the mod and commented out the chart tag and it made zero difference in performance. So what ever the time is spent in that mod; it's not the chart tags.
If you want to get ahold of me I'm almost always on Discord.

Dragony
Long Handed Inserter
Long Handed Inserter
Posts: 77
Joined: Sun Jul 09, 2017 8:13 pm
Contact:

Re: Performance problems with tagging entities

Post by Dragony »

Hmm ok thank you for looking into it. I will forward this to the developer. Here I have 33ms when pressing F5, but maybe that is for different reasons.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13239
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Performance problems with tagging entities

Post by Rseding91 »

This is what I get in the time usage debug option:
Untitled.jpg
Untitled.jpg (646.95 KiB) Viewed 746 times
If you want to get ahold of me I'm almost always on Discord.

Post Reply

Return to “Modding help”