fastfetch-cli / fastfetch

An actively maintained, feature-rich and performance oriented, neofetch like system information tool.
MIT License
9.96k stars 398 forks source link

[BUG] performance regression #956

Closed kojq closed 4 months ago

kojq commented 4 months ago

[ALPM] upgraded fastfetch (2.12.0-1 -> 2.13.0-1) [ALPM] upgraded fastfetch (2.13.0-1 -> 2.13.1-1)

Introduced either 2.13.0 or 2.13.1, fastfetch can be significantly slower outputting from the GPU line and onward, so I suspect some recent commit regarding GPU (Linux) (on NVIDIA). It occurs on git as well (https://github.com/fastfetch-cli/fastfetch/commit/59c853fb0172d12a0fe286625fa2bdbbdf7d1e14).

kojq commented 4 months ago

introduced by https://github.com/fastfetch-cli/fastfetch/commit/e9b535d2776ffed04b069283e6846744ba6a8b8d with detectPci(options, gpus, &buffer, &drmDir, entry->d_name);

kojq commented 4 months ago

I see. The issue is with pPciPath++.

CarterLi commented 4 months ago

can be significantly slower

I can't reproduce it on my laptop with RTX 3070 Ti. e9b535d2776ffed04b069283e6846744ba6a8b8d should not make much difference of performance. The major difference introduced in 2.13.0 is https://github.com/fastfetch-cli/fastfetch/blob/dev/src/detection/gpu/gpu_linux.c#L40-L52 which tries to call the DRM driver of nvidia GPU. It is only used to grab a driver name and version but should not affect performance too.

You may try --gpu-detection-method pci, which effectively avoids calling the DRM driver. Please paste the result of hyperfine 'fastfetch -s gpu -l none' 'fastfetch -s gpu -l none --gpu-detection-method pci'

kojq commented 4 months ago

I don't think hyperfine output would be useful as you have to wait a couple of seconds and not use fastfetch in immediate succession for this to occur. The flag to avoid calling the DRM driver does resolve the issue though.

kojq commented 4 months ago

I am using nouveau rather than the proprietary drivers.

CarterLi commented 4 months ago

How much time does it cost? --stat should print time usage for individual modules.

CarterLi commented 4 months ago

What does fastfetch -s gpu --format json --stat print?

kojq commented 4 months ago

1-2 seconds. I'm currently on mobile with no computer, so can't give output now. Will do later.

CarterLi commented 4 months ago

Really? Is nouveau that slow?

CarterLi commented 4 months ago

Anyway, if you can confirm where the problem is, I can cut a hotfix release today.

kojq commented 4 months ago

I can try to get back to you with the output within an hour from now. Otherwise, will be tomorrow.

kojq commented 4 months ago

--stat

 `+sso+:-`                 `.-/+oso:     Terminal: foot 1.17.2                                                                                                                                                                            2ms
`++:.                           `-/+/    Terminal Font: monospace (8pt)                                                                                                                                                                   0ms
.`                                 `/    CPU: AMD Ryzen 9 5900HS (16) @ 4.68 GHz                                                                                                                                                          1ms
                                         GPU 1: NVIDIA GeForce RTX 3060 Mobile / Max-Q [Discrete]
                                         GPU 2: AMD Radeon Vega Series / Radeon Vega Mobile Series @ 0.40 GHz [Integrated]                                                                                                             1546ms
                                         Memory: 1.85 GiB / 15.03 GiB (12%)                                                                                                                                                               0ms

-s gpu --format json --stat

[
  {
    "type": "GPU",
    "result": [
      {
        "coreCount": null,
        "memory": {
          "dedicated": {
            "total": null,
            "used": null
          },
          "shared": {
            "total": null,
            "used": null
          }
        },
        "driver": "nouveau 1.4.0",
        "name": "GeForce RTX 3060 Mobile / Max-Q",
        "temperature": null,
        "type": "Discrete",
        "vendor": "NVIDIA",
        "platformApi": "DRM (card1)",
        "frequency": null
      },
      {
        "coreCount": null,
        "memory": {
          "dedicated": {
            "total": null,
            "used": null
          },
          "shared": {
            "total": null,
            "used": null
          }
        },
        "driver": "amdgpu 3.57.0",
        "name": "Radeon Vega Series / Radeon Vega Mobile Series",
        "temperature": null,
        "type": "Integrated",
        "vendor": "AMD",
        "platformApi": "DRM (card2)",
        "frequency": 0.4
      }
    ],
    "stat": 1544
  }
]
CarterLi commented 4 months ago

Does this patch fix your issue?

diff --git a/src/detection/gpu/gpu_linux.c b/src/detection/gpu/gpu_linux.c
index 9387ce4e..5f6e93dd 100644
--- a/src/detection/gpu/gpu_linux.c
+++ b/src/detection/gpu/gpu_linux.c
@@ -70,7 +70,7 @@ static const char* drmDetectDriver(FFGPUResult* gpu, FFstrbuf* pciDir, FFstrbuf*
 static bool pciDetectDriver(FFGPUResult* gpu, FFstrbuf* pciDir, FFstrbuf* buffer, FF_MAYBE_UNUSED const char* drmKey)
 {
     #if FF_HAVE_DRM_H
-    if (drmKey)
+    if (drmKey && !ffStrEquals(drmKey, "card1"))
     {
         drmDetectDriver(gpu, pciDir, buffer, drmKey);
         if (gpu->driver.length > 0) return true;
kojq commented 4 months ago

yep. the patch resolves it.

CarterLi commented 4 months ago

This suggests that nouveau driver is bad

kojq commented 4 months ago

You could do a workaround or simply a wontfix.

kojq commented 4 months ago

FYI, prior to turing cards using nouveau will probably be the ones affected, as our cards can use NVK with mesa 24.1+ (which I suspect would have better performance). Anyway, gtg. Ciao.

CarterLi commented 4 months ago

You could do a workaround

The only workaround is that we dont try to call DRM drivers for nouveau.

However we dont know if it is nouveau if we dont ask the driver.

CarterLi commented 4 months ago

which I suspect would have better performance

We only ask for driver name and version but nothing else. I didnt know it is that hard to tell who and how old the nouveau driver is.