Low GPU Utilization in games

Hi all.

I recently updated my system and a bunch of games that were fine now have low GPU and CPU utilization.

I’m using an intel/nvidia laptop and the problems are similar on both GPUs.

What is strange is that I have benchmarked both the GPU and CPU independently and they perform as expected however when I run certain graphical programs such as glxgears or vkcube I get fps in the 20s.

$ VK_INSTANCE_LAYERS=VK_LAYER_MESA_overlay VK_LAYER_MESA_OVERLAY_CONFIG=help vkcube

image

I tried profiling vkcube and apparently writev is taking a lot of time. I’m not sure what to make of this or if this is worth pursuing further.

gprofng display text --functions ./test.5.er/

9.327 100.00  9.327 100.00   <Total>
7.705  82.62  7.705  82.62   writev
1.041  11.16  1.041  11.16   sched_yield
0.270   2.90  0.270   2.90   ioctl
...

When I run a game, there is consistently exactly one process that is using 100% of a CPU core. I’d imagine this is the bottleneck. I believe that the CPU is boosting correctly.

Performance also scales with window size.

The only game that I have tested that does not have behavior is factorio where if i have the in game video driver setting set to wayland I get normal performance, but if I set it to X11, I get poor performance. FreeCAD and OpenSCAD also have good performance.

Here is some of my configuration:

  hardware.nvidia = {
    open = false;
    package = config.boot.kernelPackages.nvidiaPackages.beta;
    modesetting.enable = true;
    powerManagement = {
      enable = true;
      finegrained = true;
    };
    nvidiaPersistenced = true;
  };

  hardware.graphics = {
    enable = true;
    extraPackages = with pkgs; [
      vaapiIntel
      vaapiVdpau
      libvdpau-va-of thegl
      intel-media-driver
      nvidia-vaapi-driver
    ];
  };
  boot.initrd = {
    systemd.enable = true;
    kernelModules = [ "vfat" "nls_cp437" "nls_iso8859-1" "usbhid" "amdgpu" ];
    ...
}

I am on sway, using kernel 6.13.0, have nix version 2.24.12. I have tested with the nvidia 565.77 driver and the 550 driver.

Hello.
A few things:

  1. can you benchmark again and post the output of nvidia-smi
  2. can you set hardware.nvidia.powerManagement.finegrained = false
  3. Can you post your config for hybrid graphics

I think I figured out what’s happening. I realized that when I ran programs in the integrated graphics, it seemed like they were being software rendered instead. intel_gpu_top confirmed that the programs were not using 3d acceleration. and glxinfo | grep "OpenGL renderer" told me that llvmpipe software renderer was being used by default for OpenGL.

I found this thread that recommended disabling some environment variables and unsetting one of these seems to have fixed things.

    GBM_BACKEND = "nvidia-drm";
    GBM_BACKENDS_PATH = "/etc/gbm";
1 Like