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

Place for things which are bugs but we have no idea how to solve them. Things related to hardware, libraries, strange setups, etc.
User avatar
linearj
Inserter
Inserter
Posts: 38
Joined: Tue Aug 07, 2018 10:50 pm
Contact:

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

Post by linearj »

Not using xrandr. That would be my preference, but it does not work on my setup; I forget the reason. I think it is just unsupported with the nvidia X.
- LinearJ
Oxyd
Former Staff
Former Staff
Posts: 1428
Joined: Thu May 07, 2015 8:42 am
Contact:

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

Post by Oxyd »

linearj wrote: Wed Jun 26, 2019 8:11 pmSo, 0.17 is querying the hardware differently.
Yes, we moved from Allegro to SDL in 0.17.
linearj wrote: Wed Jun 26, 2019 8:11 pmIt 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.
That was my thought as well, but it doesn't appear to be actually using the refresh rate anywhere in the code. Also it uses XRandR to query the refresh rate, so if that doesn't work on your setup, that would explain why Factorio can't get the refresh rate. And for what it's worth, XRandR works for me with an NVidia card – it might be worth investigating why it doesn't work for you, it might be connected to what's wrong with Factorio here.
User avatar
linearj
Inserter
Inserter
Posts: 38
Joined: Tue Aug 07, 2018 10:50 pm
Contact:

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

Post by linearj »

Well, xrandr, as I understand it, is going away as a protocol, so it would well-behoove you to look at more generic APIs.
A thought... can you add a variable to the configuration file for factorio that, if present, overrides the refresh rate? If so, then I could put in the value and test whether that resolves...

As for xrandr on my system,
hamilton ~ [45] /usr/bin/xrandr
RandR extension missing
hamilton ~ [46]

The nvidia driver does not support the extension. It used to, as I used to use it a lot and wrote a lot of scripts around it. Strangely, search google for nvidia "xrandr extension missing" gives almost no results and certainly no useful ones.
- LinearJ
User avatar
linearj
Inserter
Inserter
Posts: 38
Joined: Tue Aug 07, 2018 10:50 pm
Contact:

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

Post by linearj »

Are you calling xrandr or are you using an API? If the former, then I can write a script to produce the expected output and put it ahead of the real xrandr in the PATH...
- LinearJ
User avatar
linearj
Inserter
Inserter
Posts: 38
Joined: Tue Aug 07, 2018 10:50 pm
Contact:

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

Post by linearj »

Aha... I looked into it and remembered the issue. I cannot use xrandr because I have multiple video cards. I have two ganged GTX 960 video cards, each driving two monitors. The RAndR extension does not work in this setup.
- LinearJ
Oxyd
Former Staff
Former Staff
Posts: 1428
Joined: Thu May 07, 2015 8:42 am
Contact:

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

Post by Oxyd »

linearj wrote: Thu Jun 27, 2019 2:14 pm Well, xrandr, as I understand it, is going away as a protocol, so it would well-behoove you to look at more generic APIs.
Oh, I haven't heard about that. Do you know what it's being replaced by? Unless you mean the general move away from X and toward Wayland.
Are you calling xrandr or are you using an API? If the former, then I can write a script to produce the expected output and put it ahead of the real xrandr in the PATH...
We use libxrandr; we don't exec the xrandr binary.
linearj wrote: Thu Jun 27, 2019 2:45 pm Aha... I looked into it and remembered the issue. I cannot use xrandr because I have multiple video cards. I have two ganged GTX 960 video cards, each driving two monitors. The RAndR extension does not work in this setup.
Ah, that could be it. Are you using xinerama/TwinView, then? Could you post your Xorg.0.log and your Xorg.conf?
User avatar
linearj
Inserter
Inserter
Posts: 38
Joined: Tue Aug 07, 2018 10:50 pm
Contact:

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

Post by linearj »

Xinerama. Was trying to remember what the name of the thing was instead of xrandr.

I would have to look for the source again, but when I was originally configuring this desktop, I could not use xrandr and had to use xinerama. At the time, the docs I read implied that there was a general move away from xrandr and towards xinerama.

conf and log attached.

