[1.1.35] Linux - Lower FPS on Steam version than on non Steam version

Bugs that are actually features.
andrfgs
Inserter
Inserter
Posts: 21
Joined: Fri Sep 04, 2020 10:12 pm
Contact:

[1.1.35] Linux - Lower FPS on Steam version than on non Steam version

Post by andrfgs »

Hello there, I have made this post on Steam first and some people recommended me to post here in the bug reports. Original post: https://steamcommunity.com/app/427520/d ... 883910697/

For some reason, at least in Linux, the Steam version of the game is much slower than the non steam version. I am running on a laptop hooked into a 4K display, the Steam version runs at 40fps while the non Steam version runs at a 60fps. Both with the same configuration. There's a 20 fps loss just for using Steam. I used mods in both versions though disabling them all hasn't changed the performance difference any bit. I still have the same results with or without mods. The logs confirm I am using the dedicated GPU on both versions. The Linux Nvidia driver is set to run all OpenGL programs with VSync on, since Factorio's VSync option is broken for Linux versions.

Logs:
Steam Log: https://pastebin.com/UGeGXsxs
Non Steam Log: https://pastebin.com/q1sxAxeU

My specs:
PC: MSI Leopard 8RF (Laptop)
OS: Arch Linux
Kernel: 5.12.10-arch1-1
DE: Plasma 5.22.0 (KWin w/ OpenGL 3.1)
GPU: Nvidia GTX 1070M (using the dedicated gpu)
GPU driver: nvidia 465.31-8
Display Server: X Server (Xorg)
Game Version: 1.1.35
Definition of Evil: put train lines at (0, 0) with a constant stream of trains passing by.
User avatar
jodokus31
Smart Inserter
Smart Inserter
Posts: 1622
Joined: Sun Feb 26, 2017 4:13 pm
Contact:

Re: [1.1.35] Linux - Lower FPS on Steam version than on non Steam version

Post by jodokus31 »

andrfgs wrote: ↑Sat Jul 03, 2021 8:29 pm
Logs:
Steam Log: https://pastebin.com/UGeGXsxs
Non Steam Log: https://pastebin.com/q1sxAxeU
The steam version has actually lower graphic settings, although its slower. Very strange.

Code: Select all

   
   0.378 Graphics options: [Graphics quality: normal] [Video memory usage: all] [DXT: low-quality] [Color: 32bit]
   0.378                   [Max threads (load/render): 32/12] [Max texture size: 2048] [Tex.Stream.: 0] [Rotation quality: normal] [Other: STDCWT] [B:0,C:0,S:100]
vs

Code: Select all

   
   0.902 Graphics options: [Graphics quality: high] [Video memory usage: all] [DXT: high-quality] [Color: 32bit]
   0.902                   [Max threads (load/render): 32/12] [Max texture size: 0] [Tex.Stream.: 0] [Rotation quality: normal] 

However, I would create a log with identical settings and probably also take a screenshot from ingame debug values (F4 -> show-time-usage, show-fps)
andrfgs
Inserter
Inserter
Posts: 21
Joined: Fri Sep 04, 2020 10:12 pm
Contact:

Re: [1.1.35] Linux - Lower FPS on Steam version than on non Steam version

Post by andrfgs »

Right, I'm sorry, I lowered the settings on the Steam version to check if it helped and forgot about it.

Here are the logs with the same options on both:
Steam Log: https://pastebin.com/QRLUrVwB
Non Steam Log: https://pastebin.com/rPU3n06G

I used "__GL_SYNC_TO_VBLANK=0" on both but it seems to make no difference. The cap is 60FPS for both, but thats probably due to the driver as Factorio's VSync seems to have no effect. Well, sorta. Factorio's VSync definitely does affect the time in "Wait for Update", but the result is not the intended by a conventional VSync implementation.

Given how lightweight Factorio is on the GPU, and given that having lower quality doesn't help, this is likely a bad integration with Steam on the Linux version or a problem in Steam itself on Linux. Though other games do not seem to suffer the same issue. Even Subnautica, a non Linux native game, runs faster in Steam proton (using the Steam overlay) than it does on Lutris. Though it might be the overlay itself causing the bug for all I know.

Also quite strange the Non Steam version is has a non zero time for "Wait for Update" when Factorio's VSync was disabled in both versions and I passed "__GL_SYNC_TO_VBLANK=0". If it's the driver doing this, then it is disobeying the env variable I passed.
Attachments
Non Steam version.png
Non Steam version.png (10.22 MiB) Viewed 7671 times
Steam Time Usage.png
Steam Time Usage.png (15.74 MiB) Viewed 7677 times
Definition of Evil: put train lines at (0, 0) with a constant stream of trains passing by.
User avatar
ptx0
Smart Inserter
Smart Inserter
Posts: 1507
Joined: Wed Jan 01, 2020 7:16 pm
Contact:

