glances icon indicating copy to clipboard operation
glances copied to clipboard

Webserver slow in startup and in UI

Open PartTheSeas opened this issue 1 year ago • 11 comments

Describe the bug I don't know how I would verify or or print this behavior, but the web server is super slow in startup (20 secs+) and if I refresh the tab in my browser it takes another 20+ secs to reload

To Reproduce Steps to reproduce the behavior: No idea if it's just me, let me know what you need and how I can retreive it

Expected behavior Startup time should be a few seconds and refreshing the UI as well at max

Environement (please complete the following information)

  • Windows 11
  • Glances & psutil versions: Glances version: 4.2.1 Glances API version: 4 PsUtil version: 6.1.0 Log file: C:\Users\Donatus\AppData\Local\Temp\glances-Donatus.log
  • How do you install Glances (Pypi package, script, package manager, source): pip install glances[all]
  • Glances test: Curses module not found. Glances cannot start in standalone mode.

PartTheSeas avatar Dec 12 '24 11:12 PartTheSeas

An update on this.

After doing some research I found out that the windows-curses package seems not to work with python3.9 or above, so I downgraded python to 3.9 and was able to install the windows-curses package.

Glances seems much more responsive now, even though not blazingly fast, but way faster.

Could this have been the culprit? Is there anything else I can do to improve the performance on Windows?

Kind regards ❤️

PartTheSeas avatar Dec 12 '24 11:12 PartTheSeas

Hi @PartTheSeas

On his Pypi page, Windows-curses seems to be compliant with Python 3.6 to 3.12. Did you try to install the latest version (2.4) ?

Perhaps slow start issue came from another think.

Can you also send us the result of the following command:

glances --issue

nicolargo avatar Dec 14 '24 08:12 nicolargo

I don't know. If I install curses with python > 3.9 I get the curses error I described in my first post, so I googled a bit and downgraded to 3.9.

Can you also send us the result of the following command

glances --issue

Of course! There you go:

glances --issue
===============================================================================
Glances 4.2.1 (C:\Users\Donatus\AppData\Roaming\Python\Python39\site-packages\glances\__init__.py)
Python 3.9.0 (c:\program files\python39\python.exe)
PsUtil 6.1.0 (C:\Users\Donatus\AppData\Roaming\Python\Python39\site-packages\psutil\__init__.py)
===============================================================================
alert         [OK]    0.00000s
[]
amps          [OK]    0.00000s
[]
cloud         [OK]    0.00000s
{}
connections   [OK]    0.00211s
{'ESTABLISHED': 269,
 'LISTEN': 93,
 'SYN_RECV': 0,
 'SYN_SENT': 1,
 'initiated': 1,
 'net_connections_enabled': True,
 'nf_conntrack_enabled': False,
 'terminated': 1}
containers    [OK]    0.00000s
{}
core          [OK]    0.00000s
{'log': 32, 'phys': 24}
cpu           [OK]    0.00000s
{'cpucore': 32,
 'ctx_switches': 2227879,
 'ctx_switches_gauge': 1710985636,
 'ctx_switches_rate_per_sec': 197579.0,
 'dpc': 0.5,
 'idle': 69.7,
 'interrupts': 1720791,
 'interrupts_gauge': 4040171213,
 'interrupts_rate_per_sec': 152608.0,
 'soft_interrupts': 0,
 'soft_interrupts_gauge': 0,
 'syscalls': 6147415,
 'syscalls_gauge': 1345952197,
 'syscalls_rate_per_sec': 545184.0,
 'system': 12.0,
 'time_since_update': 11.275834321975708,
 'total': 32.1,
 'user': 16.8}
diskio        [OK]    0.00000s key=disk_name
[{'disk_name': 'PhysicalDrive0',
  'key': 'disk_name',
  'read_bytes': 16384,
  'read_bytes_gauge': 186827879424,
  'read_bytes_rate_per_sec': 1452.0,
  'read_count': 2,
  'read_count_gauge': 1313909,
  'read_count_rate_per_sec': 0.0,
  'time_since_update': 11.276895523071289,
  'write_bytes': 138457088,
  'write_bytes_gauge': 469759352832,
  'write_bytes_rate_per_sec': 12277943.0,
  'write_count': 140,
  'write_count_gauge': 517261,
  'write_count_rate_per_sec': 12.0}, ...]