Sorry for the zip, but I could not get the browser to see the xorg.conf file, even though it is readable by me and in the same dir. Very weird.
Attachments
xfiles.zip
(7.46 KiB) Downloaded 110 times
- LinearJ
User avatar
linearj
Inserter
Inserter
Posts: 38
Joined: Tue Aug 07, 2018 10:50 pm
Contact:

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

Post by linearj »

Found this:
https://unix.stackexchange.com/question ... riple-head

Is very scary and painful, as my experience with nvidia X is that I cannot get my current setup back just by saving and restore the xorg.conf file. But, I will try this weekend when I can afford some downtime on my system.

If I am able to switch to randr, I will let you know how factorio runs (and I will be a much happer camper, as I prefer randr).

This page implies that randr is replacing xinerama, whereas I saw the reverse when I was setting up my system a few years ago. Not sure which is true, but if the coding isn't too hard, you might consider trying both methods (i.e., test if randr is enabled, and if not, get the info from xinerama, etc).
- LinearJ
Oxyd
Former Staff
Former Staff
Posts: 1428
Joined: Thu May 07, 2015 8:42 am
Contact:

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

Post by Oxyd »

My impression is also that Xinerama is old and XRandR is new, so XRandR would be replacing Xinerama.

Nevertheless, I think this is all a bit of a red herring. Factorio simply doesn't detect the refresh rate when you're using Xinerama, which as far as I can tell, should be completely inconsequential. I could be wrong, of course.

I'll try with a Xinerama setup and see if I can reproduce the lag that way.
User avatar
linearj
Inserter
Inserter
Posts: 38
Joined: Tue Aug 07, 2018 10:50 pm
Contact:

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

Post by linearj »

I am also happy to run a copy of factorio with any tracing turned on that you might have. The only thing I have done for that so far is strace, which shows the process spinning on the same sequence of calls indefinitely (see post from a couple of days ago).
- LinearJ
User avatar
linearj
Inserter
Inserter
Posts: 38
Joined: Tue Aug 07, 2018 10:50 pm
Contact:

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

Post by linearj »

The good news: I disabled xinerama and now xrandr appears to be working. Even better, Factorio is running just fine.
The bad news: this has trashed my multiple monitor display. I am now down to one monitor and the documentation from nvidia is just plain wrong:

http://download.nvidia.com/XFree86/Linu ... E/sli.html

I enabled SLI, rebooted, started up X, and ran nvidia-settings. I am supposed to now go to the "SLI Mosaic Mode Settings" tab on the left. There is no such tab there.
So, now I am where I am two years ago, wandering in the dark trying to get my multiple monitors working, but now trying to do it without xinerama, which at the time was the only way I could find to make it work.

But, it does show that xrandr vs xinerama is significant to factorio performance as of 0.17...
- LinearJ
User avatar
linearj
Inserter
Inserter
Posts: 38
Joined: Tue Aug 07, 2018 10:50 pm
Contact:

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

Post by linearj »

So, my computer was dead for most of the weekend. Could only get it working on two monitors. Finally managed to get it back into a working 4 monitor state, but had to re-enable Xinerama to do it. None of the links I found earlier helped.

So, I am back where I started: working 4 monitor setup with Xinerama, Factorio eating 100% of CPU and unplayable due to lag.
- LinearJ
User avatar
linearj
Inserter
Inserter
Posts: 38
Joined: Tue Aug 07, 2018 10:50 pm
Contact:

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

Post by linearj »

Any news? I am still dead in the water on my desktop.

If I disable Xinerama, then Factorio works fine, but I only get two monitors. To see all four, I need to enable Xinerama, but then Factorio uses 100% CPU and is slow to respond.

Tried everything I could find online about configuring nvidia, but if I disable Xinerama, then it only sees the two monitors on one of my video cards. Tried enablng SLI (I have the bridge connected and the cards in the right slots for it) but no dice.

I would much rather that my set up used randr instead of xinerama, but there does not seem to be a way to make that work and see all of the monitors.
So my options are:

