Page 2 of 2

Re: [0.15.x] Severe lag and lag spike issues

Posted: Tue May 16, 2017 11:56 pm
by MagmaMcFry
Okay, I've checked out the save and Factorissimo is also a bit at fault, although that's easily fixed.

There are three important factors to your lag: Factorissimo, Vanilla Loaders, and something else.

Factorissimo uses 3-4 milliseconds per tick because you're using it wrong. Extremely fast belt connections to factory buildings are horrible for your UPS, because the faster the belt, the more often Factorissimo needs to check it for new items. Instead, use chest connections, set to transfer mode, and connected to the belts with loaders. This will shrink Factorissimo's processing time to basically nothing, because chest connections are updated very slowly and can be made to update even slower.

Vanilla Loaders has absolutely horrible code regarding transport to and from trains. Please change up all your train loading and unloading stations to not use loaders directly from trains. Put a chest buffer in between, filled with an express stack inserter or something, and attach the loaders to that.

Thirdly, the reason that your map is slower in multiplayer is that there is an absurd amount of CRC checking going on (that only needs to run in multiplayer because this is how the game tests for desyncs). Maybe it's because your map is just that large, maybe it's because there's some mod with a memory leak (it's not Factorissimo), maybe both. I don't know much about how Factorio does the CRCs.

Re: [0.15.x] Severe lag and lag spike issues

Posted: Wed May 17, 2017 2:45 am
by Rseding91
xBlizzDevious wrote:
orzelek wrote:If looking at stats game processing is below 13ms and UPS/FPS starts dropping then it might be something to investigate for devs.
Especially that it's a difference between single and multiplayer.

If detailed timings show that Factorissimo2 is using more script time in multiplayer then single that might be something for mod author to look at.

Both of those cases seem complicated :)
I would note that even on SP I'm running sub 60 FPS/UPS, hovering around 45-50. Local MP is about 30.
Not exactly scientific testing, but I opened the game up in local multiplayer, showed time-usage and then waited ten seconds and took a screenshot.
Then I saved, exited and loaded the game up as single player, waited ten seconds and took a screenshot. Here are the results:

SP:
Multiplayer Time Usage.png


Local MP:
Single Player Time Usage.png

Not exactly sure what I'm looking for, but I can see that there's a 30% drop in performance when you load MP.
Can you upload your save file and mods? 8 MS for CRC is insane.

Re: [0.15.x] Severe lag and lag spike issues

Posted: Wed May 17, 2017 4:58 am
by Nexela
xBlizzDevious wrote:I've just uploaded the save and all mods to the bug reports forum as I was having another bug. viewtopic.php?f=7&t=47735&p=275371#p275371
You can use the files attached there to test. Simply load in single player, see how smooth it runs, then load in local multiplayer and see how much worse it runs. Remove Factorissimo2 and load local MP again and it's running much more smoothly. There is always the fact that there are several hundred furnaces running inside those factories that disappeared but I don't think they'd cause a 30% performance drop. Thanks for looking into it.

Additionaly there is a loader re-write in the works that is slightly better, but loaders where never designed to work with trains so lots of loaders and lots of trains is still a bad combination.

Re: [0.15.x] Severe lag and lag spike issues

Posted: Wed May 17, 2017 5:50 pm
by xBlizzDevious
Nexela wrote:-snip-
Additionaly there is a loader re-write in the works that is slightly better, but loaders where never designed to work with trains so lots of loaders and lots of trains is still a bad combination.
Sounds useful. Is there a better loaders mod around (that I can hack green and purple versions in) or is the rest of the code fine and I just need to not use them at stations?


Rseding91 wrote:-snip-
Can you upload your save file and mods? 8 MS for CRC is insane.
OP of this thread has them: viewtopic.php?f=7&t=47735&p=275371#p275371
Just don't switch on that combinator in the preview picture!
MagmaMcFry wrote:Okay, I've checked out the save and Factorissimo is also a bit at fault, although that's easily fixed.

There are three important factors to your lag: Factorissimo, Vanilla Loaders, and something else.

Factorissimo uses 3-4 milliseconds per tick because you're using it wrong. Extremely fast belt connections to factory buildings are horrible for your UPS, because the faster the belt, the more often Factorissimo needs to check it for new items. Instead, use chest connections, set to transfer mode, and connected to the belts with loaders. This will shrink Factorissimo's processing time to basically nothing, because chest connections are updated very slowly and can be made to update even slower.

Vanilla Loaders has absolutely horrible code regarding transport to and from trains. Please change up all your train loading and unloading stations to not use loaders directly from trains. Put a chest buffer in between, filled with an express stack inserter or something, and attach the loaders to that.

