Jump to content

Pop!_OS / Linux Perfomance Boost & Stutter Fix


ZeeboNoonan

Recommended Posts

Note:  This was tested on the Flatpak Vintage Story version 1.18.3, but will work on locally installed versions.  Also, version 1.18.4 added the ability to enable mesa_glthread upon installation.

Quote
  • Fixed: Linux: Move mesa_glthread to the install.sh and prompt if the user wants to enable it


Small Performance Boost:
  Enable mesa_glthread 1 of 2 ways (or both).

    1)  In the vintagestory script file, that launches the game within flatpak, located at:

  • ~/.local/share/flatpak/app/at.vintagestory.VintageStory/x86_64/stable/active/files/bin/
  • Change the line:
  • exec /app/bin/mono /app/extra/vintagestory/Vintagestory.exe "$@"
  • To either:
    • (A)
      export mesa_glthread=true
      exec /app/bin/mono /app/extra/vintagestory/Vintagestory.exe "$@"

      (For no other reason than to keep the "exec", so the game runs in its own process, instead of as a decendant of the script.)

    • (B)

      mesa_glthread=true /app/bin/mono /app/extra/vintagestory/Vintagestory.exe "$@"

      (Just do it this way.  You'll be able to enable the more aggressive performance boost & stutter fix if you use this.)

 

    2)  Enable mesa_glthread through a DRI-specific rule.

  • The file is owned by root, so you're going to need to open it with this command from your terminal:
    • sudo gnome-text-editor /usr/share/drirc.d/00-mesa-defaults.conf
  • Go somewhere after the "<!-- The GL thread allowlist is below, workarounds are above. Keep it that way. -->" on line ~420,
  • but above the "<!-- Adaptive sync denylist follows below: -->" on line ~666, and add:
    •         <!-- CUSTOM ADDITION -->
              <application name="Vintage Story" executable="Vintagestory.exe">
                  <option name="mesa_glthread" value="true"/>
              </application>
  • ( ! ) Note: The mesa-defaults config may be in a different location. Such as:
    • (These directories are listed in a "dri-common" file, located at: "/etc/apparmor.d/abstractions/" on Pop!_OS, at least.)
      • /usr/lib{,32,64}/dri/
      • /usr/lib/@{multiarch}/dri/
      • /usr/lib/fglrx/dri/
      • /dev/dri/
      • /dev/dri/
      • /etc/drirc
      • /usr/share/drirc.d/
      • ~/.drirc


More Aggressive Performance Boost & Stutter Fix:
▶  Auto setting the schedule & io priority, and nice value of the game (with the System76 Scheduler).

   )  You must have vintagestory script (as mentioned in "Small Performance Boost") start Vintage Story without the "exec" command.
         This is so the mono runtime becomes a child of the "vintagestory" script, allowing us to target it, specifically.
         (Use option B when following the "Small Performance Boost" instructions.)

    2)  You will need root permissions, so open your file explorer from a terminal with a command like this:

  • sudo nautilus /etc/ /usr/share/

    (This will open two folders.)

    3)  Inside the share directory, copy the system76-scheduler folder into the etc directory.
        
(Presumably, the "system76-scheduler" folder is not present inside the etc directory, as was the case for me.)

    4)  Enter the system76-scheduler folder inside etc directory, and open the file: config.kdl.

    5)  Inside the file, find your way to the bottom of the assignments group.
         (Inside "process-scheduler", then inside "assignments".)

    6)  Copy & paste this custom vintagestory profile like so:

  • process-scheduler enable=true {
        ...
        assignments {
            ...
            // Custom
            vintagestory nice=-14 sched=(fifo)40 io=(best-effort)0 {
                include parent="vintagestory"
            }
        }
        ...
    }

    (The profile also includes the surrounding context for clarity.)
    NOTE:  "nice=-14" & "sched=(fifo)40" are maximums!

  • (Further details provided below...)

 

That's It!
▶  Restart your computer.  And launch the game as normal!*

 

-:-~~-:-~~-:-~~-:-~~-:-~~-:-~~-:-~~-:-~~-:-~~-:-~~-:-~~-:-~~-:-~~-:-~~-:-~~-:-

 

