Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] performance regression #956

Closed
kojq opened this issue May 21, 2024 · 19 comments
Closed

[BUG] performance regression #956

kojq opened this issue May 21, 2024 · 19 comments
Labels
bug Something isn't working

Comments

@kojq
Copy link
Contributor

kojq commented May 21, 2024

[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 (59c853f).

@kojq kojq added the bug Something isn't working label May 21, 2024
@kojq
Copy link
Contributor Author

kojq commented May 21, 2024

introduced by e9b535d with detectPci(options, gpus, &buffer, &drmDir, entry->d_name);

@kojq
Copy link
Contributor Author

kojq commented May 21, 2024

I see. The issue is with pPciPath++.

@CarterLi
Copy link
Member

can be significantly slower

I can't reproduce it on my laptop with RTX 3070 Ti. e9b535d 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
Copy link
Contributor Author

kojq commented May 22, 2024

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
Copy link
Contributor Author

kojq commented May 22, 2024

I am using nouveau rather than the proprietary drivers.

@CarterLi
Copy link
Member

CarterLi commented May 22, 2024

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

@CarterLi
Copy link
Member

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

@kojq
Copy link
Contributor Author

kojq commented May 22, 2024

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

@CarterLi
Copy link
Member

CarterLi commented May 22, 2024

Really? Is nouveau that slow?

@CarterLi
Copy link
Member

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

@kojq
Copy link
Contributor Author

kojq commented May 22, 2024

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

@kojq
Copy link
Contributor Author

kojq commented May 22, 2024

--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
Copy link
Member

CarterLi commented May 22, 2024

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
Copy link
Contributor Author

kojq commented May 22, 2024

yep. the patch resolves it.

@CarterLi
Copy link
Member

CarterLi commented May 22, 2024

This suggests that nouveau driver is bad

@kojq
Copy link
Contributor Author

kojq commented May 22, 2024

You could do a workaround or simply a wontfix.

@kojq
Copy link
Contributor Author

kojq commented May 22, 2024

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
Copy link
Member

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
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants