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

Place to get help with not working mods / modding interface.
Post Reply
Rseding91
Factorio Staff
Factorio Staff
Posts: 13239
Joined: Wed Jun 11, 2014 5:23 am
Contact:

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

Post 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
If you want to get ahold of me I'm almost always on Discord.

Rahjital
Filter Inserter
Filter Inserter
Posts: 435
Joined: Thu May 29, 2014 10:44 am
Contact:

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

Post 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.

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

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

Post 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.
If you want to get ahold of me I'm almost always on Discord.

Rahjital
Filter Inserter
Filter Inserter
Posts: 435
Joined: Thu May 29, 2014 10:44 am
Contact:

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

Post 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.

User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12888
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

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

Post 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
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...

Post Reply

Return to “Modding help”