Starting Sources & Notes:
☛ Stuttering was mostly fixed with these changes.  Before the game was a little frustrating, but now it's comparably smoother.
▶  System76 Scheduler https://github.com/pop-os/system76-scheduler (can be installed on your linux distro)
▶  DRI GUI Application rules for mesa_glthread
https://forums.bohemia.net/forums/topic/211793-mesa_glthreadtrue/
▶  Boost Linux performance (where the rabbit hole began)

 

Pictures:

☛ Just look at that smooth debug graph (bottom right).

2023-05-19_11-40-35.thumb.png.245bb09198c1959bcbe3d7d39f37c60c.png

☛ Before, that graph was shooting up past the 30 fps mark (so lower than 30 fps) with these sub-second spikes between "smoother" sections.


☹ Below are two screenshots from before these changes to illustrate my point.
    
(I don't think these screenshots were the worst of it, but whatever. I hope you get my point.)

☹ Open Forest (if there is such a thing)
Screenshotfrom2023-05-1915-54-33.thumb.png.5c368632304ea919a9d98dc6c1ef345b.png

☹ (This screenshot has been scaled down because the file size was 3½ times bigger)
Zoom into Debug Graph:
Screenshotfrom2023-05-1915-52-41.png.4dc144b643d45098fff001fc91c6dd79.png

☹ Rainy Pit (there surely is such a thing)
Screenshotfrom2023-05-1915-54-43.thumb.png.29b62f26a8c6f165a52eac7ae6c13364.png

☹ (This screenshot has been scaled down because the file size was 3½ times bigger)
Zoom into Debug Graph:
Screenshotfrom2023-05-1915-53-05.png.0e83425cd1c16636f918e2a14f70dd15.png

 

-:-~~-:-~~-:-~~-:-~~-:-~~-:-~~-:-~~-:-~~-:-~~-:-~~-:-~~-:-~~-:-~~-:-~~-:-~~-:-


-=- Clarification -=-

  • Custom vintagestory profile:
    • Tweaking:
      Nice values go from -20 to 19, where lower values have higher priority.
      Sched values go from 1 to 49**, where higher values have higher priority.
      IO values*** go from 0 to 7, where lower values have higher priority.

    • Do not set a higher priority than:
      ◊ Nice: -14
      ◊ Sched: 40
      ◊ IO: (realtime)4

    • For reference, the "Video games" section runs with the profile "games nice=-5 io=(best-effort)0".
      (This includes all steam games, as they are descendants of steam.)
      Defaults are to run processes with a set, low nice value of 6.

  • * ... launch the game as normal *

    • Sometimes, I've had to relaunch my game because the profile didn't kick in.  It kicks in the second time, but makes my game windowed.  I just enabled the fullscreen setting again and it was good as new.

    • (By "didn't kick in", I mean I checked the nice value of the mono process with just the normal "system monitor", and it was set to 6.  It was fixed when I relaunched the game.)

  • ** 49 is maximum for the sched property **

    • It actually goes up to 99, but to quote, "it is recommended not to set a higher priority than hardware IRQs (>49)."[src="https://github.com/pop-os/system76-scheduler#profile"]

    • Pipewire (the audio engine; yours could be different, such as PulseAudio) and other sound services are set with "sound-server nice=-15 sched=(fifo)49 io=(realtime)0".  If you set any program to run with a higher priority nice value than -14 & a higher priority sched value than 40, you will start to experience audio crackling.

  • *** IO values ***

    • The io property can be set to either "(best-effort)#" or "(realtime)#".  Just keep it to "io=(best-effort)0", and if you need to go faster, just blow on the cartridge.

 

 

 

Guide by me.

OS:     Pop!_OS / Linux
CPU:  AMD® Ryzen 5 3600 6-core processor × 12 threads
GPU:  GeForce GTX 1070 8 GB
RAM: 16GB (2x8GB) DDR4 DRAM 3200MHz

Edited by ZeeboNoonan
removed herobrine
  • Like 1
  • Thanks 1
Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.