glances icon indicating copy to clipboard operation
glances copied to clipboard

Is 25% CPU usage for glances normal?

Open nahmias22 opened this issue 4 years ago • 14 comments

To whom it may concern,

Is it normal to have 25% CPU usage for glances alone when running it as glances -w?

nahmias22 avatar Mar 31 '21 07:03 nahmias22

25% ? That's nothing....

image

GiganteX avatar Apr 01 '21 08:04 GiganteX

Hi @nahmias22

on my system, Glances take 7% of one CPU:

Selection_004

Try to disable some plugins on the server side to find the guilty:

glances -w --disable-plugin ports,sensors

Note: the plugins list can be display using:

glances --modules-list

Nicolas

nicolargo avatar Apr 01 '21 09:04 nicolargo

I think you'll find it's the process list. Win10 running latest Glances on Python 39 and with the default refresh, process list shows CPU for the python process at around 35% (Win Task Manager shows python CPU usage at 7-10%). Hit 'z' to turn off process list and Glances drops to 5% CPU total for the python process (and Win Task Manager drops the python process down to about 0.3%)

deefrawley avatar Apr 15 '21 08:04 deefrawley

@nahmias22 / @deefrawley : i just upload a new beta version (3.1.7b1) on Pypi test (pip install -i https://test.pypi.org/simple/ Glances). This version has a new --issue option. Can you please install and run Glances with this new option. It will start and stop Glances and display stats like that:

image

Can you please copy/paste the result ?

nicolargo avatar Apr 24 '21 09:04 nicolargo

===========================================================
Glances version 3.1.7b1 with PsUtil 5.8.0
===========================================================
alert         [OK]    0.0000s []
amps          [OK]    0.0000s []
cloud         [OK]    0.0000s {}
connections   [OK]    0.0010s {'LISTEN': 36, 'ESTABLISHED': 24, 'SYN_SENT': 0, 'SYN_RECV':
core          [OK]    0.0000s {'phys': 6, 'log': 6}
cpu           [OK]    0.0000s {'total': 15.0, 'user': 6.5, 'system': 10.0, 'idle': 82.9, '
diskio        [OK]    0.0010s [{'time_since_update': 1, 'disk_name': 'PhysicalDrive0', 're
docker        [OK]    0.0000s []
folders       [OK]    0.0000s []
fs            [OK]    0.0010s [{'device_name': 'C:\\', 'fs_type': 'NTFS', 'mnt_point': 'C:
gpu           [OK]    0.0080s [{'key': 'gpu_id', 'gpu_id': 0, 'name': 'NVIDIA GeForce GTX
help          [OK]    0.0000s None
ip            [OK]    0.0000s {}
irq           [OK]    0.0000s []
load          [OK]    0.0000s {'min1': 0.0, 'min5': 0.0, 'min15': 0.0, 'cpucore': 6}
mem           [OK]    0.0000s {'total': 17121140736, 'available': 10251096064, 'percent':
memswap       [OK]    0.0000s {'total': 20208148480, 'used': 10335367168, 'free': 98727813
network       [OK]    0.0150s [{'interface_name': 
now           [OK]    0.0000s 2021-04-26 10:27:27 +1000
percpu        [OK]    0.0010s [{'key': 'cpu_number', 'cpu_number': 0, 'total': 17.1, 'user
ports         [OK]    0.0000s []
processcount  [OK]    0.9899s {'total': 224, 'running': 217, 'sleeping': 0, 'thread': 2717
processlist   [OK]    0.0000s [{'nice': <Priority.NORMAL_PRIORITY_CLASS: 32>, 'pid': 2536,
psutilversion [OK]    0.0000s (5, 8, 0)
quicklook     [OK]    1.6730s {'cpu': 25.3, 'percpu': [{'key': 'cpu_number', 'cpu_number':
raid          [OK]    0.0000s {}
sensors       [OK]    0.0000s []
smart         [N/A]
system        [OK]    0.0010s {'os_name': 'Windows', 'hostname': 
uptime        [OK]    0.0000s {'seconds': 4610}
wifi          [OK]    0.0000s []

deefrawley avatar Apr 26 '21 00:04 deefrawley

Ok i understand, the issue came from https://github.com/nicolargo/glances/issues/1820

Try to downgrade py-cpuinfo Python lib to 3.3.0 as written in the requirements file: https://github.com/nicolargo/glances/blob/develop/optional-requirements.txt#L22

To downgrade, use:

pip install --upgrade py-cpuinfo==3.3.0

nicolargo avatar May 13 '21 15:05 nicolargo

py-cpuinfo is now v8. Why do we need to downgrade to v3?

deefrawley avatar May 14 '21 13:05 deefrawley

@deefrawley because of this non corrected issue on py-cpuinfo ==> https://github.com/workhorsy/py-cpuinfo/issues/155

nicolargo avatar May 14 '21 13:05 nicolargo

@nicolargo, I experienced this same regression. Does it make sense to pin py-cpuinfo in the setup.py?

p5a0u9l avatar Jun 03 '21 18:06 p5a0u9l

The next Glances version 3.1.8 will not use this lib anymore.

For the moment check the version on your system.

Le jeu. 3 juin 2021 à 20:00, Paul Adams @.***> a écrit :

@nicolargo https://github.com/nicolargo, I experienced this same regression. Does it make sense to pin py-cpuinfo in the setup.py?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/nicolargo/glances/issues/1834#issuecomment-854070096, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAF5UK2DFZP3JEGSA37C7TDTQ67MXANCNFSM42D7LKEA .

nicolargo avatar Jun 03 '21 18:06 nicolargo

So how is CPU usage for everyone without that lib?

sunjam avatar Jan 22 '22 20:01 sunjam

Between 5 and 9% of one CPU core on my system.

nicolargo avatar Jan 23 '22 09:01 nicolargo

@nahmias22 how is performance for you on the current release?

sunjam avatar May 27 '22 17:05 sunjam

With Glances 3.2.6.4 and PsUtil 5.9:

glances -w

takes less than 5% of one CPU (Intel(R) Core(TM) i7-4500U) on my computer (average on 30 seconds):

$ python
Python 3.10.4 (main, Apr  2 2022, 09:04:19) [GCC 11.2.0] on linux
>>> import psutil
>>> psutil.Process(pid=62788)
psutil.Process(pid=62788, name='python', status='sleeping', started='10:56:42')
>>> p.cpu_percent(interval=30)
4.6

nicolargo avatar May 28 '22 09:05 nicolargo