btop icon indicating copy to clipboard operation
btop copied to clipboard

[BUG] Setting refresh rate below ~1s doesn't work and btop hogs the input until the next refresh

Open Disr0 opened this issue 11 months ago • 15 comments

Describe the bug

The btop refresh rate seems to be really slow, even when setting it to 100ms. Also btop hogs on the inputs and only does them on the next refresh. Setting refresh rate to a higner value than 1s allows to do inputs that complete without an update, until the next update starts and it again hogs the input.

To Reproduce

  1. Open btop
  2. Do input and see that they're being hogged until the next update
  3. Set refresh rate to 100ms
  4. See that the refresh rate is still way slower than 100ms

Expected behavior

Btop should have been refreshing every 100ms and completing my acitons on input without waiting for the next refresh

Info:

  • btop++ version: 1.3.2
  • Binary: static from release
  • Architecture: x86_64
  • Platform: Linux
  • (Linux) Kernel: 6.7.8-arch1-1
  • Terminal used: kitty / foot
  • Font used: AndaleMo

Additional context

Logs 2024/02/21 (05:41:51) | ===> btop++ v.1.3.2 2024/02/21 (05:41:51) | WARNING: ROCm SMI: Failed to get maximum GPU temperature, defaulting to 110°C 2024/02/21 (05:41:51) | WARNING: ROCm SMI: Failed to get GPU power usage

2024/02/21 (05:42:32) | ===> btop++ v.1.3.2 2024/02/21 (05:42:32) | WARNING: ROCm SMI: Failed to get maximum GPU temperature, defaulting to 110°C 2024/02/21 (05:42:32) | WARNING: ROCm SMI: Failed to get GPU power usage

2024/03/01 (18:57:20) | ===> btop++ v.1.3.2 2024/03/01 (18:57:20) | WARNING: ROCm SMI: Failed to get maximum GPU temperature, defaulting to 110°C 2024/03/01 (18:57:20) | WARNING: ROCm SMI: Failed to get GPU power usage

2024/03/02 (16:54:41) | ===> btop++ v.1.3.2 2024/03/02 (16:54:41) | WARNING: ROCm SMI: Failed to get maximum GPU temperature, defaulting to 110°C 2024/03/02 (16:54:41) | WARNING: ROCm SMI: Failed to get GPU power usage

2024/03/03 (18:23:23) | ===> btop++ v.1.3.2 2024/03/03 (18:23:23) | WARNING: ROCm SMI: Failed to get maximum GPU temperature, defaulting to 110°C 2024/03/03 (18:23:23) | WARNING: ROCm SMI: Failed to get GPU power usage

2024/03/04 (17:55:21) | ===> btop++ v.1.3.2 2024/03/04 (17:55:21) | WARNING: ROCm SMI: Failed to get maximum GPU temperature, defaulting to 110°C 2024/03/04 (17:55:21) | WARNING: ROCm SMI: Failed to get GPU power usage

2024/03/04 (18:17:45) | ===> btop++ v.1.3.2 2024/03/04 (18:17:45) | WARNING: ROCm SMI: Failed to get maximum GPU temperature, defaulting to 110°C 2024/03/04 (18:17:45) | WARNING: ROCm SMI: Failed to get GPU power usage

2024/03/04 (19:01:38) | ===> btop++ v.1.3.2 2024/03/04 (19:01:38) | WARNING: ROCm SMI: Failed to get maximum GPU temperature, defaulting to 110°C 2024/03/04 (19:01:38) | WARNING: ROCm SMI: Failed to get GPU power usage

2024/03/05 (12:54:22) | ===> btop++ v.1.3.2 2024/03/05 (12:54:22) | WARNING: ROCm SMI: Failed to get maximum GPU temperature, defaulting to 110°C 2024/03/05 (12:54:22) | WARNING: ROCm SMI: Failed to get GPU power usage

2024/03/05 (23:38:51) | ===> btop++ v.1.3.2 2024/03/05 (23:38:51) | WARNING: ROCm SMI: Failed to get maximum GPU temperature, defaulting to 110°C 2024/03/05 (23:38:51) | WARNING: ROCm SMI: Failed to get GPU power usage

2024/03/09 (23:26:51) | ===> btop++ v.1.3.2 2024/03/09 (23:26:51) | WARNING: ROCm SMI: Failed to get maximum GPU temperature, defaulting to 110°C 2024/03/09 (23:26:51) | WARNING: ROCm SMI: Failed to get GPU power usage

2024/03/10 (11:10:34) | ===> btop++ v.1.3.2 2024/03/10 (11:10:34) | WARNING: ROCm SMI: Failed to get maximum GPU temperature, defaulting to 110°C 2024/03/10 (11:10:34) | WARNING: ROCm SMI: Failed to get GPU power usage

2024/03/10 (11:13:32) | ===> btop++ v.1.3.2 2024/03/10 (11:13:32) | WARNING: ROCm SMI: Failed to get maximum GPU temperature, defaulting to 110°C 2024/03/10 (11:13:32) | WARNING: ROCm SMI: Failed to get GPU power usage

2024/03/10 (11:15:15) | ===> btop++ v.1.3.2 2024/03/10 (11:15:15) | WARNING: ROCm SMI: Failed to get maximum GPU temperature, defaulting to 110°C 2024/03/10 (11:15:15) | WARNING: ROCm SMI: Failed to get GPU power usage

2024/03/10 (11:15:43) | ===> btop++ v.1.3.2 2024/03/10 (11:15:43) | WARNING: ROCm SMI: Failed to get maximum GPU temperature, defaulting to 110°C 2024/03/10 (11:15:43) | WARNING: ROCm SMI: Failed to get GPU power usage

2024/03/10 (11:17:02) | ===> btop++ v.1.3.2 2024/03/10 (11:17:02) | WARNING: ROCm SMI: Failed to get maximum GPU temperature, defaulting to 110°C 2024/03/10 (11:17:02) | WARNING: ROCm SMI: Failed to get GPU power usage

2024/03/10 (11:17:56) | ===> btop++ v.1.3.2 2024/03/10 (11:17:56) | WARNING: ROCm SMI: Failed to get maximum GPU temperature, defaulting to 110°C 2024/03/10 (11:17:56) | WARNING: ROCm SMI: Failed to get GPU power usage 2024/03/10 (11:18:02) | ERROR: Stall in Runner thread, restarting!

2024/03/10 (11:18:11) | ===> btop++ v.1.3.2 2024/03/10 (11:18:11) | WARNING: ROCm SMI: Failed to get maximum GPU temperature, defaulting to 110°C 2024/03/10 (11:18:11) | WARNING: ROCm SMI: Failed to get GPU power usage

2024/03/10 (11:18:18) | ===> btop++ v.1.3.2 2024/03/10 (11:18:18) | WARNING: ROCm SMI: Failed to get maximum GPU temperature, defaulting to 110°C 2024/03/10 (11:18:18) | WARNING: ROCm SMI: Failed to get GPU power usage

2024/03/10 (11:18:23) | ===> btop++ v.1.3.2 2024/03/10 (11:18:23) | WARNING: ROCm SMI: Failed to get maximum GPU temperature, defaulting to 110°C 2024/03/10 (11:18:23) | WARNING: ROCm SMI: Failed to get GPU power usage

2024/03/10 (11:18:31) | ===> btop++ v.1.3.2 2024/03/10 (11:18:31) | DEBUG: Running in DEBUG mode! 2024/03/10 (11:18:31) | INFO: Logger set to DEBUG 2024/03/10 (11:18:31) | DEBUG: Using locale en_US.UTF-8 2024/03/10 (11:18:31) | INFO: Running on /dev/pts/0 2024/03/10 (11:18:31) | INFO: Failed to load libnvidia-ml.so, NVIDIA GPUs will not be detected: libnvidia-ml.so.1: cannot open shared object file: No such file or directory 2024/03/10 (11:18:31) | WARNING: ROCm SMI: Failed to get maximum GPU temperature, defaulting to 110°C 2024/03/10 (11:18:31) | WARNING: ROCm SMI: Failed to get GPU power usage 2024/03/10 (11:18:32) | DEBUG: Shared::init() : Initialized. 2024/03/10 (11:18:49) | INFO: Quitting! Runtime: 00:00:18

2024/03/10 (11:18:53) | ===> btop++ v.1.3.2 2024/03/10 (11:18:53) | DEBUG: Running in DEBUG mode! 2024/03/10 (11:18:53) | INFO: Logger set to DEBUG 2024/03/10 (11:18:53) | DEBUG: Using locale en_US.UTF-8 2024/03/10 (11:18:53) | INFO: Running on /dev/pts/1 2024/03/10 (11:18:53) | INFO: Failed to load libnvidia-ml.so, NVIDIA GPUs will not be detected: libnvidia-ml.so.1: cannot open shared object file: No such file or directory 2024/03/10 (11:18:53) | WARNING: ROCm SMI: Failed to get maximum GPU temperature, defaulting to 110°C 2024/03/10 (11:18:53) | WARNING: ROCm SMI: Failed to get GPU power usage 2024/03/10 (11:18:54) | DEBUG: Shared::init() : Initialized. 2024/03/10 (11:21:41) | INFO: Quitting! Runtime: 00:02:48