Thirdly, the reason that your map is slower in multiplayer is that there is an absurd amount of CRC checking going on (that only needs to run in multiplayer because this is how the game tests for desyncs). Maybe it's because your map is just that large, maybe it's because there's some mod with a memory leak (it's not Factorissimo), maybe both. I don't know much about how Factorio does the CRCs.
The lag was an issue before I installed loaders and so when I got around to installing loaders, I didn't think to update the factories with them. I haven't touched those factories for quite some time, actually. Good to know that I've helped you find a minor issue!

1. Shame that I can't run things this way, but then I do have to cope with the limitations.
2. Also a shame, but I can sort that. I was using Burny's Station Blueprint Creator or whatever it was called so I'll just go back to that.
3. Hopefully Rseding91 can figure that out. I'm guessing it's a mod at fault.

Re: [0.15.x] Severe lag and lag spike issues

Posted: Sun May 21, 2017 3:22 pm
by xBlizzDevious
Rseding91 wrote:-snip-
Had any luck figuring this out?

Re: [0.15.x] Severe lag and lag spike issues

Posted: Tue May 23, 2017 8:47 pm
by xBlizzDevious
I have info to add:

My friend and I were working on the server to sort out the factory buildings and transition them to chests, however, ended up deciding that we would just build a large layout furnace setup in the open world.

Since 0.15.13 just came out, I updated several mods and decided that Factorissimo2 didn't need to be in the list anymore. Simply by removing Factorissimo2 from the game, that CRC figure went from 8-9.5ms down to 3-4ms.

I can't guarantee that the update to 0.15.13 did or did not have anything to do with it, but I was lagging before the crashes caused by other mods and now the game is flawless. @MagmaMcFry any ideas? Would you like a new copy of the save?

Re: [0.15.x] Severe lag and lag spike issues

Posted: Wed May 24, 2017 12:22 pm
by MagmaMcFry
Now that's weird. I did try disabling all mods except Factorissimo and the mod that added the faster belts when I messed with your old save, and the CRC went down from 10ms to ~0.5 ms, so I thought Factorissimo couldn't be causing all those CRC checks.

Re: [0.15.x] Severe lag and lag spike issues

Posted: Wed May 24, 2017 5:35 pm
by xBlizzDevious
MagmaMcFry wrote:Now that's weird. I did try disabling all mods except Factorissimo and the mod that added the faster belts when I messed with your old save, and the CRC went down from 10ms to ~0.5 ms, so I thought Factorissimo couldn't be causing all those CRC checks.
Interesting. The faster belts is just Bob's Logistics that I've removed all the other stuff from and tweaked a couple of little things. Unless belts cause that CRC thing to go up, I wouldn't see that being the cause.

Either way, here's a new copy if you're wanting to check it out.

Re: [0.15.x] Severe lag and lag spike issues

Posted: Wed May 24, 2017 8:03 pm
by Rseding91
The CRC time is spent saving electric network info last-value from each electric network that exists in the game. Because you're using a mod that makes a ton of isolated electric networks that means it spends a ton of time going over all the different networks.

Looking at it as well, Factorissimo and vanilla loaders appear to be calling get_transport_line *way* too often instead of just caching the transport lines once and re-using them. That could save a ton of time as well.

Virtually every object gotten back from the game can be cached and saved - transport lines are no exception.

Re: [0.15.x] Severe lag and lag spike issues

Posted: Thu May 25, 2017 5:44 pm
by xBlizzDevious
Rseding91 wrote:The CRC time is spent saving electric network info last-value from each electric network that exists in the game. Because you're using a mod that makes a ton of isolated electric networks that means it spends a ton of time going over all the different networks.

Looking at it as well, Factorissimo and vanilla loaders appear to be calling get_transport_line *way* too often instead of just caching the transport lines once and re-using them. That could save a ton of time as well.

Virtually every object gotten back from the game can be cached and saved - transport lines are no exception.

Good to know. Thanks for looking into it.

Which mod is it that's creating all of the electric networks? Other than Factorissimo (which is now gone) I haven't got anything else - as far as I'm aware - that adds separate networks.

I'd also note that Vanilla Loaders is now gone - I've replaced it with Loaders Redux. I don't know how the code works so the "get_transport_line" bit is unknown to me but that'll be useful for the modders who do know.

Re: [0.15.x] Severe lag and lag spike issues

Posted: Sat Oct 14, 2017 5:29 am
by wolfling
I'm also FPS having issues with multi-mods including Factorissimo2... almost every connection is either through chests or pipes... but I think we have a lot of recursion... did we break the mod?
Right now I have to pause the game, then once I unpause I get about two seconds before unplayability sets back in and I have to repause to do any more.
Incidentally, we only have one active train and it's using pumps not loaders, though there is a station under construction with 42 loaders but it isn't running yet.
Is this all I need to send or is there more? (I'm playing latest stable on Steam.)

Re: [0.15.x] Severe lag and lag spike issues

Posted: Sat Oct 14, 2017 11:05 am
by Loewchen
wolfling wrote:I'm also FPS having issues with multi-mods including Factorissimo2...
That is the standard client too slow for server issue, see performance issue section in local FAQ.