Page 1 of 1

Faster startup (e.g. for iterating on mod code)

Posted: Sun Dec 18, 2016 10:05 pm
by zx64
While getting my head around the modding functionality of Factorio, I couldn't help but notice just how punishing a full restart of the game can be even with an SSD, so I had a look to see if there were any options that would speed things up (e.g. lowering texture quality etc.).

I can't remember if tree mipmaps and/or trilinear filtering are on by default, but for me these two options add a significant amount of time to the time taken between creating the atlas and moving onto loading sounds:

Code: Select all

   1.318 Initial atlas bitmap size is 16384
   1.320 Created atlas bitmap 16384x5589
   1.320 Created atlas bitmap 4096x968
   1.320 Created atlas bitmap 4096x3652
  19.545 Sprites loaded
  19.546 Convert atlas 4096x968 to: trilinear-filtering
  19.584 Convert atlas 4096x3652 to: mipmap
  20.249 Loading sounds...
I also noticed there's a "cache-sprite-atlas" setting in config.ini. While I imagine this setting is unhelpful if you're changing the artwork, enabling it can significantly speed up the time it takes to start Factorio when combined with disabling both those features.

With these changes combined, i.e.:

Code: Select all

cache-sprite-atlas=true
tree-sprite-mipmaps=false
trilinear-filtering=false
the game takes significantly less time to reach the "loading sounds" stage:

Code: Select all

   1.291 Initial atlas bitmap size is 16384
   1.295 Created atlas bitmap 16384x9492
   2.506 Atlases loaded from disk cache.
   2.703 Sprites loaded
   3.391 Loading sounds...
This is after several runs with each setting, the first time after changing the settings you'll probably see it take longer to start because the game has to build the cached data.

Also having a e.g. sandbox save that you can auto-load by passing "--load-game yoursandbox" on the command line also helps from a workflow perspective since all the loading/waiting happens up front rather than having to explicitly click through the main menu each and every time.

One final startup "optimisation" I made was to replace all oggs in data\base with a short, silent file.

Before:

Code: Select all

   3.389 Loading sounds...
   5.699 Custom inputs active: 0
After:

Code: Select all

   3.403 Loading sounds...
   4.037 Custom inputs active: 0
Obviously I recommend you make a separate "development" install of standalone Factorio - the standalone version uses completely separate config/save/etc. directories which is perfect for these sorts of potentially destabilising changes that you don't want in your proper install.

Re: Faster startup (e.g. for iterating on mod code)

Posted: Mon Dec 19, 2016 5:32 am
by Nexela
Another quick tip If all you are changing is control.lua code a full restart isn't needed, simply restarting the map, or loading a save will work. Keep in a mind what events are ran when doing this though. As loading/new/upgrading existing all run different events.

Re: Faster startup (e.g. for iterating on mod code)

Posted: Mon Dec 19, 2016 7:51 pm
by ssilk
Added to viewtopic.php?f=80&t=16136 Faster start sequence / Update check / Load order

Re: Faster startup (e.g. for iterating on mod code)

Posted: Mon Dec 19, 2016 7:57 pm
by daniel34
Moved from Ideas and Suggestions to Modding discussion, as there is no actual suggestion found in the OP and most of this topic will only be relevant to modders.

Re: Faster startup (e.g. for iterating on mod code)

Posted: Tue Dec 20, 2016 2:54 am
by Mooncat
FYR, FFF #168 has mentioned that we will be able to force the game to update sprites, as well as some prototype values in runtime. Hopefully this will eliminate the need to restart the whole game.

Re: Faster startup (e.g. for iterating on mod code)

Posted: Tue Dec 20, 2016 5:23 pm
by Rseding91
Mooncat wrote:FYR, FFF #168 has mentioned that we will be able to force the game to update sprites, as well as some prototype values in runtime. Hopefully this will eliminate the need to restart the whole game.
*if* that option is still enabled in the release build it makes the entire game slower because of how it works. It's not some kind of optimization - it's simply for development.

Re: Faster startup (e.g. for iterating on mod code)

Posted: Tue Dec 20, 2016 7:18 pm
by orzelek
Rseding91 wrote:
Mooncat wrote:FYR, FFF #168 has mentioned that we will be able to force the game to update sprites, as well as some prototype values in runtime. Hopefully this will eliminate the need to restart the whole game.
*if* that option is still enabled in the release build it makes the entire game slower because of how it works. It's not some kind of optimization - it's simply for development.
Having a parameter that allows to use it for mod development would be enough I think.

Re: Faster startup (e.g. for iterating on mod code)

Posted: Tue Dec 20, 2016 10:48 pm
by zx64
How complete is the sprite atlas caching feature intended to be? e.g. it doesn't seem to properly cache if you enable treemips or filtering (see timing in my logs), but it seems like a useful thing for normal users to have on.

Re: Faster startup (e.g. for iterating on mod code)

Posted: Tue Dec 20, 2016 11:33 pm
by Rseding91
zx64 wrote:How complete is the sprite atlas caching feature intended to be? e.g. it doesn't seem to properly cache if you enable treemips or filtering (see timing in my logs), but it seems like a useful thing for normal users to have on.
It can't cache things in the mipmap, things that are filtered, or things that end up compressed so if you enable those options it's not as useful.

You don't ever need those options unless you have a slower computer that can't handle loading all of the sprites into VRAM anyway.