2024/03/10 (11:23:19) | ===> btop++ v.1.3.2 2024/03/10 (11:23:19) | WARNING: ROCm SMI: Failed to get maximum GPU temperature, defaulting to 110°C 2024/03/10 (11:23:19) | WARNING: ROCm SMI: Failed to get GPU power usage

2024/03/10 (11:26:35) | ===> btop++ v.1.3.2 2024/03/10 (11:26:35) | WARNING: ROCm SMI: Failed to get maximum GPU temperature, defaulting to 110°C 2024/03/10 (11:26:35) | WARNING: ROCm SMI: Failed to get GPU power usage 2024/03/10 (11:26:41) | ERROR: Stall in Runner thread, restarting!

2024/03/10 (11:27:15) | ===> btop++ v.1.3.2 2024/03/10 (11:27:15) | WARNING: ROCm SMI: Failed to get maximum GPU temperature, defaulting to 110°C 2024/03/10 (11:27:15) | WARNING: ROCm SMI: Failed to get GPU power usage 2024/03/10 (11:27:31) | ERROR: Exception during Config::unlock() : unordered_map::at

2024/03/10 (11:27:40) | ===> btop++ v.1.3.2 2024/03/10 (11:27:40) | WARNING: ROCm SMI: Failed to get maximum GPU temperature, defaulting to 110°C 2024/03/10 (11:27:40) | WARNING: ROCm SMI: Failed to get GPU power usage 2024/03/10 (11:27:44) | ERROR: Exception during Config::unlock() : unordered_map::at

2024/03/10 (11:28:22) | ===> btop++ v.1.3.2 2024/03/10 (11:28:22) | WARNING: ROCm SMI: Failed to get maximum GPU temperature, defaulting to 110°C 2024/03/10 (11:28:22) | WARNING: ROCm SMI: Failed to get GPU power usage

2024/03/10 (11:29:43) | ===> btop++ v.1.3.2 2024/03/10 (11:29:43) | WARNING: ROCm SMI: Failed to get maximum GPU temperature, defaulting to 110°C 2024/03/10 (11:29:43) | WARNING: ROCm SMI: Failed to get GPU power usage

2024/03/10 (11:30:54) | ===> btop++ v.1.3.2 2024/03/10 (11:30:54) | ERROR: Couldn't determine terminal size of "STDOUT_FILENO"! 2024/03/10 (11:30:54) | WARNING: ROCm SMI: Failed to get maximum GPU temperature, defaulting to 110°C 2024/03/10 (11:30:54) | WARNING: ROCm SMI: Failed to get GPU power usage 2024/03/10 (11:30:55) | ERROR: Couldn't determine terminal size of "STDOUT_FILENO"! 2024/03/10 (11:30:55) | ERROR: Couldn't determine terminal size of "STDOUT_FILENO"! 2024/03/10 (11:30:56) | ERROR: Couldn't determine terminal size of "STDOUT_FILENO"! 2024/03/10 (11:30:57) | ERROR: Couldn't determine terminal size of "STDOUT_FILENO"! 2024/03/10 (11:30:58) | ERROR: Couldn't determine terminal size of "STDOUT_FILENO"!

2024/03/10 (11:31:09) | ===> btop++ v.1.3.2 2024/03/10 (11:31:09) | ERROR: Couldn't determine terminal size of "STDOUT_FILENO"!

2024/03/10 (11:31:17) | ===> btop++ v.1.3.2 2024/03/10 (11:31:17) | ERROR: Couldn't determine terminal size of "STDOUT_FILENO"!

2024/03/10 (11:32:24) | ===> btop++ v.1.3.2 2024/03/10 (11:32:24) | WARNING: ROCm SMI: Failed to get maximum GPU temperature, defaulting to 110°C 2024/03/10 (11:32:24) | WARNING: ROCm SMI: Failed to get GPU power usage`

Disr0 avatar Mar 10 '24 04:03 Disr0

this seems like a performance problem at first glance. could you please check the timings of the individual collect operations? start btop with the --debug flag and you should see a timings block in the top left corner. if one of the operations exceeds 100ms, this is likely the cause. on the other hand it's hard to imagine that this takes longer than a few microseconds.

imwints avatar Mar 10 '24 11:03 imwints

the next step would be to disable gpu support at compile time and check if the problem persists.

imwints avatar Mar 10 '24 11:03 imwints

this seems like a performance problem at first glance. could you please check the timings of the individual collect operations? start btop with the --debug flag and you should see a timings block in the top left corner. if one of the operations exceeds 100ms, this is likely the cause. on the other hand it's hard to imagine that this takes longer than a few microseconds.

image the debug mode output

Disr0 avatar Mar 10 '24 16:03 Disr0

the next step would be to disable gpu support at compile time and check if the problem persists.

removing gpu_support at compilation fixes the issue, thanks! my gpu is rx570, by the way, and i don't experience any issues with it in gpu heavy games and stuff image

Still, the issue with the gpu is kinda strange... btop works fine on my laptop with radeon graphics iGpu...

Disr0 avatar Mar 10 '24 16:03 Disr0

The issue is also seen with nvtop

Disr0 avatar Mar 10 '24 16:03 Disr0

I guess someone has to profile the code with older gpus. i guess this has to do with the api used to query the gpu stats for nvidia, and how it is implemented on your device.

imwints avatar Mar 10 '24 17:03 imwints

I guess someone has to profile the code with older gpus. i guess this has to do with the api used to query the gpu stats for nvidia, and how it is implemented on your device.

@imwints My gpu:

26:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Ellesmere [Radeon RX 470/480/570/570X/580/580X/590] (rev ef)
	Subsystem: Micro-Star International Co., Ltd. [MSI] Radeon RX 580 ARMOR 8G OC
	Kernel driver in use: amdgpu
	Kernel modules: amdgpu

Disr0 avatar Mar 10 '24 19:03 Disr0

i read that as gtx 570 but anyhow it's an older gpu so i guess it's an issue with the driver and/or rocm.

imwints avatar Mar 11 '24 10:03 imwints

but only profiling will help here.

imwints avatar Mar 11 '24 10:03 imwints

Running into the same issue with a Radeon RX 470 on Gentoo. I am seeing similarly high gpu collection time (~2s) when running with --debug. ~/.config/btop/btop.log shows the following:

2024/03/31 (13:21:45) | ===> btop++ v.1.3.0
2024/03/31 (13:21:45) | WARNING: ROCm SMI: Failed to get maximum GPU temperature, defaulting to 110°C
2024/03/31 (13:21:45) | WARNING: ROCm SMI: Failed to get GPU power usage

2024/03/31 (13:38:27) | ===> btop++ v.1.3.2
2024/03/31 (13:38:27) | WARNING: ROCm SMI: Failed to get maximum GPU temperature, defaulting to 110°C
2024/03/31 (13:38:27) | WARNING: ROCm SMI: Failed to get GPU power usage

(Probably unrelated?) but I also get the following error when trying to switch presets:

ERROR: Exception during Config::unlock() : unordered_map::at

Both issues are resolved by uninstalling rocm-smi. I assume this has a similar effect to compiling without gpu monitoring.

david-d-white avatar Mar 31 '24 18:03 david-d-white

Reading the pcie bandwidth on AMDGPU causes the thread to wait for 1s.

https://github.com/Syllo/nvtop/issues/208#issuecomment-1589458154

Umio-Yasuno avatar Apr 22 '24 13:04 Umio-Yasuno

Running into the same issue with a Radeon RX 470 on Gentoo. I am seeing similarly high gpu collection time (~2s) when running with --debug. ~/.config/btop/btop.log shows the following:

2024/03/31 (13:21:45) | ===> btop++ v.1.3.0
2024/03/31 (13:21:45) | WARNING: ROCm SMI: Failed to get maximum GPU temperature, defaulting to 110°C
2024/03/31 (13:21:45) | WARNING: ROCm SMI: Failed to get GPU power usage

2024/03/31 (13:38:27) | ===> btop++ v.1.3.2
2024/03/31 (13:38:27) | WARNING: ROCm SMI: Failed to get maximum GPU temperature, defaulting to 110°C
2024/03/31 (13:38:27) | WARNING: ROCm SMI: Failed to get GPU power usage

(Probably unrelated?) but I also get the following error when trying to switch presets:

ERROR: Exception during Config::unlock() : unordered_map::at

Both issues are resolved by uninstalling rocm-smi. I assume this has a similar effect to compiling without gpu monitoring.

Thanks for hint to remove rocm-smi! On Arch I removed 'rocm-smi-lib' package and btop is working correct now.

My GPU: 04:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Lexa PRO [Radeon 540/540X/550/550X / RX 540X/550/550X] (rev c7) (prog-if 00 [VGA controller]) Subsystem: ASUSTeK Computer Inc. Device 0513

poplawskidaniel avatar May 03 '24 15:05 poplawskidaniel

Either not using rsmi_dev_pci_throughput_get or isolating the threads that use rsmi_dev_pci_throughput_get should fix this issue.

https://github.com/aristocratos/btop/blob/dd4ada7023223c610ccfad48ec3abe0500f91af5/src/linux/btop_collect.cpp#L1555-L1567

Umio-Yasuno avatar May 03 '24 22:05 Umio-Yasuno

I have an amd 580 graphics card and I am having the same things happen to me

znoble360 avatar May 10 '24 01:05 znoble360