Re: [1.1.35] Linux - Lower FPS on Steam version than on non Steam version

Post by ptx0 »

it's just a factor of the steam web browser getting crazy and consuming CPU, which is why i switched from steam a couple years ago.
quyxkh
Smart Inserter
Smart Inserter
Posts: 1031
Joined: Sun May 08, 2016 9:01 am
Contact:

Re: [1.1.35] Linux - Lower FPS on Steam version than on non Steam version

Post by quyxkh »

You can cut steam's overhead on the library page *a lot* by switching to small mode in the view menu.
User avatar
jodokus31
Smart Inserter
Smart Inserter
Posts: 1622
Joined: Sun Feb 26, 2017 4:13 pm
Contact:

Re: [1.1.35] Linux - Lower FPS on Steam version than on non Steam version

Post by jodokus31 »

quyxkh wrote: ↑Sun Jul 04, 2021 3:08 am You can cut steam's overhead on the library page *a lot* by switching to small mode in the view menu.
Wow, nice tip. :)
andrfgs wrote: ↑Sun Jul 04, 2021 12:50 am Also quite strange the Non Steam version is has a non zero time for "Wait for Update" when Factorio's VSync was disabled in both versions and I passed "__GL_SYNC_TO_VBLANK=0". If it's the driver doing this, then it is disobeying the env variable I passed.
At least __GL_SYNC_TO_VBLANK gets listed in the log around first 10 lines, so i think it will be considered.

I also disabled OpenGL Extension KHR_debug via Ctrl+Alt + Settings -> The rest -> "disable opengl ext."
Not sure what it does, but it sounds like debug overhead.
User avatar
ptx0
Smart Inserter
Smart Inserter
Posts: 1507
Joined: Wed Jan 01, 2020 7:16 pm
Contact:

Re: [1.1.35] Linux - Lower FPS on Steam version than on non Steam version

Post by ptx0 »

jodokus31 wrote: ↑Sun Jul 04, 2021 7:46 am
quyxkh wrote: ↑Sun Jul 04, 2021 3:08 am You can cut steam's overhead on the library page *a lot* by switching to small mode in the view menu.
Wow, nice tip. :)
andrfgs wrote: ↑Sun Jul 04, 2021 12:50 am Also quite strange the Non Steam version is has a non zero time for "Wait for Update" when Factorio's VSync was disabled in both versions and I passed "__GL_SYNC_TO_VBLANK=0". If it's the driver doing this, then it is disobeying the env variable I passed.
At least __GL_SYNC_TO_VBLANK gets listed in the log around first 10 lines, so i think it will be considered.

I also disabled OpenGL Extension KHR_debug via Ctrl+Alt + Settings -> The rest -> "disable opengl ext."
Not sure what it does, but it sounds like debug overhead.
This extension allows the GL to notify applications when various events
occur that may be useful during application development, debugging and
profiling.

These events are represented in the form of enumerable messages with a
human-readable string representation. Examples of debug events include
incorrect use of the GL, warnings of undefined behavior, and performance
warnings.
andrfgs
Inserter
Inserter
Posts: 21
Joined: Fri Sep 04, 2020 10:12 pm
Contact:

Re: [1.1.35] Linux - Lower FPS on Steam version than on non Steam version

Post by andrfgs »

@quyxkh I disabled the entire Steam overlay, but it had no effect no fps. Also this is the only game I've had this issue with, so far.

@judokus Where do I find those settings? I should add that turning VSync off on the nvidia driver affects ALL OpenGL applications, including my compositor, which then causes tearing in all my day to day windows. But regardless, I haven't found this to solve the problem anyways. Where is that option to disable the debug? Can I simply pass 'KHR_debug=0' to the game launch parameters?
Definition of Evil: put train lines at (0, 0) with a constant stream of trains passing by.
User avatar
jodokus31
Smart Inserter
Smart Inserter
Posts: 1622
Joined: Sun Feb 26, 2017 4:13 pm
Contact:

Re: [1.1.35] Linux - Lower FPS on Steam version than on non Steam version

Post by jodokus31 »

If you open Factorio in main menu, click on "Settings" with Ctrl+Alt pressed.
Then an additional menu entry appears in Settings menu called "The Rest"
Here are a lot of different options like "disable opengl extensions"

The same options can be found in config.ini:

