GameMode: Difference between revisions

From NixOS Wiki
imported>MetaDark
mNo edit summary
Klinger (talk | contribs)
m Category:Software removed (Gaming is enough)
Tag: Manual revert
 
(25 intermediate revisions by 7 users not shown)
Line 1: Line 1:
GameMode is a daemon/lib combo for Linux that allows games to request a set of optimisations be temporarily applied to the host OS and/or a game process.
[https://github.com/FeralInteractive/gamemode GameMode] is a daemon/lib combo for Linux that allows games to request a set of optimisations be temporarily applied to the host OS and/or a game process.


== Installation ==
== Installation ==
Line 8: Line 8:
</syntaxhighlight>
</syntaxhighlight>


It's also possible to use GameMode without the NixOS module, but process renicing will not work:
== Running ==
To run games with GameMode start it like this:


<syntaxhighlight lang="nix">
<syntaxhighlight lang=console>
environment.systemPackages = with pkgs; [
$ gamemoderun ./game
  gamemode
</syntaxhighlight>
];
 
When you have started your game you can verify that GameMode is running with the command:
<syntaxhighlight lang=console>
$ gamemoded -s
</syntaxhighlight>
 
=== Steam ===
To make sure Steam starts a game with GameMode, right click the game, select Properties..., then Launch Options and enter:
 
<syntaxhighlight lang=text>
gamemoderun %command%
</syntaxhighlight>
</syntaxhighlight>


{{Note|CPU & GPU optimisations require root-level access. GameMode defines Polkit actions under <code>share/polkit-1/actions</code> to allow any user to perform the optimisations, but Polkit will only load these actions when installed in the system profile. If you install GameMode into a user profile, the optimisations will fail to apply.}}
== Verifying Optimisations ==
<code>gamemoded -t</code> can be used to verify that the optimisations for your configuration get applied:
<syntaxhighlight lang = console>
$ gamemoded -t
: Loading config
Loading config file [/nix/store/p8dbmpdak57psrb5c0mz7crsc95nfzs6-gamemode-1.6.1/share/gamemode/gamemode.ini]
Loading config file [/etc/gamemode.ini]
: Running tests
 
:: Basic client tests
:: Passed
 
:: Dual client tests
gamemode request succeeded and is active
Quitting by request...
:: Passed
 
:: Gamemoderun and reaper thread tests
...Waiting for child to quit...
...Waiting for reaper thread (reaper_frequency set to 5 seconds)...
:: Passed
 
:: Supervisor tests
:: Passed
 
:: Feature tests
::: Verifying CPU governor setting
::: Passed
::: Verifying Scripts
:::: Running start script [/nix/store/ig8aqj0973jgn6mhnr7smmqb6p7alrz4-libnotify-0.7.9/bin/notify-send 'GameMode started']
:::: Passed
:::: Running end script [/nix/store/ig8aqj0973jgn6mhnr7smmqb6p7alrz4-libnotify-0.7.9/bin/notify-send 'GameMode ended']
:::: Passed
::: Passed
::: Verifying GPU Optimisations
::: Passed
::: Verifying renice
::: Passed
::: Verifying ioprio
::: Passed
:: Passed
 
: All Tests Passed!
</syntaxhighlight>


== Known Errors ==
== Known Errors ==
{{Tip|The logs of the daemon service can be accessed with <code>journalctl --user -u gamemoded.service</code>.}}
Renice & ioprio optimisations sometimes fail. This is caused by GameMode trying to apply optimisations on processes that exit before the optimisations can be applied. See [https://github.com/FeralInteractive/gamemode/issues/167#issuecomment-524277666 FeralInteractive/gamemode#167 (comment)].
Renice & ioprio optimisations sometimes fail. This is caused by GameMode trying to apply optimisations on processes that exit before the optimisations can be applied. See [https://github.com/FeralInteractive/gamemode/issues/167#issuecomment-524277666 FeralInteractive/gamemode#167 (comment)].


<syntaxhighlight>
<syntaxhighlight lang=text>
ERROR: Could not inspect tasks for client [329118]! Skipping ioprio optimisation.
ERROR: Could not inspect tasks for client [329118]! Skipping ioprio optimisation.
ERROR: Refused to renice client [31477,31477]: prio was (-10) but we expected (0)
ERROR: Refused to renice client [31477,31477]: prio was (-10) but we expected (0)
Line 28: Line 84:
If you don't have an Intel CPU, you will get errors about failing to read the energy levels. This isn't a real problem. It just means that optimizations for integrated graphics cards won't be enabled:
If you don't have an Intel CPU, you will get errors about failing to read the energy levels. This isn't a real problem. It just means that optimizations for integrated graphics cards won't be enabled:


<syntaxhighlight>
<syntaxhighlight lang=text>
ERROR: Failed to open file for read /sys/class/powercap/intel-rapl/intel-rapl:0/intel-rapl:0:0/energy_uj
ERROR: Failed to open file for read /sys/class/powercap/intel-rapl/intel-rapl:0/intel-rapl:0:0/energy_uj
</syntaxhighlight>
</syntaxhighlight>


If you don't have a screensaver installed, you will get the following error:
If you don't have a screensaver installed, you will get the following error:
<syntaxhighlight>
<syntaxhighlight lang=text>
ERROR: Could not call Inhibit on org.freedesktop.ScreenSaver: No route to host
ERROR: Could not call Inhibit on org.freedesktop.ScreenSaver: No route to host
         org.freedesktop.DBus.Error.ServiceUnknown
         org.freedesktop.DBus.Error.ServiceUnknown
Line 39: Line 95:
</syntaxhighlight>
</syntaxhighlight>


You can disable the screensaver inhibiter to ignore these errors:
You can disable the screensaver inhibiter to get rid of those errors:
<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
programs.gamemode.settings.general.inhibit_screensaver = 0;
programs.gamemode.settings.general.inhibit_screensaver = 0;
</syntaxhighlight>
</syntaxhighlight>


{{Tip|The logs of the daemon service can be accessed with <code>journalctl --user -u gamemoded.service</code>.}}
 
Setting the power scheme might result in the following error:
<syntaxhighlight lang=text>
::: Verifying CPU governor setting
ERROR: Governor was not set to performance (was actually schedutil)!
::: Failed!
</syntaxhighlight>
Adding the the user to the gamemode group resolves this error.
<syntaxhighlight lang="nix">
extraGroups = ["gamemode"];
</syntaxhighlight>
 
[[Category:Gaming]]

Latest revision as of 20:34, 25 June 2024

GameMode is a daemon/lib combo for Linux that allows games to request a set of optimisations be temporarily applied to the host OS and/or a game process.

Installation

GameMode depends on root-level capabilities that aren't available in a user-level Nix package installation. The easiest way to set this up is to use the NixOS module:

programs.gamemode.enable = true;

Running

To run games with GameMode start it like this:

$ gamemoderun ./game

When you have started your game you can verify that GameMode is running with the command:

$ gamemoded -s

Steam

To make sure Steam starts a game with GameMode, right click the game, select Properties..., then Launch Options and enter:

gamemoderun %command%

Verifying Optimisations

gamemoded -t can be used to verify that the optimisations for your configuration get applied:

$ gamemoded -t
: Loading config
Loading config file [/nix/store/p8dbmpdak57psrb5c0mz7crsc95nfzs6-gamemode-1.6.1/share/gamemode/gamemode.ini]
Loading config file [/etc/gamemode.ini]
: Running tests

:: Basic client tests
:: Passed

:: Dual client tests
gamemode request succeeded and is active
Quitting by request...
:: Passed

:: Gamemoderun and reaper thread tests
...Waiting for child to quit...
...Waiting for reaper thread (reaper_frequency set to 5 seconds)...
:: Passed

:: Supervisor tests
:: Passed

:: Feature tests
::: Verifying CPU governor setting
::: Passed
::: Verifying Scripts
:::: Running start script [/nix/store/ig8aqj0973jgn6mhnr7smmqb6p7alrz4-libnotify-0.7.9/bin/notify-send 'GameMode started']
:::: Passed
:::: Running end script [/nix/store/ig8aqj0973jgn6mhnr7smmqb6p7alrz4-libnotify-0.7.9/bin/notify-send 'GameMode ended']
:::: Passed
::: Passed
::: Verifying GPU Optimisations
::: Passed
::: Verifying renice
::: Passed
::: Verifying ioprio
::: Passed
:: Passed

: All Tests Passed!

Known Errors

Renice & ioprio optimisations sometimes fail. This is caused by GameMode trying to apply optimisations on processes that exit before the optimisations can be applied. See FeralInteractive/gamemode#167 (comment).

ERROR: Could not inspect tasks for client [329118]! Skipping ioprio optimisation.
ERROR: Refused to renice client [31477,31477]: prio was (-10) but we expected (0)

If you don't have an Intel CPU, you will get errors about failing to read the energy levels. This isn't a real problem. It just means that optimizations for integrated graphics cards won't be enabled:

ERROR: Failed to open file for read /sys/class/powercap/intel-rapl/intel-rapl:0/intel-rapl:0:0/energy_uj

If you don't have a screensaver installed, you will get the following error:

ERROR: Could not call Inhibit on org.freedesktop.ScreenSaver: No route to host
        org.freedesktop.DBus.Error.ServiceUnknown
        The name org.freedesktop.ScreenSaver was not provided by any .service files

You can disable the screensaver inhibiter to get rid of those errors:

programs.gamemode.settings.general.inhibit_screensaver = 0;


Setting the power scheme might result in the following error:

::: Verifying CPU governor setting
ERROR: Governor was not set to performance (was actually schedutil)!
::: Failed!

Adding the the user to the gamemode group resolves this error.

extraGroups = ["gamemode"];