folders       [OK]    0.00000s
[]
fs            [OK]    0.00100s key=mnt_point
[{'device_name': 'A:\\',
  'free': 12693402140672,
  'fs_type': 'NTFS',
  'key': 'mnt_point',
  'mnt_point': 'A:\\',
  'percent': 29.5,
  'size': 18000189054976,
  'used': 5306786914304}, ...]
gpu           [OK]    0.00000s
[]
help          [OK]    0.00000s
None
ip            [OK]    0.00000s
{}
irq           [OK]    0.00000s
[]
load          [OK]    0.00000s
{'cpucore': 32, 'min1': 0.4, 'min15': 0.03, 'min5': 0.1}
mem           [OK]    0.00912s
{'available': 51528966144, 'free': 51528966144, 'percent': 62.4, 'total': 137142276096, 'used': 85613309952}
memswap       [OK]    0.01779s
{'free': 34195550208,
 'percent': 0.5,
 'sin': 0,
 'sout': 0,
 'time_since_update': 11.287798881530762,
 'total': 34359738368,
 'used': 164188160}
network       [OK]    0.01369s key=interface_name
[{'alias': None,
  'bytes_all': 290353705,
  'bytes_all_gauge': 816899893223,
  'bytes_all_rate_per_sec': 25717176.0,
  'bytes_recv': 278629171,
  'bytes_recv_gauge': 790692178511,
  'bytes_recv_rate_per_sec': 24678712.0,
  'bytes_sent': 11724534,
  'bytes_sent_gauge': 26207714712,
  'bytes_sent_rate_per_sec': 1038464.0,
  'interface_name': 'Ethernet',
  'key': 'interface_name',
  'speed': 1048576000,
  'time_since_update': 11.290263891220093}, ...]
now           [OK]    0.00000s
{'custom': '2024-12-14 16:21:50 +0100', 'iso': '2024-12-14T16:21:50+01:00'}
percpu        [OK]    0.00000s key=cpu_number
[{'cpu_number': 0,
  'dpc': 9.5,
  'guest': None,
  'guest_nice': None,
  'idle': 57.0,
  'interrupt': 7.3,
  'iowait': None,
  'irq': None,
  'key': 'cpu_number',
  'nice': None,
  'softirq': None,
  'steal': None,
  'system': 19.9,
  'total': 43.0,
  'user': 6.3}, ...]
ports         [OK]    0.00100s
[]
processcount  [OK]    7.35434s
{'pid_max': 0, 'running': 388, 'sleeping': 0, 'thread': 10588, 'total': 396}
processlist   [OK]    0.00000s
[]
psutilversion [OK]    0.00000s
'6.1.0'
quicklook     [OK]    0.01898s
{'cpu': 30.8,
 'cpu_hz': 3200000000.0,
 'cpu_hz_current': 3200000000.0,
 'cpu_log_core': 32,
 'cpu_name': 'CPU',
 'cpu_phys_core': 24,
 'load': 0.1,
 'mem': 62.3,
 'percpu': [{...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...},
            {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...},
            {...}, {...}],
 'swap': 0.5}
raid          [OK]    0.00000s
{}
sensors       [OK]    2.03907s
[]
smart         [NA]
system        [OK]    0.00000s
{'hostname': 'Hades',
 'hr_name': 'Windows 10 SP0 64bit',
 'os_name': 'Windows',
 'os_version': '10 SP0',
 'platform': '64bit'}
uptime        [OK]    0.00000s
{'seconds': 33049}
version       [OK]    0.00000s
'4.2.1'
vms           [OK]    0.00000s
[]
wifi          [OK]    0.00000s
[]
===============================================================================
Total time to update all stats: 9.46418s
===============================================================================

The entire UI and start up are slow. If I F5 the Glances tab it needs like 5-20 seconds to refresh

PartTheSeas avatar Dec 14 '24 15:12 PartTheSeas

processcount [OK] 7.35434s sensors [OK] 2.03907s

On my side i have:

processcount [OK] 0.06198s sensors [OK] 0.0007s

Can not explain the reason :(

I never tested Glances on Windows 11. Is another user use this OS with Glances ?

nicolargo avatar Dec 20 '24 09:12 nicolargo

Niclargo, I'm also using Windows 11 Pro and have a similar issue (NPI) with initiating and getting updates from Glances to Homepage (docker widgets). Would be glad to help if I can... 

C:\Users\user>glances --issue
===============================================================================
Glances 4.3.0.8 (C:\Program Files\Python313\Lib\site-packages\glances\__init__.py)
Python 3.13.2 (C:\Program Files\Python313\python.exe)
PsUtil 6.1.1 (C:\Program Files\Python313\Lib\site-packages\psutil\__init__.py)
===============================================================================
alert         [OK]    0.00001s
[]
amps          [OK]    0.00009s
[]
cloud         [OK]    0.00004s
{}
connections   [OK]    0.04797s
{'ESTABLISHED': 60,
 'LISTEN': 57,
 'SYN_RECV': 0,
 'SYN_SENT': 4,
 'initiated': 4,
 'net_connections_enabled': True,
 'nf_conntrack_enabled': False,
 'terminated': 4}
containers    [OK]    3.27443s key=name
[{'command': 'docker-entrypoint.sh node server.js',
  'cpu_percent': 0.0,
  'created': '2025-02-04T00:06:59.909727661Z',
  'engine': 'docker',
  'id': '31d8becaf8fa84c4610fe93af3295ee86a6980c73c70371626d200a83e8d5098',
  'image': ('ghcr.io/gethomepage/homepage:latest',),
  'io_rx': None,
  'io_wx': None,
  'key': 'name',
  'memory_percent': None,
  'memory_usage': 126423040,
  'name': 'haypile-homepage',
  'network_rx': 0,
  'network_tx': 0,
  'status': 'running',
  'uptime': '21 hours'}, ...]
core          [OK]    0.00015s
{'log': 4, 'phys': 4}
cpu           [OK]    0.00061s
{'cpucore': 4,
 'ctx_switches': 511697,
 'ctx_switches_gauge': 413733541,
 'ctx_switches_rate_per_sec': 26601.0,
 'dpc': 1.0,
 'idle': 34.7,
 'interrupts': 324711,
 'interrupts_gauge': 1084426424,
 'interrupts_rate_per_sec': 16880.0,
 'soft_interrupts': 0,
 'soft_interrupts_gauge': 0,
 'syscalls': 2118349,
 'syscalls_gauge': 3075367306,
 'syscalls_rate_per_sec': 110127.0,
 'system': 40.7,
 'time_since_update': 19.235352754592896,
 'total': 69.2,
 'user': 22.2}
diskio        [OK]    0.00110s key=disk_name
[{'disk_name': 'PhysicalDrive0',
  'key': 'disk_name',
  'read_bytes': 54276608,
  'read_bytes_gauge': 610184223744,
  'read_bytes_rate_per_sec': 2821518.0,
  'read_count': 1838,
  'read_count_gauge': 11362403,
  'read_count_rate_per_sec': 95.0,
  'time_since_update': 19.236664295196533,
  'write_bytes': 20270592,
  'write_bytes_gauge': 332043010048,
  'write_bytes_rate_per_sec': 1053747.0,
  'write_count': 1208,
  'write_count_gauge': 15562868,
  'write_count_rate_per_sec': 62.0}, ...]
folders       [OK]    0.00007s
[]
fs            [OK]    0.00119s key=mnt_point
[{'device_name': 'C:\\',
  'free': 385950703616,
  'fs_type': 'NTFS',
  'key': 'mnt_point',
  'mnt_point': 'C:\\',
  'percent': 24.3,
  'size': 510015827968,
  'used': 124065124352}, ...]
gpu           [OK]    0.00042s
[]
help          [OK]    0.00012s
None
ip            [OK]    0.00007s
{}
irq           [OK]    0.00012s
[]
load          [OK]    0.00039s
{'cpucore': 4, 'min1': 3.66, 'min15': 0.29, 'min5': 0.85}
mem           [OK]    0.01512s
{'available': 4484128768, 'free': 4484128768, 'percent': 73.5, 'total': 16947015680, 'used': 12462886912}
memswap       [OK]    0.02961s
{'free': 3904622592,
 'percent': 9.4,
 'sin': 0,
 'sout': 0,
 'time_since_update': 19.519527196884155,
 'total': 4311076864,
 'used': 406454272}
network       [OK]    0.05300s key=interface_name
[{'alias': None,
  'bytes_all': 0,
  'bytes_all_gauge': 0,
  'bytes_recv': 0,
  'bytes_recv_gauge': 0,
  'bytes_sent': 0,
  'bytes_sent_gauge': 0,
  'interface_name': 'Wi-Fi 2',
  'key': 'interface_name',
  'speed': 0,
  'time_since_update': 19.51547122001648}, ...]
now           [OK]    0.00005s
{'custom': '2025-02-09 14:32:06 -0700', 'iso': '2025-02-09T14:32:06-07:00'}
percpu        [OK]    0.00015s key=cpu_number
[{'cpu_number': 0,
  'dpc': 1.0,
  'guest': None,
  'guest_nice': None,
  'idle': 31.2,
  'interrupt': 1.4,
  'iowait': None,
  'irq': None,
  'key': 'cpu_number',
  'nice': None,
  'softirq': None,
  'steal': None,
  'system': 37.7,
  'total': 68.8,
  'user': 28.8}, ...]
ports         [OK]    0.00043s
[]
processcount [OK]    13.33312s
{'pid_max': 0, 'running': 335, 'sleeping': 0, 'thread': 4776, 'total': 373}
processlist   [OK]    0.00102s
[]
programlist   [OK]    0.00739s
[]
psutilversion [OK]    0.00010s
'6.1.1'
quicklook     [OK]    0.03189s
{'cpu': 67.7,
 'cpu_hz': 800000000.0,
 'cpu_hz_current': 800000000.0,
 'cpu_log_core': 4,
 'cpu_name': 'CPU',
 'cpu_phys_core': 4,
 'load': 7.8,
 'mem': 73.7,
 'percpu': [{...}, {...}, {...}, {...}],
 'swap': 9.7}
raid          [OK]    0.00050s
{}
sensors       [OK]    2.03824s
[]
smart         [NA]
system        [OK]    0.00002s
{'hostname': 'xxxxxxxx',
 'hr_name': 'Windows 11 SP0 64bit',
 'os_name': 'Windows',
 'os_version': '11 SP0',
 'platform': '64bit'}
uptime        [OK]    0.00013s
{'seconds': 798365}
version       [OK]    0.00007s
'4.3.0.8'
vms           [OK]    0.00012s
[]
wifi          [OK]    0.00007s
[]
===============================================================================
Total time to update all stats: 19.12697s
===============================================================================**_

petapika avatar Feb 09 '25 21:02 petapika

processcount [OK] 7.35434s sensors [OK] 2.03907s

On my side i have:

processcount [OK] 0.06198s sensors [OK] 0.0007s

Can not explain the reason :(

I never tested Glances on Windows 11. Is another user use this OS with Glances ?

I’m also finding about 8-20s to refresh glances on windows.

Edit: Seems like 60-120s is more common.

Edit: It appears to get worse with longer uptime. 60-120s is the worst I’ve seen still up to this point, After reset it will still take a few seconds which is far worse than macos and linux, but at least it’s kind of usable.

xoorath avatar May 06 '25 14:05 xoorath

This issue is stale because it has been open for 3 months with no activity.

github-actions[bot] avatar Sep 01 '25 02:09 github-actions[bot]

I'm having this issue as well. It seems like the main problem is that updating the process count is very slow:

===============================================================================
Glances 4.3.3 (C:\Users\Mitch\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\glances\__init__.py)
Python 3.10.11 (C:\Users\Mitch\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\python.exe)
PsUtil 7.0.0 (C:\Users\Mitch\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\psutil\__init__.py)
===============================================================================
alert         [OK]    0.00000s
[{'avg': 86.51418242757502,
  'begin': 1757308405,
  'count': 1,
  'desc': '',
  'end': -1,
  'global_msg': 'EVENTS history',
  'max': 86.51418242757502,
  'min': 86.51418242757502,
  'sort': 'memory_percent',
  'state': 'WARNING',
  'sum': 86.51418242757502,
  'top': [],
  'type': 'MEM'}]
amps          [OK]    0.00000s
[]
cloud         [OK]    0.00000s
{}
connections   [OK]    0.00300s
{'ESTABLISHED': 76,
 'LISTEN': 59,
 'SYN_RECV': 0,
 'SYN_SENT': 2,
 'initiated': 2,
 'net_connections_enabled': True,
 'nf_conntrack_enabled': False,
 'terminated': 2}
containers    [OK]    0.00000s
[]
core          [OK]    0.00100s
{'log': 24, 'phys': 12}
cpu           [OK]    0.00100s
{'cpucore': 24,
 'ctx_switches': 1382929,
 'ctx_switches_gauge': 2848860992,
 'ctx_switches_rate_per_sec': 71433.0,
 'dpc': 0.4,
 'idle': 47.8,
 'interrupts': 1107061,
 'interrupts_gauge': 1457866937,
 'interrupts_rate_per_sec': 57183.0,
 'soft_interrupts': 0,
 'soft_interrupts_gauge': 0,
 'soft_interrupts_rate_per_sec': 0,
 'syscalls': 4355260,
 'syscalls_gauge': 2409285336,
 'syscalls_rate_per_sec': 224965.0,
 'system': 8.8,
 'time_since_update': 19.359688997268677,
 'total': 51.3,
 'user': 42.4}
diskio        [OK]    0.00100s key=disk_name
[{'disk_name': 'PhysicalDrive0',
  'key': 'disk_name',
  'read_bytes': 131072,
  'read_bytes_gauge': 11935843840,
  'read_bytes_rate_per_sec': 6770.0,
  'read_count': 2,
  'read_count_gauge': 581028,
  'read_count_rate_per_sec': 0.0,
  'time_since_update': 19.359688997268677,
  'write_bytes': 0,
  'write_bytes_gauge': 9798749184,
  'write_bytes_rate_per_sec': 0.0,
  'write_count': 0,
  'write_count_gauge': 116981,
  'write_count_rate_per_sec': 0.0}, ...]
folders       [OK]    0.00000s
[]
fs            [OK]    0.01300s key=mnt_point
[{'device_name': 'C:\\',
  'free': 99187568640,
  'fs_type': 'NTFS',
  'key': 'mnt_point',
  'mnt_point': 'C:\\',
  'options': 'rw,fixed',
  'percent': 80.1,
  'size': 498586914816,
  'used': 399399346176}, ...]
gpu           [OK]    0.00100s key=gpu_id
[{'fan_speed': 0,
  'gpu_id': 'nvidia0',
  'key': 'gpu_id',
  'mem': 44.447593688964844,
  'name': 'NVIDIA GeForce RTX 3080',
  'proc': 22,
  'temperature': 59}, ...]
help          [OK]    0.00000s
None
ip            [OK]    0.00100s
{}
irq           [OK]    0.00000s
[]
load          [OK]    0.00000s
{'cpucore': 24, 'min1': 0.23, 'min15': 0.02, 'min5': 0.06}
mem           [OK]    0.00100s
{'available': 4937043968, 'free': 4937043968, 'percent': 85.6, 'total': 34276900864, 'used': 29339856896}
memswap       [OK]    0.00000s
{'free': 18139332608,
 'percent': 8.7,
 'sin': 0,
 'sout': 0,
 'time_since_update': 19.28362464904785,
 'total': 19865579520,
 'used': 1726246912}
network       [OK]    0.02300s key=interface_name
[{'alias': None,
  'bytes_all': 0,
  'bytes_all_gauge': 0,
  'bytes_all_rate_per_sec': 0,
  'bytes_recv': 0,
  'bytes_recv_gauge': 0,
  'bytes_recv_rate_per_sec': 0,
  'bytes_sent': 0,
  'bytes_sent_gauge': 0,
  'bytes_sent_rate_per_sec': 0,
  'interface_name': 'Ethernet 4',
  'key': 'interface_name',
  'speed': 1048576000,
  'time_since_update': 19.2596333026886}, ...]
now           [OK]    0.00000s
{'custom': '2025-09-07 22:14:02 -0700', 'iso': '2025-09-07T22:14:02-07:00'}
percpu        [OK]    0.00100s key=cpu_number
[{'cpu_number': 0,
  'dpc': 3.0,
  'guest': None,
  'guest_nice': None,
  'idle': 58.1,
  'interrupt': 0.4,
  'iowait': None,
  'irq': None,
  'key': 'cpu_number',
  'nice': None,
  'softirq': None,
  'steal': None,
  'system': 8.9,
  'total': 41.9,
  'user': 29.6}, ...]
ports         [OK]    0.00100s
[]
processcount [OK]    15.33154s
{'pid_max': 0, 'running': 437, 'sleeping': 0, 'thread': 13270, 'total': 442}
processlist   [OK]    0.00100s
[]
programlist   [OK]    0.00700s
[]
psutilversion [OK]    0.00000s
'7.0.0'
quicklook     [OK]    0.00300s
{'cpu': 51.1,
 'cpu_hz': 3801000000.0,
 'cpu_hz_current': 3801000000.0,
 'cpu_log_core': 24,
 'cpu_name': 'CPU AMD64 Family 23 Model 113 Stepping 0, AuthenticAMD',
 'cpu_phys_core': 12,
 'load': 0.3,
 'mem': 85.9,
 'percpu': [{...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...},
            {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}],
 'swap': 8.7}
raid          [OK]    0.00000s
{}
sensors       [OK]    2.03741s
[]
smart         [NA]
system        [OK]    0.00000s
{'hostname': 'DeepBlue',
 'hr_name': 'Windows 10 SP0 64bit',
 'os_name': 'Windows',
 'os_version': '10 SP0',
 'platform': '64bit'}
uptime        [OK]    0.00000s
{'seconds': 262410}
version       [OK]    0.00000s
'4.3.3'
vms           [OK]    0.00000s
[]
wifi          [OK]    0.00000s
[]
===============================================================================
Total time to update all stats: 17.43294s
===============================================================================

mlindgren avatar Sep 08 '25 05:09 mlindgren

I believe the perf issue with processcount is related to https://github.com/giampaolo/psutil/issues/2366 and https://github.com/giampaolo/psutil/issues/2463. Based on the description of that issue, running as admin should help, but it didn't make a substantial difference for me, and I'd like to not have to run as admin. I think this can only be fixed by psutil, though.

mlindgren avatar Sep 09 '25 04:09 mlindgren

Same issue here.

Environment

  • OS: Windows 11 WSL2
  • Distro: Ubuntu 24.04 (64-bit)
  • Kernel: Linux 6.6.87.2-microsoft-standard-WSL2
  • Glances 4.3.3 (/app/glances/init.py)
  • Python 3.12.3 (/venv/bin/python3)
  • PsUtil 7.0.0 (/venv/lib/python3.12/site-packages/psutil/init.py)
  • Deployment: Docker (nicolargo/glances:ubuntu-latest-full/nicolargo/glances:ubuntu-latest)

Observation

  • With [sensors] enabled → startup and web refresh take 10+ seconds.
  • With [sensors] disabled → everything is fast again.
  • [processcount] works fine, by disabling it removes all TASKS info.

leohazy avatar Sep 14 '25 18:09 leohazy

As @mlindgren said, the issue came from the PSUtil lib used under the wood by Glances to grab system stats.

Issue are the followings:

  • https://github.com/giampaolo/psutil/issues/2366
  • https://github.com/giampaolo/psutil/issues/2463

I let the issues opened as far as the PsUtil issues will be corrected.

nicolargo avatar Sep 14 '25 20:09 nicolargo