Open webcaptcha opened 5 months ago
The CPU percentage displayed is per core, so when you have 16 CPU core (or threads) active, the maximum would be 1600%. Do you consider this takes too much CPU usage?
@webcaptcha are you using the default sampling interval (1.5s) or something more frequent? Looks like you have over 2000 processes running there - visiting each in /proc does take a small amount of time and it all adds up. You might find some additional insights by adding the UTIME and STIME columns and observing htop there as well (I expect you'll see much higher kernel time than user time).
Can you provide a copy of your htoprc
configuration file?
Same for me on Fedora and Debian. Even though I have 8C/16T, laptop at the summer just burns your knees, so you have to monitor what to close, and htop just shouldn't be running in the background. Not critical, but others do not experience high CPU usage by htop itself. I also did not find any relevant bug reports except this one.
My thoughts at first was that this high CPU usage is just at this exact point of the time when it refreshes info, but top shows exactly the same with independent refresh rate.
Here is mine ~/.config/htop/htoprc
, I hope it helps.
``` # Beware! This file is rewritten by htop when settings are changed in the interface. # The parser is also very primitive, and not human-friendly. htop_version=3.2.2 config_reader_min_version=3 fields=0 48 17 18 38 39 40 2 46 47 49 1 hide_kernel_threads=1 hide_userland_threads=1 hide_running_in_container=0 shadow_other_users=0 show_thread_names=0 show_program_path=1 highlight_base_name=0 highlight_deleted_exe=1 shadow_distribution_path_prefix=0 highlight_megabytes=1 highlight_threads=1 highlight_changes=0 highlight_changes_delay_secs=5 find_comm_in_cmdline=1 strip_exe_from_cmdline=1 show_merged_command=0 header_margin=1 screen_tabs=1 detailed_cpu_time=0 cpu_count_from_one=0 show_cpu_usage=1 show_cpu_frequency=1 show_cpu_temperature=1 degree_fahrenheit=0 update_process_names=0 account_guest_in_cpu_meter=0 color_scheme=0 enable_mouse=1 delay=15 hide_function_bar=0 header_layout=two_50_50 column_meters_0=LeftCPUs2 Memory Swap column_meter_modes_0=1 1 1 column_meters_1=RightCPUs2 Tasks LoadAverage Uptime column_meter_modes_1=1 2 2 2 tree_view=0 sort_key=46 tree_sort_key=0 sort_direction=-1 tree_sort_direction=1 tree_view_always_by_pid=0 all_branches_collapsed=0 screen:Main=PID USER PRIORITY NICE M_VIRT M_RESIDENT M_SHARE STATE PERCENT_CPU PERCENT_MEM TIME Command .sort_key=PERCENT_CPU .tree_sort_key=PID .tree_view=0 .tree_view_always_by_pid=0 .sort_direction=-1 .tree_sort_direction=1 .all_branches_collapsed=0 screen:I/O=PID USER IO_PRIORITY IO_RATE IO_READ_RATE IO_WRITE_RATE PERCENT_SWAP_DELAY PERCENT_IO_DELAY Command .sort_key=IO_RATE .tree_sort_key=PID .tree_view=0 .tree_view_always_by_pid=0 .sort_direction=-1 .tree_sort_direction=1 .all_branches_collapsed=0 ```
I did not changed default refresh rate, I have only added sensors info, CPU frequency, majfaults and "hide userland process threads" or something like that.
Forgot to mention, my CPU is AMD too: AMD Ryzen 7 5800U
. I don't remember that I had this issue with Intel before.
Could you try to disable CPU frequency or CPU temperature and check whether the behavior persists.
Tried to disable both CPU frequency and CPU temperature and restarting htop, CPU usage is the same before and after, behavior persisted.
![image](https://github.com/user-attachments/assets/e4e43b47-3cff-4aa6-a493-7b3671e81112) ![image](https://github.com/user-attachments/assets/48564d0e-f176-4aef-85ab-962dade90713)
Collected gprof output with:
./autogen.sh
CFLAGS="-g -O2 -pg" ./configure
make
./htop
gprof ./htop gmon.out > gprof_output.txt
```
Flat profile:
Each sample counts as 0.01 seconds.
% cumulative self self total
time seconds seconds calls ms/call ms/call name
75.00 0.15 0.15 25 6.00 6.00 LinuxProcessTable_readOomData
15.00 0.18 0.03 52200 0.00 0.00 Process_makeCommandStr
5.00 0.19 0.01 1293233 0.00 0.00 Process_compare
5.00 0.20 0.01 1293233 0.00 0.00 compareRealNumbers
0.00 0.20 0.00 1293233 0.00 0.00 LinuxProcess_compareByKey
0.00 0.20 0.00 1293233 0.00 0.00 Process_compareByKey_Base
0.00 0.20 0.00 58910 0.00 0.00 fast_strtoll_dec.constprop.0
0.00 0.20 0.00 52611 0.00 0.00 Hashtable_get
0.00 0.20 0.00 52200 0.00 0.00 Table_cleanupRow
0.00 0.20 0.00 52181 0.00 0.00 ProcessTable_getProcess
0.00 0.20 0.00 50094 0.00 0.00 Vector_add
0.00 0.20 0.00 16782 0.00 0.00 readfd_internal
0.00 0.20 0.00 16710 0.00 0.00 xReadfileat
0.00 0.20 0.00 14202 0.00 0.00 Row_updateFieldWidth
0.00 0.20 0.00 11671 0.00 0.00 RichString_setLen
0.00 0.20 0.00 8945 0.00 0.00 xSnprintf
0.00 0.20 0.00 7101 0.00 0.00 GPUMeter_active
0.00 0.20 0.00 7101 0.00 0.00 Process_updateCPUFieldWidths
0.00 0.20 0.00 7101 0.00 0.00 String_safeStrncpy
0.00 0.20 0.00 6578 0.00 0.00 LinuxProcess_rowWriteField
0.00 0.20 0.00 6072 0.00 0.00 Process_writeField
0.00 0.20 0.00 5605 0.00 0.00 RichString_appendnAscii
0.00 0.20 0.00 4789 0.00 0.00 Panel_set
0.00 0.20 0.00 4789 0.00 0.00 Process_rowMatchesFilter
0.00 0.20 0.00 4789 0.00 0.00 Vector_set
0.00 0.20 0.00 4234 0.00 0.00 xStrdup
0.00 0.20 0.00 4070 0.00 0.00 xCalloc
0.00 0.20 0.00 3175 0.00 0.00 RichString_appendAscii
0.00 0.20 0.00 2322 0.00 0.00 Process_updateCmdline
0.00 0.20 0.00 2114 0.00 0.00 insert
0.00 0.20 0.00 2111 0.00 0.00 Hashtable_put
0.00 0.20 0.00 2107 0.00 0.00 RichString_setAttrn
0.00 0.20 0.00 2102 0.00 0.00 LinuxProcess_new
0.00 0.20 0.00 2102 0.00 0.00 Process_delete
0.00 0.20 0.00 2102 0.00 0.00 Process_done
0.00 0.20 0.00 2102 0.00 0.00 Process_fillStarttimeBuffer
0.00 0.20 0.00 2102 0.00 0.00 Process_init
0.00 0.20 0.00 2102 0.00 0.00 Row_init
0.00 0.20 0.00 2102 0.00 0.00 Table_add
0.00 0.20 0.00 1882 0.00 0.00 LinuxProcessList_readComm
0.00 0.20 0.00 1882 0.00 0.00 LinuxProcessTable_readCmdlineFile
0.00 0.20 0.00 1882 0.00 0.00 Process_updateComm
0.00 0.20 0.00 1842 0.00 0.00 Process_updateExe
0.00 0.20 0.00 1583 0.00 0.00 Compat_faccessat
0.00 0.20 0.00 1518 0.00 0.00 Row_printKBytes
0.00 0.20 0.00 1463 0.00 0.00 mbstowcs_nonfatal
0.00 0.20 0.00 1012 0.00 0.00 Row_printPercentage
0.00 0.20 0.00 990 0.00 0.00 RichString_delete
0.00 0.20 0.00 934 0.00 0.00 RichString_appendWide
0.00 0.20 0.00 920 0.00 0.00 RichString_appendChr
0.00 0.20 0.00 506 0.00 0.00 Process_rowIsHighlighted
0.00 0.20 0.00 506 0.00 0.00 Process_writeCommand
0.00 0.20 0.00 506 0.00 0.00 RichString_appendnWideColumns
0.00 0.20 0.00 506 0.00 0.00 Row_display
0.00 0.20 0.00 506 0.00 0.00 Row_printBytes
0.00 0.20 0.00 506 0.00 0.00 Row_printCount
0.00 0.20 0.00 506 0.00 0.00 Row_printLeftAlignedField
0.00 0.20 0.00 506 0.00 0.00 Row_printTime
0.00 0.20 0.00 430 0.00 0.00 UsersTable_getRef
0.00 0.20 0.00 414 0.00 0.00 BarMeterMode_draw
0.00 0.20 0.00 403 0.00 0.00 xReallocArrayZero
0.00 0.20 0.00 368 0.00 0.00 CPUMeter_updateValues
0.00 0.20 0.00 368 0.00 0.00 Platform_setCPUValues
0.00 0.20 0.00 368 0.00 0.00 sumPositiveValues
0.00 0.20 0.00 203 0.00 0.00 xMalloc
0.00 0.20 0.00 98 0.00 0.00 xReadfile
0.00 0.20 0.00 92 0.00 0.00 Meter_humanUnit
0.00 0.20 0.00 69 0.00 0.00 String_freeArray
0.00 0.20 0.00 69 0.00 0.00 String_split
0.00 0.20 0.00 69 0.00 0.00 TextMeterMode_draw
0.00 0.20 0.00 64 0.00 0.00 String_readLine
0.00 0.20 0.00 48 0.00 0.00 Vector_prune
0.00 0.20 0.00 46 0.00 0.00 AllCPUsMeter_updateValues
0.00 0.20 0.00 46 0.00 0.00 DualColCPUsMeter_draw
0.00 0.20 0.00 46 0.00 0.00 Meter_setMode
0.00 0.20 0.00 46 0.00 0.00 SingleColCPUsMeter_draw
0.00 0.20 0.00 46 0.00 0.00 drawTab
0.00 0.20 0.00 36 0.00 0.00 xAsprintf
0.00 0.20 0.00 32 0.00 0.00 CPUMeter_init
0.00 0.20 0.00 32 0.00 0.00 Meter_setCaption
0.00 0.20 0.00 32 0.00 0.00 free_and_xStrdup
0.00 0.20 0.00 26 0.00 0.00 LinuxMachine_updateCPUcount
0.00 0.20 0.00 26 0.00 0.00 toFieldIndex
0.00 0.20 0.00 25 0.00 0.00 Generic_gettime_realtime
0.00 0.20 0.00 25 0.00 0.00 LinuxMachine_scanCPUTime
0.00 0.20 0.00 25 0.00 0.00 Machine_scan
0.00 0.20 0.00 25 0.00 7.20 Machine_scanTables
0.00 0.20 0.00 25 0.00 1.20 ProcessTable_cleanupEntries
0.00 0.20 0.00 25 0.00 0.00 ProcessTable_goThroughEntries
0.00 0.20 0.00 25 0.00 0.00 ProcessTable_iterateEntries
0.00 0.20 0.00 25 0.00 0.00 ProcessTable_prepareEntries
0.00 0.20 0.00 25 0.00 0.00 Row_resetFieldWidths
0.00 0.20 0.00 25 0.00 0.00 Row_setUidColumnWidth
0.00 0.20 0.00 25 0.00 0.00 Table_prepareEntries
0.00 0.20 0.00 25 0.00 0.00 Vector_compact
0.00 0.20 0.00 24 0.00 0.00 Generic_gettime_monotonic
0.00 0.20 0.00 24 0.00 0.00 MainPanel_eventHandler
0.00 0.20 0.00 23 0.00 0.00 FunctionBar_draw
0.00 0.20 0.00 23 0.00 0.00 FunctionBar_drawExtra
0.00 0.20 0.00 23 0.00 0.00 Header_draw
0.00 0.20 0.00 23 0.00 0.00 Header_updateData
0.00 0.20 0.00 23 0.00 0.00 IncSet_drawBar
0.00 0.20 0.00 23 0.00 0.00 LoadAverageMeter_display
0.00 0.20 0.00 23 0.00 0.00 LoadAverageMeter_updateValues
0.00 0.20 0.00 23 0.00 0.00 MainPanel_drawFunctionBar
0.00 0.20 0.00 23 0.00 0.00 MemoryMeter_updateValues
0.00 0.20 0.00 23 0.00 0.00 Meter_delete
0.00 0.20 0.00 23 0.00 0.00 Meter_new
0.00 0.20 0.00 23 0.00 0.00 Panel_draw
0.00 0.20 0.00 23 0.00 0.00 Panel_getCh
0.00 0.20 0.00 23 0.00 0.00 Panel_getSelectedIndex
0.00 0.20 0.00 23 0.00 0.00 Panel_prune
0.00 0.20 0.00 23 0.00 0.00 Panel_setSelected
0.00 0.20 0.00 23 0.00 0.00 Panel_size
0.00 0.20 0.00 23 0.00 0.00 Platform_getLoadAverage
0.00 0.20 0.00 23 0.00 0.00 Platform_getUptime
0.00 0.20 0.00 23 0.00 0.00 Platform_setMemoryValues
0.00 0.20 0.00 23 0.00 0.00 Platform_setSwapValues
0.00 0.20 0.00 23 0.00 0.00 RichString_setAttr
0.00 0.20 0.00 23 0.00 0.00 RichString_writeWide
0.00 0.20 0.00 23 0.00 0.00 SwapMeter_updateValues
0.00 0.20 0.00 23 0.00 0.87 Table_rebuildPanel
0.00 0.20 0.00 23 0.00 0.87 Table_updateDisplayList
0.00 0.20 0.00 23 0.00 0.00 TasksMeter_display
0.00 0.20 0.00 23 0.00 0.00 TasksMeter_updateValues
0.00 0.20 0.00 23 0.00 0.00 UptimeMeter_updateValues
0.00 0.20 0.00 23 0.00 0.87 Vector_insertionSort
0.00 0.20 0.00 19 0.00 0.00 Hashtable_remove
0.00 0.20 0.00 19 0.00 0.00 Vector_softRemove
0.00 0.20 0.00 13 0.00 0.00 RowField_alignedTitle
0.00 0.20 0.00 6 0.00 0.00 String_trim
0.00 0.20 0.00 6 0.00 0.00 Vector_delete
0.00 0.20 0.00 6 0.00 0.00 Vector_new
0.00 0.20 0.00 4 0.00 0.00 FunctionBar_delete
0.00 0.20 0.00 4 0.00 0.00 FunctionBar_new
0.00 0.20 0.00 4 0.00 0.00 String_cat
0.00 0.20 0.00 3 0.00 0.00 Hashtable_clear
0.00 0.20 0.00 3 0.00 0.00 Hashtable_delete
0.00 0.20 0.00 3 0.00 0.00 Hashtable_new
0.00 0.20 0.00 3 0.00 0.00 Object_isA
0.00 0.20 0.00 3 0.00 0.00 xRealloc
0.00 0.20 0.00 2 0.00 0.00 AllCPUsMeter_done
0.00 0.20 0.00 2 0.00 0.00 CPUMeterCommonInit
0.00 0.20 0.00 2 0.00 0.00 CPUMeterCommonUpdateMode
0.00 0.20 0.00 2 0.00 0.00 DualColCPUsMeter_updateMode
0.00 0.20 0.00 2 0.00 0.00 FunctionBar_setLabel
0.00 0.20 0.00 2 0.00 0.00 RichString_rewind
0.00 0.20 0.00 2 0.00 0.00 ScreenSettings_readFields
0.00 0.20 0.00 2 0.00 0.00 Settings_initScreenSettings.constprop.0
0.00 0.20 0.00 2 0.00 0.00 Settings_newScreen
0.00 0.20 0.00 2 0.00 0.00 Settings_readMeterModes
0.00 0.20 0.00 2 0.00 0.00 signal_safe_fprintf
0.00 0.20 0.00 2 0.00 0.00 xMallocArray
0.00 0.20 0.00 1 0.00 0.00 Action_setBindings
0.00 0.20 0.00 1 0.00 0.00 CRT_done
0.00 0.20 0.00 1 0.00 0.00 CRT_init
0.00 0.20 0.00 1 0.00 0.00 CRT_resetSignalHandlers
0.00 0.20 0.00 1 0.00 0.00 CRT_setColors
0.00 0.20 0.00 1 0.00 0.00 DynamicColumns_delete
0.00 0.20 0.00 1 0.00 0.00 DynamicColumns_new
0.00 0.20 0.00 1 0.00 0.00 DynamicMeters_delete
0.00 0.20 0.00 1 0.00 0.00 DynamicMeters_new
0.00 0.20 0.00 1 0.00 0.00 DynamicScreens_delete
0.00 0.20 0.00 1 0.00 0.00 DynamicScreens_new
0.00 0.20 0.00 1 0.00 0.00 FunctionBar_synthesizeEvent
0.00 0.20 0.00 1 0.00 0.00 Header_calculateHeight
0.00 0.20 0.00 1 0.00 0.00 Header_delete
0.00 0.20 0.00 1 0.00 0.00 Header_new
0.00 0.20 0.00 1 0.00 0.00 Header_populateFromSettings
0.00 0.20 0.00 1 0.00 0.00 Header_setLayout
0.00 0.20 0.00 1 0.00 0.00 IncSet_delete
0.00 0.20 0.00 1 0.00 0.00 IncSet_new
0.00 0.20 0.00 1 0.00 0.00 LinuxProcessTable_initTtyDrivers
0.00 0.20 0.00 1 0.00 0.00 Machine_delete
0.00 0.20 0.00 1 0.00 0.00 Machine_done
0.00 0.20 0.00 1 0.00 0.00 Machine_init
0.00 0.20 0.00 1 0.00 0.00 Machine_new
0.00 0.20 0.00 1 0.00 0.00 Machine_populateTablesFromSettings
0.00 0.20 0.00 1 0.00 0.00 Machine_setTablesPanel
0.00 0.20 0.00 1 0.00 0.00 MainPanel_delete
0.00 0.20 0.00 1 0.00 0.00 MainPanel_new
0.00 0.20 0.00 1 0.00 0.00 MainPanel_printHeader
0.00 0.20 0.00 1 0.00 0.00 MainPanel_setState
0.00 0.20 0.00 1 0.00 0.00 MainPanel_updateLabels
0.00 0.20 0.00 1 0.00 0.00 MetersPanel_cleanup
0.00 0.20 0.00 1 0.00 0.00 Panel_done
0.00 0.20 0.00 1 0.00 0.00 Panel_init
0.00 0.20 0.00 1 0.00 0.00 Panel_move
0.00 0.20 0.00 1 0.00 0.00 Panel_resize
0.00 0.20 0.00 1 0.00 0.00 Platform_done
0.00 0.20 0.00 1 0.00 0.00 Platform_getMaxPid
0.00 0.20 0.00 1 0.00 0.00 Platform_init
0.00 0.20 0.00 1 0.00 0.00 Platform_setBindings
0.00 0.20 0.00 1 0.00 0.00 ProcessTable_delete
0.00 0.20 0.00 1 0.00 0.00 ProcessTable_done
0.00 0.20 0.00 1 0.00 0.00 ProcessTable_init
0.00 0.20 0.00 1 0.00 0.00 ProcessTable_new
0.00 0.20 0.00 1 0.00 0.00 Row_setPidColumnWidth
0.00 0.20 0.00 1 0.00 0.00 ScreenManager_add
0.00 0.20 0.00 1 0.00 0.00 ScreenManager_delete
0.00 0.20 0.00 1 0.00 0.00 ScreenManager_insert
0.00 0.20 0.00 1 0.00 0.00 ScreenManager_new
0.00 0.20 0.00 1 0.00 185.61 ScreenManager_run
0.00 0.20 0.00 1 0.00 0.00 Settings_delete
0.00 0.20 0.00 1 0.00 0.00 Settings_deleteColumns
0.00 0.20 0.00 1 0.00 0.00 Settings_isReadonly
0.00 0.20 0.00 1 0.00 0.00 Settings_new
0.00 0.20 0.00 1 0.00 0.00 Settings_read
0.00 0.20 0.00 1 0.00 0.00 Table_done
0.00 0.20 0.00 1 0.00 0.00 Table_init
0.00 0.20 0.00 1 0.00 0.00 Table_printHeader
0.00 0.20 0.00 1 0.00 0.00 Table_setPanel
0.00 0.20 0.00 1 0.00 0.00 UsersTable_delete
0.00 0.20 0.00 1 0.00 0.00 UsersTable_new
0.00 0.20 0.00 1 0.00 0.00 Vector_insert
0.00 0.20 0.00 1 0.00 0.00 actionQuit
0.00 0.20 0.00 1 0.00 0.00 xReallocArray
% the percentage of the total running time of the
time program used by this function.
cumulative a running sum of the number of seconds accounted
seconds for by this function and those listed above it.
self the number of seconds accounted for by this
seconds function alone. This is the major sort for this
listing.
calls the number of times this function was invoked, if
this function is profiled, else blank.
self the average number of milliseconds spent in this
ms/call function per call, if this function is profiled,
else blank.
total the average number of milliseconds spent in this
ms/call function and its descendents per call, if this
function is profiled, else blank.
name the name of the function. This is the minor sort
for this listing. The index shows the location of
the function in the gprof listing. If the index is
in parenthesis it shows where it would appear in
the gprof listing if it were to be printed.
Copyright (C) 2012-2023 Free Software Foundation, Inc.
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved.
Call graph (explanation follows)
granularity: each sample hit covers 2 byte(s) for 5.00% of 0.20 seconds
index % time self children called name
This fixes high load:
Subject: [PATCH] Commented function
---
Index: linux/LinuxProcessTable.c
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/linux/LinuxProcessTable.c b/linux/LinuxProcessTable.c
--- a/linux/LinuxProcessTable.c (revision fc54b885ef75b8edacc4a9758f29b51e16025d34)
+++ b/linux/LinuxProcessTable.c (date 1725503862876)
@@ -629,6 +629,7 @@
* Read /proc/<pid>/maps (process-shared data)
*/
static void LinuxProcessTable_readMaps(LinuxProcess* process, openat_arg_t procFd, const LinuxMachine* host, bool calcSize, bool checkDeletedLib) {
+ return;
Process* proc = (Process*)process;
proc->usesDeletedLib = false;
Before fix
Maybe changing buffer size will help, but I do not care. So htop relays on procfs? But why it even reads /maps?
There are two reasons for reading /proc/<pid>/maps
:
The problem with these is BTW not the routine itself, but that the kernel is slow in providing these information. The parsing of these lines is already heavily optimized to avoid slow libc functions where ever possible.
Nice useful features! Can I disable them?
Yes.
Unchecking "Highlight out-dated/removed programs (red) / libraries (yellow)" is the solution of this issue for me!
For me unchecking "Highlight out-dated/removed programs (red) / libraries (yellow)" only reduces the cpu load. If the feature is enabled htop shows 50% cpu load and after disabling it it's about 30%. htop 3.3.0 Operating System: Fedora Linux 40 KDE Plasma Version: 6.1.5 KDE Frameworks Version: 6.6.0 Qt Version: 6.7.2 Kernel Version: 6.10.10-200.fc40.x86_64 (64-bit) Graphics Platform: Wayland Processors: 8 × Intel® Core™ i7-4790 CPU @ 3.60GHz Memory: 15.5 GiB of RAM Graphics Processor: AMD Radeon RX 5700 Manufacturer: ASUS Product Name: All Series
Sorry for some delay from my side. Here in Ukraine the life is funny
with option "Highlight out-dated/removed programs (red) / libraries (yellow)" disabled wtih enabled
Not much differences
Here is my config
Does hitting Shift+H (disable showing threads) help?
Does hitting Shift+H (disable showing threads) help?
cpu consumption reduces by 2, was about 11-14, with shigt+h its 5-7
I'm on KDE Plasma on Wayland session
Terminal emulator - Alacritty When I run htop it's usually shows around 15% CPU with peaks up to 25%
Is it ok? For example on the screenshot at the same time Firefox was playing video.
If it needed I can make a video but almost all time it uses than numbers of CPU
CPU - AMD 7840HS GPU - intergrated RAM - 32GB
htop default config