Improve comment

This commit is contained in:
nicolargo 2022-09-11 12:16:30 +02:00
parent d8a00d73a2
commit 5a1315130b
2 changed files with 7 additions and 4 deletions

View File

@ -513,6 +513,8 @@ class Plugin(GlancesPlugin):
# Process list
# Loop over processes (sorted by the sort key previously compute)
# This is a Glances bottleneck (see flame graph),
# get_process_curses_data should be optimzed
i = 0
for p in self.__sort_stats(process_sort_key):
ret.extend(self.get_process_curses_data(p, i == args.cursor_position, args))

View File

@ -253,6 +253,7 @@ class GlancesProcesses(object):
#####################
sorted_attrs = ['cpu_percent', 'cpu_times', 'memory_percent', 'name', 'status', 'num_threads']
displayed_attr = ['memory_info', 'nice', 'pid']
# 'name' can not be cached because it is used for filtering
cached_attrs = ['cmdline', 'username']
# Some stats are optional
@ -274,14 +275,14 @@ class GlancesProcesses(object):
is_cached = True
# Build the processes stats list (it is why we need psutil>=5.3.0)
# This is on of the main bottleneck of Glances (see flame graph)
self.processlist = [
p.info
for p in psutil.process_iter(attrs=sorted_attrs, ad_value=None)
# OS-related processes filter
if not (BSD and p.info['name'] == 'idle')
and not (WINDOWS and p.info['name'] == 'System Idle Process')
and not (MACOS and p.info['name'] == 'kernel_task')
and
if not (BSD and p.info['name'] == 'idle') and
not (WINDOWS and p.info['name'] == 'System Idle Process') and
not (MACOS and p.info['name'] == 'kernel_task') and
# Kernel threads filter
not (self.no_kernel_threads and LINUX and p.info['gids'].real == 0)
]