Code: Select all

; Comma separated list of OpenGL extensions that should not be used (for example: ARB_copy_image,KHR_debug)
disabled-opengl-extensions=KHR_debug
I'm not sure, if it really has any impact. Thanks @ptx0 for the info
andrfgs
Inserter
Inserter
Posts: 21
Joined: Fri Sep 04, 2020 10:12 pm
Contact:

Re: [1.1.35] Linux - Lower FPS on Steam version than on non Steam version

Post by andrfgs »

OK, I did that and no performance gain. Seriously, I'm really thinking there is a bug in how the Steam integration is implemented for Linux. This is not happening in other games and the Steam overlay being disabled does not improve anything at all.
Definition of Evil: put train lines at (0, 0) with a constant stream of trains passing by.
User avatar
ptx0
Smart Inserter
Smart Inserter
Posts: 1507
Joined: Wed Jan 01, 2020 7:16 pm
Contact:

Re: [1.1.35] Linux - Lower FPS on Steam version than on non Steam version

Post by ptx0 »

if you want more info, you can use perf top

on Debian derivatives, sudo apt-get -y install perf-tools

on RH derivatives, sudo dnf install perf-tools

then run:

perf top

and if you want a more visual output, use a flame graph: https://www.brendangregg.com/FlameGraph ... raphs.html
andrfgs
Inserter
Inserter
Posts: 21
Joined: Fri Sep 04, 2020 10:12 pm
Contact:

Re: [1.1.35] Linux - Lower FPS on Steam version than on non Steam version

Post by andrfgs »

I used Hotspot (https://github.com/KDAB/hotspot), which a GUI version of perf and with flamegraphs integrated to it.
I first had to change the kernel perf event flags to -1 with: 'sudo sysctl -w kernel.perf_event_paranoid=-1'

So here's the flamegraph for the Steam version:
Steam.png
Steam.png (405.91 KiB) Viewed 7419 times
And the flamegraph for the Non Steam version:
Non Steam.png
Non Steam.png (334.8 KiB) Viewed 7419 times
From the graph, the Non Steam version takes most time on the init phase of the game but afterwards it runs smoothly. On the Steam version though, we can see the SwapBuffers call is the problem here. In fact, 'glxSwapBuffers' seems to be called by 'gameoverlayrenderer.so' which is the Steam overlay, making additional calls to the nvidia libraries. And this was with the Steam Overlay disabled on the launcher. So it appears disabling the overlay simply hides the UI, but the render calls are still there.
Definition of Evil: put train lines at (0, 0) with a constant stream of trains passing by.
User avatar
jodokus31
Smart Inserter
Smart Inserter
Posts: 1622
Joined: Sun Feb 26, 2017 4:13 pm
Contact:

Re: [1.1.35] Linux - Lower FPS on Steam version than on non Steam version

Post by jodokus31 »

Stupid question: What happens, if steam program is running, but you play the non-steam version of factorio independently?
andrfgs
Inserter
Inserter
Posts: 21
Joined: Fri Sep 04, 2020 10:12 pm
Contact:

Re: [1.1.35] Linux - Lower FPS on Steam version than on non Steam version

Post by andrfgs »

Not a stupid question at all. I do understand your thinking, it could be the platform issuing expensive syscalls to the OS, but unfortunately, nothing changes. The non steam version runs at 60fps regardless.
Definition of Evil: put train lines at (0, 0) with a constant stream of trains passing by.
User avatar
ptx0
Smart Inserter
Smart Inserter
Posts: 1507
Joined: Wed Jan 01, 2020 7:16 pm
Contact:

Re: [1.1.35] Linux - Lower FPS on Steam version than on non Steam version

Post by ptx0 »

well thanks for running that, the results weren't what i observed. it looks like steam is garbage in more than one way :)
User avatar
jodokus31
Smart Inserter
Smart Inserter
Posts: 1622
Joined: Sun Feb 26, 2017 4:13 pm
Contact:

Re: [1.1.35] Linux - Lower FPS on Steam version than on non Steam version

Post by jodokus31 »

andrfgs wrote: ↑Tue Jul 06, 2021 5:06 pm Not a stupid question at all. I do understand your thinking, it could be the platform issuing expensive syscalls to the OS, but unfortunately, nothing changes. The non steam version runs at 60fps regardless.
That's strange. Why should steam version be influenced, but non-steam version not, when steam is running. I cannot imagine, that the executables themselves are different. The problem has to be, how the steam version is called or configured. Maybe you could try to call steam version directly from file manager?

I have steam, but never bothered to activate factorio for steam, because i liked the standalone version more. So i cant test it.
User avatar
ptx0
Smart Inserter
Smart Inserter
Posts: 1507
Joined: Wed Jan 01, 2020 7:16 pm
Contact:

Re: [1.1.35] Linux - Lower FPS on Steam version than on non Steam version

Post by ptx0 »

jodokus31 wrote: ↑Wed Jul 07, 2021 8:33 pm
andrfgs wrote: ↑Tue Jul 06, 2021 5:06 pm Not a stupid question at all. I do understand your thinking, it could be the platform issuing expensive syscalls to the OS, but unfortunately, nothing changes. The non steam version runs at 60fps regardless.
That's strange. Why should steam version be influenced, but non-steam version not, when steam is running. I cannot imagine, that the executables themselves are different. The problem has to be, how the steam version is called or configured. Maybe you could try to call steam version directly from file manager?

I have steam, but never bothered to activate factorio for steam, because i liked the standalone version more. So i cant test it.
you're chasing your own tail, the library is only running when it is steam that is running the game. context switching is expensive.
quyxkh
Smart Inserter
Smart Inserter
Posts: 1031
Joined: Sun May 08, 2016 9:01 am
Contact:

Re: [1.1.35] Linux - Lower FPS on Steam version than on non Steam version

Post by quyxkh »

Both with the same configuration.
Your logs say they're different. Your steam setup has a 175% custom UI scale and a 2048 texture size cutoff.
evg-zhabotinsky
Inserter
Inserter
Posts: 22
Joined: Wed Dec 09, 2020 3:53 pm
Contact:

Re: [Oxyd] [1.1.35] Linux - Lower FPS on Steam version than on non Steam version

Post by evg-zhabotinsky »

Steam on Linux has one huge bug/feature, called Steam Runtime.
https://wiki.archlinux.org/title/Steam/Troubleshooting#Steam_runtime
It is a feature, because it (usually) lets you ignore library dependencies of your games and just play them.
It is a bug, because most of the time it degrades performance a lot, and sometimes (very rarely) results in library version conflicts causing crashes.

Usually I disable it on a computer when I play on it enough to get bothered by performance, and haven't enabled it back even once.
For me, Factorio runs, like, 50% faster? With Steam Runtime disabled. Still a bit slower than on Windows, but that's "thanks" to primusrun.

If your distribution doesn't provide a ready way to launch Steam without its Runtime, try something like "STEAM_RUNTIME=0 steam".
(Though that variable might be overridden by the distribution-provided script for running Steam, will have to find and fix it there then.)
When running like that, you might have to install some extra libraries, but if standalone games provide none and still work you should be ok already.

Another option that should work, I think, is to set Launch Options for the game in Steam to something like:
env -u LD_PRELOAD -u LD_LIBRARY_PATH %command%
That should get rid of any possible chance for Steam to force or even suggest any libraries to that one game.
Actually, I'd suggest using this option anyway, because I think Steam tries to inject something even with both Steam Overlay and Runtime disabled.
Again, installing missing libraries might be required.

In general, lots of (semi-)commercial software for Linux is distributed bundled with libraries and utilities "just in case", often old, sometimes broken.
I even had one case where an IDE (STM32Cube) improved from nearly unusable (very broken GUI) to perfectly working after removing bundled JRE.
Basically, your specific Linux setup is an unknown for many software distributors and they try to compensate by bundling extra stuff,
but if your system is properly managed then that bundled stuff is a much greater unknown for you due to being foreign to your system.
andrfgs
Inserter
Inserter
Posts: 21
Joined: Fri Sep 04, 2020 10:12 pm
Contact:

Re: [Oxyd] [1.1.35] Linux - Lower FPS on Steam version than on non Steam version

Post by andrfgs »

First sorry for the long time to reply, I have been a bit busy with work related stuff so I couldn't reply right away.

I tried to run Steam in the native mode. I even ran directly on the terminal:
> STEAM_RUNTIME=0 steam

But the FPS is still low.

Next I tried to use the following launch parameters

Code: Select all

env -u LD_PRELOAD -u LD_LIBRARY_PATH prime-run %command%


when running Steam Native and the FPS is still low. Sorry to insist on this, might it actually be the specific implementation of Factorio for steam on Linux that's a bit inneficient?

I don't want to sound rude to the developers or anything, I'm just trying to narrow down the causes of this problem. I really would love to run Factorio with steam because it helps synchronizing the game saves and also blueprints between machines.
Definition of Evil: put train lines at (0, 0) with a constant stream of trains passing by.
Post Reply

Return to β€œNot a bug”