-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[Linux] psutil.cpu_frequency() is slow #1851
Comments
Strace from the machine: Apparently first read in
The other reads of |
I noticed that
adding @giampaolo. |
@gghh may be interested as well. |
We also need min and max frequencies though. This is what I get with 8 CPUs:
Not very fast indeed. Perhaps there's another method to do this (ioctl()?). |
Note that these can get quickly:
According to what @gghh told me that reading On the contrary, @giampaolo : So maybe we can combine these 2 approaches? |
The change is about using /proc/cpuinfo when available. It provides cached values for frequencies and one can fill up minimum and maximum frequency from /sys/devices/system/cpu/cpufreq/policy/* sub-system (which is fast). Fixes giampaolo#1851.
The change is about using /proc/cpuinfo when available. It provides cached values for frequencies and one can fill up minimum and maximum frequency from /sys/devices/system/cpu/cpufreq/policy/* sub-system (which is fast). Fixes giampaolo#1851.
The change is about using /proc/cpuinfo when available. It provides cached values for frequencies and one can fill up minimum and maximum frequency from /sys/devices/system/cpu/cpufreq/policy/* sub-system (which is fast). Fixes giampaolo#1851.
Micro optimization in reference to #1852 and #1851. Use glob.glob(), which internally relies on os.scandir() in order to list /sys/devices/system/cpu/cpufreq files. In doing so, we avoid os.path.exists() for each CPU, which internally uses os.stat(). Signed-off-by: Giampaolo Rodola <[email protected]>
The change is about using /proc/cpuinfo when available. It provides cached values for frequencies and one can fill up minimum and maximum frequency from /sys/devices/system/cpu/cpufreq/policy/* sub-system (which is fast). Fixes giampaolo#1851.
The change is about using /proc/cpuinfo when available. It provides cached values for frequencies and one can fill up minimum and maximum frequency from /sys/devices/system/cpu/cpufreq/policy/* sub-system (which is fast). Fixes giampaolo#1851.
The change is about using /proc/cpuinfo when available. It provides cached values for frequencies and one can fill up minimum and maximum frequency from /sys/devices/system/cpu/cpufreq/policy/* sub-system (which is fast). Fixes giampaolo#1851.
The change is about using /proc/cpuinfo when available. It provides cached values for frequencies and one can fill up minimum and maximum frequency from /sys/devices/system/cpu/cpufreq/policy/* sub-system (which is fast). Fixes giampaolo#1851.
Signed-off-by: Giampaolo Rodola <[email protected]>
Platform
Running the following code snippet takes quite some time on my machine:
and it's even slower on a EPYC machine:
The text was updated successfully, but these errors were encountered: