Page 1 of 2

[0.14.7] Lags and very low UPS in MP

Posted: Sun Sep 18, 2016 5:38 pm
by darkhog
I was trying to play Factorio with my friend today on a admittedly fairly complex map. But after I've connected to him, I've experienced a total lagfest so much that even chat/console stopped responding after a while. After having to alt+f4 the game, I've asked him to give me a copy of this map to make sure it's a network issue and not something with my computer to which he obliged. After loading it in a single player mode, it worked just fine, stable 60 fps. So the lags and fps loss had to be a network issue, which I'm reporting now.

The map in question was this one: https://mega.nz/#!uc8wSY6K!Ip7rMv_nft9m ... MypRYGccUs - so you can replicate it easily. Dunno why it barfed on me, especially since I have stable 60mbps connection.

Will link this thread to my friend so he can send any relevant info such as host settings and how the whole thing looked from his side.

Also this is my first post here. Hi.

Re: Network issue causing lagfest and low fps [0.14.7]

Posted: Sun Sep 18, 2016 5:47 pm
by Zaflis
Since i'm his hoster, here is what it looked like on my end when hosting from ingame (non-headless):
lobby.jpg
lobby.jpg (47.63 KiB) Viewed 6912 times
I don't have any lag ingame and it's 60/60 fps/ups. My own connection is 12/12 mbit. The save file is above 37Mb in size and was created during 0.13 i think, now we playing on 0.14.7.

Re: Network issue causing lagfest and low fps [0.14.7]

Posted: Sun Sep 18, 2016 6:09 pm
by Loewchen
Make a screenshot with show_time_used_percent, show_fps and show_multiplayer_waiting_statistics activated when the issue is present.

Re: Network issue causing lagfest and low fps [0.14.7]

Posted: Sun Sep 18, 2016 6:27 pm
by Zaflis
We also tried other way around by me connecting to his game. The lag was much less noticable, at least half playable. This is from my end in that case:
http://i.imgur.com/wlWEd7Q.png

He'll upload another when he joins mine.

Re: Network issue causing lagfest and low fps [0.14.7]

Posted: Sun Sep 18, 2016 6:40 pm
by darkhog
Here's mine (after connecting to Zaflis' side since when he connected to me according to him it was a nonissue, for me as a host it also wasn't any bad stuff):

http://i.imgur.com/YRliFGE.png In single player it's stable 60fps for me everywhere on this map, even in "populated" areas.

Re: Network issue causing lagfest and low fps [0.14.7]

Posted: Sun Sep 18, 2016 6:43 pm
by Loewchen
darkhog wrote:Here's mine (after connecting to Zaflis' side since when he connected to me according to him it was a nonissue, for me as a host it also wasn't any bad stuff):

http://i.imgur.com/YRliFGE.png In single player it's stable 60fps for me everywhere on this map, even in "populated" areas.
What are your hardware specs?

Re: Network issue causing lagfest and low fps [0.14.7]

Posted: Sun Sep 18, 2016 9:06 pm
by darkhog
Intel Core2Quad Q9450 @2.66GHz, 8gb ram, GF GTX 660.

But it shouldn't matter as when I run the very same map locally (single-player) I get stable 60 FPS even in busy areas such as one shown in the shot. It's most likely a network issue (and as a developer myself I know netcode can be extremely hard to do right, that's why the game I'm working on right now is single-player only).

By no means this is a deal breaker for me, the game is AWESOME, I just want it to be even better, love games like this. And since I'm a gamedev myself I try to post as much useful reports as I can.

Re: Network issue causing lagfest and low fps [0.14.7]

Posted: Mon Sep 19, 2016 1:35 pm
by kovarex
What could I do. From what you said, the network connection is a problem there, you can post the log, or show the latency info. But I guess that the internet is just too unreliable in your case. If any of you are using a wifi, switch to cable, wifi is always bad.

Re: Network issue causing lagfest and low fps [0.14.7]

Posted: Mon Sep 19, 2016 1:45 pm
by Zaflis
His screenshot shows 237ms per frame on Entity Update. Any clue to where it comes from or it could be improved?

Re: Network issue causing lagfest and low fps [0.14.7]

Posted: Mon Sep 19, 2016 1:54 pm
by Loewchen
Zaflis wrote:His screenshot shows 237ms per frame on Entity Update. Any clue to where it comes from or it could be improved?
This alone would be what you expect to see when the cpu is (significantly) too slow for the map, but as you said it handles the map fine in SP.

Re: Network issue causing lagfest and low fps [0.14.7]

Posted: Mon Sep 19, 2016 1:58 pm
by kovarex
darkhog wrote:Here's mine (after connecting to Zaflis' side since when he connected to me according to him it was a nonissue, for me as a host it also wasn't any bad stuff):

http://i.imgur.com/YRliFGE.png In single player it's stable 60fps for me everywhere on this map, even in "populated" areas.
But this screenshot shows 3.2FPS indeed, so I'm confused.

Re: Network issue causing lagfest and low fps [0.14.7]