* Only use two monitors; not acceptable.
* Use four monitors, but only play Factorio 0.16, which has always worked. Fortunately, 0.16 is a great game, but I really want to play 0.17
* Only play Factorio 0.17 on my laptop. Also not good, as laptop horsepower is limited. It runs fine, but as the base gets big, I hit the limits of laptop performance. My large 0.17 base on my laptop is still far outperforming the 0.17 main menu on the desktop though... :-)
- LinearJ
Oxyd
Former Staff
Former Staff
Posts: 1428
Joined: Thu May 07, 2015 8:42 am
Contact:

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

Post by Oxyd »

Well, the news is twofold. The good part is that I have been able to reproduce it on my machine if I switch to Xinerama. The bad part is that 97% of the CPU time is spent inside the NVidia driver, which means that there probably isn't anything I can do. This sounds like a performance issue with the NVidia driver itself.
posila
Factorio Staff
Factorio Staff
Posts: 5362
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

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

Post by posila »

I wonder ... does setting ogl-accelerated-renderer=true in config.ini or setting environment variable SDL_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR=0 make any difference?
User avatar
linearj
Inserter
Inserter
Posts: 38
Joined: Tue Aug 07, 2018 10:50 pm
Contact:

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

Post by linearj »

Odd that it only spins CPU in the nvidia driver when using xinerama. Same driver works fine without xinerama.

Will test the ogl / SDL settings tonight.
It would be great if there is a setting that would allow this to run with xinerama. Seems like there should be since the same driver works without it.
Having said that, I'd still like to get rid of xinerama and go back to randr. I tried most of the past weekend, but without xinerama, nvidia would not see any of the monitors plugged into the second card.
- LinearJ
User avatar
linearj
Inserter
Inserter
Posts: 38
Joined: Tue Aug 07, 2018 10:50 pm
Contact:

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

Post by linearj »

P.S., I was using the 410.78 nvidia driver. As part of trying to get randr working this past weekend, I upgraded to 430.26 and the issue is there as well.

If it is indeed a performance issue in the driver, it has been there for a while and is still there.
- LinearJ
posila
Factorio Staff
Factorio Staff
Posts: 5362
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

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

Post by posila »

I should have also noted that "ogl-accelerated-renderer" setting was added to config.ini in 0.17.54, so you'll have to update (it won't do anything on 0.17.52)
User avatar
linearj
Inserter
Inserter
Posts: 38
Joined: Tue Aug 07, 2018 10:50 pm
Contact:

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

Post by linearj »

Sorry... forgot to post results last night.
Firstly, no worries: I always upgrade to latest/greatest, so I was on .55 before trying the suggestions, anyway :-).

Bad news, good news and bad news.
Bad news: making the changes had no effect.

Good news: I searched for "nvidia xinerama performance issues" and found some more pages on how to get nvidia working without xinerama and was finally successful at accessing my monitors on the second card without xinerama.

Bad news: Apparently there is a three monitor limit hardcoded into the non-xinerama code. Seems silly as the same setup works fine (except for that performance issue) with 4 monitors with xinerama. Possibly the issue is that there is no hw acceleration when using four monitors because the GPUs cannot handle it. But, that also does not make sense as this system dual boots to windows, where all of my windows games (including my steam copy of factorio) run just fine. Unfortunately, I prefer to run Factorio under Linux as I can play while I am working on my code, and I prefer running Linux 2x2 instead of just 3 monitors, especially if I am coding/building while playing Factorio.

I'd open a support case with nvidia, but since their configuration tool specifically pops up an error message, "error, more than 3 displays are configured" (or some such), I don't think I am likely to get very far.

Many thanks for your help. I still hold out hope that you guys will find a setting that allows this to work with xinerama, but I understand that I am an edge case and this will take more horsepower than results will justify. If you do happen to find something, though, please let me know!
- LinearJ
tehfreek
Filter Inserter
Filter Inserter
Posts: 391
Joined: Thu Mar 17, 2016 7:34 am
Contact:

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

Post by tehfreek »

Have you reported this to Nvidia? I realize that their priorities are closer to CS:GO and PUBG on a single monitor, but since you bought their product they should either support it themselves or make it possible for others to support it.
Post Reply

Return to “1 / 0 magic”