Page 1 of 3

[0.17.52] CPU pegged and high lag even on menu screen

Posted: Tue Jun 25, 2019 1:29 pm
by linearj
On my Linux desktop system (12 CPU, 64G memory), 0.16 always ran fine. I was finally able to install the update yesterday, but the game is extremely laggy and pegs the CPU even on the initial menu screen. Mousing over the buttons takes almost a second for the button highlight to change to the new one. It takes 1-3 seconds after clicking a button to move onto the next screen.
Running top before starting, the system is idle and load is down below 0.1. Once I start Factorio, it pegs the CPU and stays there.
I then went back and started my 0.16 install, and it still works fine. So, it should not be that something else on the system is eating resources. 0.16 still runs fine, on 0.17 the lag makes the game unplayable and menus almost unusable.

My Linux laptop (8 CPU, 16G) works fine for both 0.16 and 0.17. On starting 0.17, the CPU is pegged until shortly after the menu screen. I don't see any lag issues and was able to play several hours yesterday.

I have attached logs from both my laptop and desktop for comparison. The "install" should be identical on both systems, as I used rsync to copy the install from the desktop to the laptop.

Re: [0.17.52] CPU pegged and high lag even on menu screen

Posted: Tue Jun 25, 2019 1:44 pm
by Oxyd

Code: Select all

   0.323  [0]: 0 - {[0,0], 2560x1440, SDL_PIXELFORMAT_RGB888, 0Hz}
   0.323  [1]: 1 - {[0,1440], 2560x1440, SDL_PIXELFORMAT_RGB888, 0Hz}
   0.323  [2]: 2 - {[2560,0], 2560x1440, SDL_PIXELFORMAT_RGB888, 0Hz}
   0.323  [3]: 3 - {[2560,1440], 2560x1440, SDL_PIXELFORMAT_RGB888, 0Hz}
0Hz doesn't sound right. Does anything change if you turn VSync off in Settings → Graphics?

Re: [0.17.52] CPU pegged and high lag even on menu screen

Posted: Tue Jun 25, 2019 1:49 pm
by linearj
Do you mean turn off "Wait for VSync" ?

If so, unfortunately, it did not. I started the game, went to settings->graphics, unchecked "Wait for VSync", clicked Confirm, Back, and then Exit. I then restarted the game. Still has the same lag. Checked the setting and verified it was indeed off.

Updated log attached.

Re: [0.17.52] CPU pegged and high lag even on menu screen

Posted: Tue Jun 25, 2019 1:52 pm
by linearj
Oh, and before you ask, "lspci -v" of video cards attached.

Re: [0.17.52] CPU pegged and high lag even on menu screen

Posted: Tue Jun 25, 2019 2:10 pm
by linearj
Been messing with it. Tested a hypothesis: on my laptop, CPU is pegged on startup, but shortly after it reaches menu screen, it drops down to zero. I figured, maybe something is just taking longer on the desktop.

So, started it on desktop and letting it run while watching CPU. Been running almost 15m and still sitting at around 105% CPU utilitzation for the factorio process.

Re: [0.17.52] CPU pegged and high lag even on menu screen

Posted: Tue Jun 25, 2019 2:34 pm
by tehfreek
Can you attach strace to the process and share some of the output?

Re: [0.17.52] CPU pegged and high lag even on menu screen

Posted: Tue Jun 25, 2019 2:40 pm
by linearj
Below, repeating. The sched_yield line repeats several dozen times, followed by the rest.

sched_yield() = 0
getpid() = 28704
getpid() = 28704
getpid() = 28704
getpid() = 28704
getpid() = 28704
getpid() = 28704
clock_gettime(CLOCK_MONOTONIC, {tv_sec=96405, tv_nsec=348874247}) = 0
clock_gettime(CLOCK_MONOTONIC, {tv_sec=96405, tv_nsec=348903347}) = 0
clock_gettime(CLOCK_MONOTONIC, {tv_sec=96405, tv_nsec=348925664}) = 0
sched_yield() = 0
sched_yield() = 0
clock_gettime(CLOCK_MONOTONIC, {tv_sec=96405, tv_nsec=348994492}) = 0
sched_yield() = 0
sched_yield() = 0
recvmsg(8, {msg_namelen=0}, 0) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=8, events=POLLIN|POLLPRI}], 1, 0) = 0 (Timeout)
futex(0x7ffc49de012c, FUTEX_CMP_REQUEUE_PRIVATE, 1, 2147483647, 0x7ffc49de00e0, 23194) = 1
futex(0x7ffc49de00e0, FUTEX_WAKE_PRIVATE, 1) = 1

Re: [0.17.52] CPU pegged and high lag even on menu screen

Posted: Tue Jun 25, 2019 3:20 pm
by Oxyd
Could you run the game under perf and send me the result files, perf.data and perf.data.tar.bz2?

Code: Select all

perf record -D20000 --call-graph dwarf path/to/factorio
perf archive perf.data
The first command will run Factorio under perf – I'd like you to let it load to the main menu and then simply close the game after a few seconds. (It will wait for 20 seconds before collecting samples, and your log indicates that your desktop can load the game in 17 seconds, so that should be about right. Idea is to collect samples from the laggy menu and not from startup. You can tweak the value of the -D flag if you feel other delay would be more apropriate.)

Second command will create an archive with object files necessary to analyse the first file on another computer. perf.data and perf.data.tar.bz2 should be around 70 MB each, depending on how long you leave the game running.

Re: [0.17.52] CPU pegged and high lag even on menu screen

Posted: Tue Jun 25, 2019 3:24 pm
by linearj
Attached.

Re: [0.17.52] CPU pegged and high lag even on menu screen

Posted: Tue Jun 25, 2019 3:45 pm
by Oxyd
Thanks, can I also have the perf.data file?

Re: [0.17.52] CPU pegged and high lag even on menu screen

Posted: Tue Jun 25, 2019 3:49 pm
by linearj
Ah. Didn't realize that didn't get included.
Just looking at the file, and we have a problem. There is a lot of sensitive data in that file. It seems to have included environment variables, .e.g., which I cannot publish.

I may need to try and set up a controlled environment to run this again. That will take some time, unfortunately.

Re: [0.17.52] CPU pegged and high lag even on menu screen

Posted: Tue Jun 25, 2019 4:04 pm
by linearj
Tried a Q&D way to do this, and that seems to have helped. I am concerned, however, about what I am not seeing.

Is there a way I can xfer this file more securely? E.g., something more direct to you or perhaps if you share a GPG public key I can use to encrypt it...

Re: [0.17.52] CPU pegged and high lag even on menu screen

Posted: Tue Jun 25, 2019 4:11 pm
by tehfreek
Upload it to Google Drive and PM a private link.

Re: [0.17.52] CPU pegged and high lag even on menu screen

Posted: Tue Jun 25, 2019 4:15 pm
by linearj
Never done that before. Will have to google how to upload to google drive :-). Will let you know...

Re: [0.17.52] CPU pegged and high lag even on menu screen

Posted: Tue Jun 25, 2019 4:35 pm
by linearj
Uploaded to google drive and PM'ed link. My first PM in the forums; it shows in my Outbox instead of Sent Messages, so not sure if it was "sent" or not...

Re: [0.17.52] CPU pegged and high lag even on menu screen

Posted: Tue Jun 25, 2019 4:55 pm
by Oxyd
Yep, I received the files just fine, thanks. I'll see if I can figure anything out from it.

Re: [0.17.52] CPU pegged and high lag even on menu screen

Posted: Tue Jun 25, 2019 4:57 pm
by linearj
Many thanks; I am going to delete it from GD, now.
Let me know if there is anything further I can do to help!

Re: [0.17.52] CPU pegged and high lag even on menu screen

Posted: Wed Jun 26, 2019 1:43 pm
by Oxyd
Unfortunately, I don't see anything particularly relevant in that either. You're using an NVidia card – did you change any settings of the NVidia driver? Anything NVidia-related in xorg.conf(.d), environment variables, or did you change anything inside nvidia-settings? You could also try unplugging all but one of your monitors, maybe the quad-screen setup is too much for something to handle.

Since you are the only person reporting this, I'm inclined to call this an undetermined issue with your setup, with the graphics driver high on the suspect list.

Re: [0.17.52] CPU pegged and high lag even on menu screen

Posted: Wed Jun 26, 2019 8:11 pm
by linearj
No special settings. Specifically, no changes between runs. More explicitly:

Run Factorio 0.16. Runs fine. Plays fine.
Run Factorio 0.17.52. 100% CPU and lag.
Run Factorio 0.16. Runs fine. Plays fine.

No changes or reboots or anything between the above three steps.
Same three steps on my laptop produce playable runs each time.

Big difference appears to be how Factorio is seeing the monitors:
0.16:
0.203 Available display adapters: 1
0.203 [0]: resolution 5120x2880px at [0,0]

0.17:
0.385 Available displays: 4
0.385 [0]: 0 - {[0,0], 2560x1440, SDL_PIXELFORMAT_RGB888, 0Hz}
0.385 [1]: 1 - {[0,1440], 2560x1440, SDL_PIXELFORMAT_RGB888, 0Hz}
0.385 [2]: 2 - {[2560,0], 2560x1440, SDL_PIXELFORMAT_RGB888, 0Hz}
0.385 [3]: 3 - {[2560,1440], 2560x1440, SDL_PIXELFORMAT_RGB888, 0Hz}

So, 0.17 is querying the hardware differently. Assuming we have success reports from other multi-monitor Linux users, then it could be particular to my hw. It appears at least that Factorio is not querying the vsync refresh rate properly, as it is getting 0Hz. I am betting that this zero is causing it to spin in a loop somewhere in the code.

Unplugging monitors is painful. It takes forever to get X/nvidia to agree on where to place them again, even if I save the Xorg.conf.

Re: [0.17.52] CPU pegged and high lag even on menu screen

Posted: Wed Jun 26, 2019 9:34 pm
by tehfreek
linearj wrote: Wed Jun 26, 2019 8:11 pm Unplugging monitors is painful. It takes forever to get X/nvidia to agree on where to place them again, even if I save the Xorg.conf.
Couldn't you use xrandr to turn them off?