-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New version of cpuinfo is very slow (4.0.0 versus 5.0.0 or higher)... #155
Comments
In py-cpuinfo 5.0.0 and greater, the1 second delay is from when py-cpuinfo runs the CPUID instruction to measure the CPU Hz. It gets the CPU ticks, sleeps for 1 second, measures the ticks again, then returns the difference. So there isn't any way to get around wasting that 1 second. In py-cpuinfo 4.0.0 it is most likely failing to run CPUID for that OS configuration. Then it looks like it is running very quickly, when it is just failing. Here is a short example of basically what we are doing: # Works on py-cpuinfo 7.0.0
# Warning: Don't use this in the main python process. As it can crash
# entire Python runtime, if there is an error. This also only Works
# on x86 and x86_64 CPUs.
if __name__ == '__main__':
from time import sleep
from sys import stdout
from cpuinfo import CPUID
# Generate the CPUID machine code function
cpuid = CPUID()
ticks_fn = cpuid.get_ticks_func()
try:
while True:
# Measure the Hz
start = ticks_fn.func()
sleep(1)
end = ticks_fn.func()
hz_measured = (end - start)
# Print Hz
print(hz_measured)
stdout.flush()
# Exit and cleanup on Ctrl+c
except KeyboardInterrupt:
pass
finally:
if ticks_fn: ticks_fn.free() I will look into if there is a better way to do this. |
….2.3 Anartz Nuin (4): Bring back 'rss' and 'cache' memory stats in docker plugin Add RSS column for containers in web UI Fix container rss value reported as memory value update static assets Bao Trinh (1): Fix broken method call when config is None Bartlomiej Cieszkowski (5): glances can work in console mode on windows - windows-curses text wrap was due to size of screen being different than subwindows size, use term_window sizing tz unused import dont remove comment Blake (1): fixed typo in comments Caleb Marchent (1): Fix grammar in sensors documentation Clifford W. Hansen (2): Fixed docker copy issue Fixed python library path Deepak Kaul (2): Adding in optional protocol variable for rabbitmq export which adds in support for amqps protocol Needed to handle case where no protocol was specified in configuration. So added in an if clause to check if the protocol was present Deosrc (4): Add mqtt output in JSON format Reformat JSON output into hierarchy structure Rename parameter for topic structure Fix omitted config value causing error Eduard Marbach (5): ci: implement github actions for builds fix: dev build contains all optional req ci: fix release process and improve build speeds ci: fix pushing for develop branch feat: readd armv6 to docker images Floran Brutel (10): Display gpu and mem more plugin on small devices Finish connection plugin of the webUi Replace \n by br in amp result Build webui Build WebUI after npm package update Build the WebUI and remove yarn.lock WebUI : Hide the process count of amp if regex is not defined Fix sort by disk io in the web ui Display N/A only if gpu values are null Display full interface name of network for big screen in the webui Gaspard d'Hautefeuille (4): Reflect "used percent" user disk space Add user disk space usage Add email action for space trigger critical pystache requirement to render the mustache syntax Guillaume L (1): Update master dockerfile for Ubuntu 20.04 Jürgen Gmach (2): Remove deprecated keyword "sudo" from travis config. Do not use "python setup.py install" any more. Karthikeyan Singaravelan (2): Fix DeprecationWarning regarding invalid escape sequence. Fix SyntaxWarning regarding literal comparison. Use is_alive instead of isAlive for Python 3.9 compatibility. Kevin Eifinger (1): (ci): Add linux/arm/v6 docker platform Markus Pöschl (16): Migrate to multistaged Dockerfile for debian images. Migrate the dev image also in the multi-stage build Change the actions to build both of the versioned variants Add opencontainers label metadata Ensure correct version inside docker container Change docker build to matrix Install dependencies before installing from pypi for better layer caching Adjust dev images for caching and add workdir again Install build-essentials instead of just the gcc on debain build images Add alpine multi-staged build Move to plain alpine image to build pip dependencies successfully Change cache specific to Dockerfile, not commit. Apply os on image tag Fix missing docker image name Fix python lib path in alpine images Fix alpine path Michael J. Cohen (1): Fix typo Mikael Muszynski (1): Fix typo in README Nicolas Hennion (314): On the road on the version 3.1.4 or higher Correct unitest Correct unitest Update doc and conf file [ports] ICMP does not work #1538 Correct an issue if IP plugin is not available in the Curses UI Add update duration in the plugin decorator KeyError: b'Rss:' in memory_maps #1551 Ignore .idea folder Make processes.sort_key configurable #1536 Improve sort key management Update documentation. Display load as percentage when Irix mode is disable #1554 Prevent exporting empty data to InfluxDB Add a comment for future export enhancement NVIDIA GPU temperature #1523 Update dep in setup file Glances writing lots of Docker Error message in logs file #1561 Feature request: HDD S.M.A.R.T. reports #1288 (only terminal UI) Update docs First try to eable the connections plugin in the WebUI... (it's a fail) Create FUNDING.yml Correct an issue while init IP plugin (issue #1528) again... log file under public/shared tmp/ folders must not have deterministic name #1575 Can start glances with MQTT export #1581 FS filtering can be done on device name #1606 NameError: name logger is not defined in net plugin #1602 Debug message for issue #1604 Glances don't want to run on Crostini (LXC Container, Debian 10, python 3.7.3) #1600 Feature request: Include hostname in all (e.g. kafka) exports #1594 Kafka key name needs to be bytes #1593 [diskio] Aliases Display Incorrectly/Not at All, and Glances Throws Error on Exit #1618 Correct an issue on Windows, time zone not display correctly. Skip it for the moment Update doc Glances 3.1.4 ready to be released On the road to Glances 3.1.5 Convert JPEG to PNG images (for documentation) Convert JPEG to PNG images (for documentation) Minor release for Debian package Undefined name 'i' in plugins/glances_gpu.py #1635 View by CPU is only showing 6 of 12 cores #1640 (only update docs) Glances should not phone home #1646 (on master branch only) Asymetric, cluttered configuration: Some options only accessible via CLI or keyboard or config file #1650 (correct IRQ) Update view.html #1636 Tests using /etc/glances/glances.conf from already installed version #1654 First version of processus selector (no action for the moment) Update documentation for server protection #1657 First version when click on K Use Ubuntu 20.04 as default Docker image Use Ubuntu 20.04 as default Docker image Missing temperature #1664 First working version of the kill feature Selected process is now undelined Update documentation for 'k' hotkey (kill process) Display 'k' kill process help message in the Curses UI Make the kill feature works while in filtered mode Quick Look missing CPU Infos #1685 class AmpsList method _build_amps_list() Windows fail (glances/amps_list.py) #1689 Enhancement Request: .conf parameter for AMP #1690 Update docs Regex fix for hide conf key #1691 Unusual characters in cmdline cause lines to disappear and corrupt the display #1692 Can't start server: unexpected keyword argument 'address' #1693 Change pre-requisite Glances 3.1.5 Update doc On the road of version 3.1.6 Update NEWS file Update NEWS file Rebuild Web UI Fix gpu plugin to handle multiple gpus with different reporting capabilities #1634 Update DockerFile As said in the issue #1700, new version od cpuinfo (7.0.0) is very slow... As said in the issue #1700, new version od cpuinfo (7.0.0) is very slow (ok with 4.0.0)... Add compatibility for Py-cpuinfo 7.0.0 or higher Set cpuinfo version to 4.0.0 until issue workhorsy/py-cpuinfo#155 is analysed Do not display zsh share twice Publish develop branch to test.pypi.org Publish develop branch to test.pypi.org correct provider name Publish develop branch to test.pypi.org correct version Update develop Dockerfile to use test.pypi.org merge conflict in manpage? #1712 merge conflict in manpage? #1712 Correct Docker Alpine Dockerfile Correct Python path in the devel-apline Docker File fixing command in json.rst #1724 Update document datapack following #1724 Do not shorten container names #1723 Update doc for multi arch Docker images Make build reproducible #1740 Manpage improvement #1743 RIP Alpine? #1741 Alpine image is broken #1744 Update documentation for F5 Add docker pull badge Make the popup box use the insert mode (no change...) Add hide filter to Docker list (first part of #1748) Filter docker containers #1748 Add sponsors badged Update the donation section Reverse the last PR #1762 because it breaks the CI pipeline Error with IP Plugin : object has no attribute #1528 crash on startup on Illumos when no swap is configured #1767 crash on startup on Illumos when no swap is configured #1767 Correct issue with #1767 First version of the new influxdb2 exporter Improve log message Unable to connect to Influxdb 2.0 #1776 Improve dep Update readme file Update doc Update issue templates Update issue templates The last PR break the compatibilty with Python 2 The last PR break the compatibilty with Python 2 Update Dockerfile First try. Have to be optimized Optimize plugins space by not displaying 0 stats in Curse interface #1787 Unusual characters in cmdline cause lines to disappear and corrupt the display #1692 version 3.1.6 On the road of the version 3.1.7 Test ok with ELK 7.1.10. To be tweaked. Glances crash after installing module for shown GPU informations on Windows 10 #1800 Glances crash after installing module for shown GPU informations on Windows 10 #1800 Update docs On teh second road of 3.1.7 Force Ubuntu 20.01 for SNAP Force Ubuntu 20.01 for SNAP Resolve SNAP conflict Resolve SNAP conflict Update docs following PR #1798 Doc. No SMART screenshot. #1799 Typo in RAIDS docs Update docs Disable hide zero function by default because it is under developement... Glances version 3.1.6.2 Correct an issue if section did not exist Correct an issue if section did not exist Remove pystache by chevron (mustache implementation) #1817 Replace Pystache by Chevron 2/2 See #1817 Add perf stats for processcount Plugin quicklook takes more than one seconds to update #1820 Smart plugin error while start glances as root #1806 Reaplly the Add hide option to sensors plugin #1596 PR Update documentation for HDDTemp plugin Correct typo in documentation Add debug message for snap packaging One more try for snapcraft Add debug message for snap packaging again Correct launch issue in Snapcraft Correct launch issue in Snapcraft another try... Correct launch issue in Snapcraft another try again... Correct one of the issue of #1822 (get_bool_value error) Refactor the way importants stats are displayed #1826 Add a new decision tree (not used for the moment) '/api/3/processlist/pid/3936'use this api can't get right info,all messy code #1828 Update Web UI dep Add webui in Makefile First version but should be optimize to display plugin grab time First version but should be optimize to display plugin grab time Add update stats time Add Glances and PsUtil version Replace Travis by Github action #1850 Correct Pypi CI pipeline Correct issue with non existing PermissionError in Python 2 Correct Pypi CI pipeline Correct Pypi CI pipeline Let only build and test pipelines Correct Flake8 issue on unitest file Correct Flake8 issue for config.py file Add Bandit to test Update dep module list Remove shell=True for actions (following Bandit issue report) #1851 Remove travis because now all *should* be done via Github actions Another unsuccess try for SNAP Catch adress already in use message more propely GPU temperature not shown in webview #1849 Switch to normalize beta version (not use _ anymore) Security audit - B411 #1025 Process short name (without the path is the default behavor). Addd a new --process-long-name option to force the previous behavor Update docs Manage multiple commands (&&) in the secure popen Glances version 3.1.7 On the road of Glances 3.1.8 Correct ypo in InfluxDB doc sample Export to graphite #1854 Connection to Graphite Server should be done before releasing the feature Correct default Graphite port to 2003 Implemented but test is KO: only a part of the stats are exported... Same behavor with both client Graphyte and GraphiteSender. Perhaps the issue came from the server (docker-graphite-grafana) Update WebUI for security vuln Add --issue to Github issue template Correct issue with latest version of Docker API (1.41) - See details in issue - #1857 Correct test before using cache 3.1.8 Beta 3 Improve code quality #820 Pressing Q to get rid of irq not working #1792 Add virtualenv venv to gitignore file Correct Flake8 issue in pkugins Update hddtemp.rst Update hddtemp.rst Update hddtemp.rst Update hddtemp.rst Update hddtemp.rst Add files via upload Update hddtemp.rst Update quicklook.rst Add shortcut to run Glances in dev environment First optimzation with a new dynamic way to compute the refresh rate. Good news, the CPU consumption seams to be lower than ~20% with a refresh rate more or less the same... Update documentation Correct an issue when stats use old stats (example network). Had also to deal with the export CSV module not working. Correct an issue when stats use old stats (example network). Had also to deal with the export CSV module not working. Not all field in CPU export. Had to investigate Add files via upload CPU is OK, but not diskio and others plugins Correct issue in stdout cvs header field Filter data exported from Docker plugin Replace py-cpuinfo by PsUtil and home made methods Set refresh rate for global CPU percent Add files via upload Add caching for processing username and cmdline Add coment to defaullt glances.conf file Update GraphFlame Make the Docker API connection timeout configurable Make the Docker API connection timeout configurable, update doc Update docs Set minimal version for PSUtil Improve Docker client connection Put CPU improvement in test Generate specific tag for every docker container on influxdb export #1871 Correct an issue while getting Core number Correct filter Improve history perf Improve history perf Change main curses loop Improve curses loop. Avoid checking keypressed if it return -1. Set the dafault refresh rate of system stats to 60 seconds Generate specific tag from stats' key for InfluxDB and InfluxDB2 export #1871 Update documentation Correct refresh time method Add profiling tools Default refresh time for sensors is refresh rate * 2 Update Flame profiling Grab sensors temperature threshold Add some comments to the processlist.py Correct issue with bad key for AMPS Corrtec an issue with sensors Get system sensors temperatures thresholds #1864 Update Glances Flame Add some comments in cpu_percent AttributeError: 'NoneType' object has no attribute 'current' #1875 Correct an issue in last commit for #1875 Correct unitary test following PR #1873 # Quit from help should return to main screen, not exit #1874 Add release-note in the Makefile Update Makefile Add no pager to release note Add NEWS file and improve Makefile Add some tools to the Makefile Docker containers information missing with Docker 20.10.x #1878 Sparkline not working in server/client mode #1881 - For the moment disable sparkline in client mode Update docs for sparklines Reindent audodiscover.py file Change except in Zeroconf Network interfaces not applying in web UI #1884 Remove test in conf file Starting an alias with a number causes a crash #1885 Spelling correction in docs #1886 Update issue template version 3.2.0 On the road to Glances 3.2.1 Update NEWS file Also search glances.conf file in /usr/share/doc/glances/glances.conf #1862 Also search glances.conf file in /usr/share/doc/glances/glances.conf #1862 Correct an issue in last commit Update contribution file Update contribution file Update README concerning Docker files Glances 3.2.0 and influxdb export - Missing network data #1893 Security audit - B411 #1025 Glances version 3.2.1 Roadtrip to version 3.2.2 Corect release note for version 3.2.0 Create codeql-analysis.yml Update docs Add API doc for CPU (not completed) Add API doc for CPU Add API doc for MEM Add load and memswap Add network Add core docs Get specific item Add field == value Rename stdout fields to apidoc Rename stdout fields to apidoc Add the all request, with warnings Add history Add limits Update api.rst Reformat API doc Reformat API doc 2 [3.2.0/3.2.1] keybinding not working anymore #1904 InfluxDB/InfluxDB2 Export object has no attribute hostname #1899 Glances version 3.2.2 On the road to Glances 3.2.3 Debian Docker images broken with version 3.2.2 #1905 Public IP address doesn't display anymore #1910 Make the process sort list configurable through the command line #1903 Update process list doc Update process list doc Update Flame profiling Glances don't send hostname (tag) to influxdb2 batinfo not in docker image (and in requirements files...) ? #1915 Processor name getting cut off #1917 Docker container monitoring only show half command? #1912 Update Makefile version 3.2.3 Oren Amsalem (1): Not need for python-dev anymore Paulo Flabiano Smorigo (1): Fix grafana json Rui Chen (3): Add python 3.7 and 3.8 into CI pypy -> pypy3 ci: add python 3.9 Sergey Prytkov (1): manual refresh on F5 Stefan Eßer (1): Update README.rst Tim Gates (1): docs: fix simple typo, optionnal -> optional Tom Matheussen (1): Fixed formatting on FS example Tuux (1): Fixe issue #1814 Wm Salt Hale (5): Add instructions about password protecting Docker removed mode from secrets block, expanded docker-compose entry Add instructions about password protecting Docker removed mode from secrets block, expanded docker-compose entry fixed code-block formatting Yan (1): Fix history_add, so it allows history_max_size to be zero Yoganand Chandrasekhar (1): Update glances_sparklines.py codecakes (1): added optional requirements dependabot[bot] (12): Bump macaddress from 0.2.8 to 0.2.9 in /glances/outputs/static Bump lodash from 4.17.15 to 4.17.19 in /glances/outputs/static Bump elliptic from 6.4.0 to 6.5.3 in /glances/outputs/static Bump fstream from 1.0.11 to 1.0.12 in /glances/outputs/static Bump stringstream from 0.0.5 to 0.0.6 in /glances/outputs/static Bump sshpk from 1.13.1 to 1.16.1 in /glances/outputs/static Bump angular from 1.7.9 to 1.8.0 in /glances/outputs/static Bump y18n from 3.2.1 to 3.2.2 in /glances/outputs/static Bump elliptic from 6.5.3 to 6.5.4 in /glances/outputs/static Bump yargs-parser from 5.0.0 to 5.0.1 in /glances/outputs/static Bump lodash from 4.17.19 to 4.17.21 in /glances/outputs/static Bump hosted-git-info from 2.7.1 to 2.8.9 in /glances/outputs/static fcalvet (6): Reduced precision to seconds in influxdb export Slight glances/README.txt update Update grafana example for diskio Correcting diskio write units in grafana dashboard Requirement for elasticsearch library for export fix GPU memory consumption reporting meganomic (2): Add strftime config option Add commandline option for strftime_format. Set check_updates in config because otherwise outdated fails since it isn't set even though there is a 'global' qq547057827 (1): 提交docker-compose文件
Hi, if I'm reading the code correctly, you try every function and add fields as you go. So at least on linux, lscpu already provides this info and you don't need to run the CPUID timer. Another way around this might be to provide a routine to get to specific fields faster. For example, I only need the flags, and the timer is not even a useful delay. |
On my machine, py-cpuinfo is quite slow. Seems it's a known issue: workhorsy/py-cpuinfo#155 This setting cuts the time it takes me to run the test suite in half.
* Add HOST_INFO.INCLUDE_CPU_INFO setting On my machine, py-cpuinfo is quite slow. Seems it's a known issue: workhorsy/py-cpuinfo#155 This setting cuts the time it takes me to run the test suite in half. * Add documentation Co-authored-by: chris.grace <[email protected]>
I also just ran into this. I wanted to use this library to get some info out like CPU model name but taking more than 1s is too long for my application. A few thoughts:
|
Hi,
i use cpuinfo in Glances to display cpu info...
An issue as been openned by a user: see nicolargo/glances#1700
It is also reproduced on my side:
0.02 second versus 1.11 second...
In your bug report please include:
The text was updated successfully, but these errors were encountered: