Page 1 of 1

Game performace drops with chunks explored + my mod [10.2]

Posted: Mon Jul 07, 2014 12:27 am
by Rseding91
Using: Factorio 10.2 - note this doesn't seem to happen on 0.9.8

I'm attempting to track all water bodies generated in the world by chunk and link them if they connect. Right now the mod does that but I'm having a strange issue where the game's performance drops off quickly with the more chunks explored.

Now, I expect it to take longer to generate chunks due to the water-body checking I'm telling it to do but even after it's finished chunk generation and background chunk generation the game still lags massively compared to without the mod.

The mod literally only executes code during game first-launch and chunk generation: I have no idea what's causing the lag and would appreciate any help.

Simply install the mod and generate a new world - turn the game speed up to allow background chunk generation to do its thing or explore a decent amount and watch the "Update Time" on the debug screen. It climbs steadily even though the "Script Update" section shows the mod never uses over 0.2 MS(while exploring)/0.06 (on average when background generation runs) and nothing once background chunk generation is done.

https://www.dropbox.com/s/ep4dae8r6wgjc ... acking.zip

Re: Game performace drops with chunks explored + my mod [10.

Posted: Mon Jul 07, 2014 8:22 am
by Rahjital
How much data are you storing? I've only taken a quick look at the mod and its complex code, but it appears you are storing enormous amount of data, including all the water tiles generated. If that's really what you do, you should try to reduce the amount of stored data as much as possible, very high memory usage can slow down Lua significantly.

Re: Game performace drops with chunks explored + my mod [10.

Posted: Mon Jul 07, 2014 2:11 pm
by Rseding91
Rahjital wrote:How much data are you storing? I've only taken a quick look at the mod and its complex code, but it appears you are storing enormous amount of data, including all the water tiles generated. If that's really what you do, you should try to reduce the amount of stored data as much as possible, very high memory usage can slow down Lua significantly.

It stores the x/y of each water/deepwater tile in the game that's generated. Generating roughly 40x40 chunks is only 9~ MB worth of data it holds - hardly large.

The thing is: it doesn't lag in Factorio 0.9.8 - only 10.2 which means LUA can easily handle the stored data and to believe it's a bug in 10.2.

Neither the "Script Update" section, the garbage cleanup section or the mod its self says it's causing any extra load on the game - the game just slows down. It's odd.

Re: Game performace drops with chunks explored + my mod [10.

Posted: Mon Jul 07, 2014 6:26 pm
by Rahjital
Lua has a noticeable overhead for variables and additional one for global ones, which means storing as little as possible is always preferable. You are right that it not being a problem in 0.9.8 almost certainly means it's a Factorio-based bug. It may be something related to the save file changes implemented, something that only happens when a lot of data is stored in the glob table. It's a good thing you've submitted it as a bug, but I'm afraid there's nothing else to be done.

Re: Game performace drops with chunks explored + my mod [10.

Posted: Fri Jul 11, 2014 11:28 am
by ssilk
Very off topic note (or not?): From my experiments with the Lua2Wiki generator I write I can say, that Lua is significantly slower than PHP, when it is going to handle large amounts of variables. This matches also very good with this benchmark: http://onlyjob.blogspot.de/2011/03/perl ... a-tcl.html

On the other hand, when it is going about pure calculations, Lua is of course faster: http://www.timestretch.com/article/mand ... _benchmark

Other links:
http://www.unlimitednovelty.com/2012/06 ... -perl.html
http://lua-users.org/wiki/LuaComparison
http://benchmarksgame.alioth.debian.org ... calc=chart