Bad performance on AMD Laptop

Hello!

I got NixOs on my laptop recently. But the performance when browsing the web sucks. I can feel the latency when typing and moving the mouse in Chrome (firefox feels right though).

I’m not sre I got hardware acceleration right, or it is something else. Or it is just chrome being chrome.

The laptop is a Thinkpad L14 AMD:

  • AMD Ryzen 7 PRO 5875U with Radeon Graphic
  • 16 G RAM
  • 500 G nvme
  • NixOs

Where should I start debugging this?

I have these in my configuration.nix:

  boot.initrd.kernelModules = [ "amdgpu" ];
  boot.kernelParams = [
    # Force use of the thinkpad_acpi driver for backlight control.
    # This allows the backlight save/load systemd service to work.
    "acpi_backlight=native"

    # AMD CPU scaling
    # https://www.kernel.org/doc/html/latest/admin-guide/pm/amd-pstate.html
    # https://wiki.archlinux.org/title/CPU_frequency_scaling#amd_pstate
    # On recent AMD CPUs this can be more energy efficient.
    "amd_pstate=guided"

    # Load amdgpu at stage 1
    "amdgpu"
  ];

  # AMD GPU
  hardware.opengl.extraPackages = with pkgs; [
    # VA-API and VDPAU
    vaapiVdpau

    # AMD ROCm OpenCL runtime
    rocmPackages.clr
    rocmPackages.clr.icd

    # AMDVLK drivers can be used in addition to the Mesa RADV drivers.
    #amdvlk
  ];
  hardware.opengl.extraPackages32 = with pkgs; [
    driversi686Linux.amdvlk
  ];

  environment.variables = {
    # VAAPI and VDPAU config for accelerated video.
    # See https://wiki.archlinux.org/index.php/Hardware_video_acceleration
    "VDPAU_DRIVER" = "radeonsi";
    "LIBVA_DRIVER_NAME" = "radeonsi";
  };
  # Most software has the HIP libraries hard-coded. Workaround:
  systemd.tmpfiles.rules = [
    "L+    /opt/rocm/hip   -    -    -     -    ${pkgs.rocmPackages.clr}"
  ];

glxgears gives me ~36 FPS on my external monitor and ~45 on the laptop screen.

I can dump here the output of {glx,vdpau,vaapi,vulkan,opencl-}info, is that useful or just spam right now?

1 Like

You could consult chrome://gpu

Just found out vkcube, I get around ~33 FPS in there as well. Similar number to glxgears.

Chrome seems to be a symptom of the problem? (surprised that Firefox has a much better performance in my case).

I think my integrated GPU is somehow not being used.

Edit: Here’s the top part of chrome://gpu:

Graphics Feature Status
=======================
*   Canvas: Hardware accelerated
*   Canvas out-of-process rasterization: Enabled
*   Direct Rendering Display Compositor: *Disabled*
*   Compositing: Hardware accelerated
*   Multiple Raster Threads: Enabled
*   OpenGL: Enabled
*   Rasterization: Hardware accelerated
*   Raw Draw: *Disabled*
*   Skia Graphite: **Disabled**
*   Video Decode: Hardware accelerated
*   Video Encode: *Software only. Hardware acceleration disabled*
*   Vulkan: **Disabled**
*   WebGL: Hardware accelerated
*   WebGL2: Hardware accelerated
*   WebGPU: **Disabled**

I think I got it.

From the Arch Wiki:

On AMD GPU devices, VA-API does not work according to Chromium bug 1445074. A patch is available, but it only works under X11/XWayland.

https://issues.chromium.org/issues/40267998

I think that’s part of it. glxgears and vkcubes performance is very low, there’s something missing in there. Chrome being slow maybe because uses one of those APIs to render?

1 Like

I actually have decent performance on both Vivaldi and Brave on my AMD Vega 8 laptop :man_shrugging: