kyranf / robotarmyfactorio

A mod to add robot troop units and perhaps associated support buildings and items to produce and control them.
MIT License
35 stars 11 forks source link

Memoryleak and Server-side hiccups when directly commanding bots #139

Open blubFisch opened 6 years ago

blubFisch commented 6 years ago

Hi,

Tried a 2v2 with this nice mod, but we had some performance issues:

  1. The server memory increased to 10 GB
  2. Whenever we tried to use the "Droid Squad command tool", the server would not respond for a half second or so.
  3. Additionally, the server would not respond sometimes even when we didn't use the command tool. This kept happening after we disabled to mod though, but not after we started a new game.

Here is the save: https://chomarxy.de/nextcloud/index.php/s/q0XgtRBFl3rNI09

Cheers Nils

kyranf commented 6 years ago

Thanks. i'm downloading the zip now. was the mod heavily used, or just tinkered with a little bit? Was there hundreds/thousands of squads created? So what I am asking is for a small description of how the mod was used so I can try to look at what aspects of the mod may cause it.

It sounds like there was a very very large amount of squads generated and the logic for-loops were getting way too big, and global tables were getting very big.

ChoMar05 commented 6 years ago

Hi,

Thanks for the Reply, im one of the other Players. The Mod was used over a longer period of time, we started building bots early and from the Progression of the Game you can see we arent in endgame, but there was quite some time to build bots. As for Creation, I think about 100, maybe 200 Squads created, but not in use - most of them destroyed by biters.

kyranf commented 6 years ago

@ChoMar05 Thanks. That isn't an unusual amount, it's pretty low really. I will look at the mod list for the save game, there might be other reasons (like a huge amount of other forces generated by the other mods) which may slow down my mod's loop times and also cause bloat in the global tables. I do a lot of "for each force. .. loop through and process.. " style of code

ChoMar05 commented 6 years ago

Only other mod was Nanobots, that one shouldnt cause said Problems. One question: Is the Amount of Squads CREATED important or the amount IN USE? And another thing: Is there any point where the Server would wait for a Response from the Client that could slow things down, is rather large or anything that could be caused by a shitty connection of a client?

kyranf commented 6 years ago

because of the lockstep algorithm Factorio uses and the ultra precise requirements of the simulation, if anyone has a shit computer and can't run the mod's logic (or the game in general) very quickly, they will slow down the whole server...

There is nothing explicit in the mod which is large and needs any specific waiting, or any specific server/client stuff. The mod is run by each client, and it should be the same result on everyone's game otherwise it'd desync.

The squads CREATED vs squads IN USE is not necessarily a performance issue, but rather could lead to memory bloat as the tables get larger. The indexing method of Lua means that you can quickly look up a value in a table, but iterating through the table to find valid table entries can be a performance hog after a while. I'm not sure yet if that's what is happening. It might be useful for me to try to print the lengths of each major table used in my mod, to see if any have become absolutely huge for no reason

ChoMar05 commented 6 years ago

No Shitty PCs (I think) and no Desyncs. Just someone with Shitty Internet.

kyranf commented 6 years ago

If someone is slowing down I think they will just get the catch-up thing or get booted from the game. Nothing should really slow the server down as long as the other players are all fine.

blubFisch commented 6 years ago

Any progress? :-)

kyranf commented 6 years ago

nope :-(