Posted: Mon Sep 19, 2016 7:26 pm
by orzelek
Looking at stats would seem that when in multiplayer as client simulation of entities is eating up a lot more CPU power then when running in single player where all is ok. In single player entity update is well below values needed for 60fps while in multi it's really a lot.

Is the issue reproducible each time when you connect in that server/client setup?

Re: Network issue causing lagfest and low fps [0.14.7]

Posted: Mon Sep 19, 2016 8:38 pm
by Zaflis
Yes we tried 3 times. He was forced to Alt+F4 to quit the game.

Re: Network issue causing lagfest and low fps [0.14.7]

Posted: Tue Sep 20, 2016 12:30 am
by bbgun06
I'm also noticing this issue. I am using mods, but from the stats, it seems only uranium power is using a significant amount of time. I have a Core i7 920 CPU. When in single player I get 50fps/ups steadily, so I may be reaching the limit of what CPU can handle. However in multiplayer there is a massive hit to performance. Note I tested this while playing on a LAN, so I don't expect the network to be a factor.
Here is my game running in single player:
http://steamcommunity.com/sharedfiles/f ... =766761220
http://steamcommunity.com/sharedfiles/f ... =766761250
About 50ups when zoomed out, and 60 when zoomed in.

Now while hosting a game:
http://steamcommunity.com/sharedfiles/f ... =766761297
http://steamcommunity.com/sharedfiles/f ... =766761333
The FPS and UPS are about the same.

Now connected to the server over LAN:
http://steamcommunity.com/sharedfiles/f ... =766761410
http://steamcommunity.com/sharedfiles/f ... =766761451
The frame rates here aren't as steady as the others.

Finally, I've noticed a crippling issue that may be related. Every time the server auto saves, my game waits until the server is done saving before it starts. This puts it behind, and while catching up the UPS drops to 5.4. Often my game is not able to catch up, and the 'jumps' counter steadily increases. To fix it I have to pause the game. But I never get kicked for being too slow. These screenshots are about 1 second apart after an autosave, and you can see that I'm dropping farther and farther behind.
http://steamcommunity.com/sharedfiles/f ... =766765535
http://steamcommunity.com/sharedfiles/f ... =766765585
http://steamcommunity.com/sharedfiles/f ... =766765626
In the past I've waited until that counter was over 1600, but pausing allowed me to catch up. Why would the UPS go slower when catching up? I would expect it to speed up, or at least stay the same if it's CPU limited.

I've also attached some screenshots showing my CPU load while catching up. None of the cores are running at 100%, so I think the CPU is not the limiting factor.

Re: Network issue causing lagfest and low fps [0.14.7]

Posted: Tue Sep 20, 2016 12:18 pm
by orzelek
It might still be CPU problem bbgun06.
Currently game is limited to one core running the simulation. So technically it should get one core to 100% but due to core switching it gets distributed over the cores.
Since sum of those %-ages doesn't get to 100% it still looks like something in factorio is causing it to idle for some time instead of crunching numbers.
(I'd expect the sum to be over 100% easily since game can use one core for simulation and one for rendering at least)

Re: Network issue causing lagfest and low fps [0.14.7]

Posted: Tue Sep 20, 2016 4:45 pm
by Loewchen
orzelek wrote:It might still be CPU problem bbgun06.
Currently game is limited to one core running the simulation. So technically it should get one core to 100% but due to core switching it gets distributed over the cores.
Since sum of those %-ages doesn't get to 100% it still looks like something in factorio is causing it to idle for some time instead of crunching numbers.
(I'd expect the sum to be over 100% easily since game can use one core for simulation and one for rendering at least)
I am even inclined to suspect that the original issue is caused by insufficient CPU performance as well, as the symptoms are so similar. My theory would be that there is additional load in MP that will let the peer drop slightly below 60ups and then the effort to realign results in this latency-buffer-jump oscillation catastrophe.

Re: [0.14.7] Lags and very low UPS in MP

Posted: Sat Sep 24, 2016 12:43 am
by bbgun06
Correct me if I'm wrong, but I thought the server was supposed to slow down to match the client.

Re: [0.14.7] Lags and very low UPS in MP

Posted: Sat Sep 24, 2016 5:42 am
by Rseding91
bbgun06 wrote:Correct me if I'm wrong, but I thought the server was supposed to slow down to match the client.
Nope. The server runs at the speed it was told to run: 60 UPS by default. If the client can't keep up then it gets dropped eventually.

Re: [0.14.7] Lags and very low UPS in MP

Posted: Sun Sep 25, 2016 12:48 am
by Rseding91
Everything described here is just the "catching up" mechanics. If your computer can't keep up with the server you're connecting to it manifest in your game sitting forever trying to catch up with you eventually being dropped from the server if you fail to catch up.

Re: [0.14.7] Lags and very low UPS in MP

Posted: Sun Sep 25, 2016 9:31 pm
by darkhog
New info: Removing all the robot bays from the map+undecorator mod "fixed" the issue. It's not a proper fix, but just letting you know that it may be because of some bad robots ;).