Page 1 of 1

Performance problems with tagging entities

Posted: Fri Aug 04, 2023 1:48 pm
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?

Re: Performance problems with tagging entities

Posted: Fri Aug 04, 2023 2:02 pm
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.

Re: Performance problems with tagging entities

Posted: Fri Aug 04, 2023 2:15 pm
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.

Re: Performance problems with tagging entities

Posted: Fri Aug 04, 2023 2:26 pm
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.

Re: Performance problems with tagging entities

Posted: Fri Aug 04, 2023 2:59 pm
by Dragony

Re: Performance problems with tagging entities

Posted: Fri Aug 04, 2023 4:28 pm
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.

Re: Performance problems with tagging entities

Posted: Fri Aug 04, 2023 5:26 pm
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.

Re: Performance problems with tagging entities

Posted: Fri Aug 04, 2023 5:42 pm
by Rseding91
This is what I get in the time usage debug option:
Untitled.jpg
Untitled.jpg (646.95 KiB) Viewed 1022 times