Closed erikhuck closed 3 months ago
This is actually very useful, since it can track full utilization of the CPU. Would recommend adding an option to divide by the number of CPU cores. This would then provide a percent utilization of the whole CPU across all cores.
On Tue, Mar 26, 2024 at 10:58 AM Erik Huckvale @.***> wrote:
This may not be as helpful information when child processes are used without showing the information for the main and child processes individually as described in #11 https://github.com/MoseleyBioinformaticsLab/gpu_tracker/issues/11. But the user can decide whether they want to see just the sum of all CPU percentages or that in addition to the more granular version. This stack overflow https://stackoverflow.com/questions/41206809/psutil-measuring-the-cpu-usage-of-a-specific-process describes how this can be accomplished. We should explain in the documentation that a cpu usage of greater than 100% can occur if a process uses multiple threads across multiple cores.
— Reply to this email directly, view it on GitHub https://github.com/MoseleyBioinformaticsLab/gpu_tracker/issues/13, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADEP7BZ4I5QSUM5LQTIK6TDY2GEJLAVCNFSM6AAAAABFJDJDNSVHI2DSMVQWIX3LMV43ASLTON2WKOZSGIYDQNJQGA3TKMY . You are receiving this because you are subscribed to this thread.Message ID: @.***>
Email: @. (work) @. (personal) Phone: 859-218-2964 (office) 859-218-2965 (lab) 859-257-7715 (fax) Web: http://bioinformatics.cesb.uky.edu/ Address: CC434 Roach Building, 800 Rose Street, Lexington, KY 40536-0093
class MaxCPUPercentage:
system_cpu_count: int
system_cpu_percent: float
system_average_cpu_percent: float # possibly
main_cpu_percent: float
main_normalized_cpu_percent: float
descendent_cpu_percent: float
descendent_average_cpu_percent: float
combined_cpu_percent: float
combined_average_cpu_percent: float
main_n_threads: int
descendent_n_threads: int
combined_n_threads: int
percpu
is True
.p.cpu_percent() / psutil.cpu_count()
where p
is a Process
.If the information is across CPU cores, then I would recommend the following key names: class MaxCPUUtilization: system_core_count: int system_core_percent: float system_cpu_percent: float # possibly main_core_percent: float main_cpu_percent: float descendent_core_percent: float descendent_cpu_percent: float combined_core_percent: float combined_cpu_percent: float main_n_threads: int descendant_n_threads: int combined_n_threads: int
Just realized one more important aspect of reporting CPU utilization. Both max and average results should be reported. Max will help indicate if the CPU is being fully utilized at any given time and average utilization will indicate how well the CPU is being utilized across time.
@hunter-moseley
CPUUtilization
? And should we name the fields as so: system_max_core_percent
, system_mean_core_percent
, main_max_core_percent
, main_mean_core_percent
, etc.A CPU has multiple CPU cores.
So, core_percent is in place of cpu_percent. And cpu_percent is in place of normalized_cpu_percent.
Yes, you can rename the class to CPUUtilization. Yes, use max and mean to distinguish between max and mean values.
On Wed, Apr 10, 2024 at 6:04 PM Erik Huckvale @.***> wrote:
@hunter-moseley https://github.com/hunter-moseley
- What is the difference between cpu_percent and core_percent?
- To account for collecting the average, should we rename the class to just CPUUtilization? And should we name the fields as so: system_max_core_percent, system_mean_core_percent, main_max_core_percent, main_mean_core_percent, etc.
— Reply to this email directly, view it on GitHub https://github.com/MoseleyBioinformaticsLab/gpu_tracker/issues/13#issuecomment-2048514706, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADEP7B7FNBNGX5KID3ELM4DY4WZP5AVCNFSM6AAAAABFJDJDNSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANBYGUYTINZQGY . You are receiving this because you were mentioned.Message ID: @.***>
Email: @. (work) @. (personal) Phone: 859-218-2964 (office) 859-218-2965 (lab) 859-257-7715 (fax) Web: http://bioinformatics.cesb.uky.edu/ Address: CC434 Roach Building, 800 Rose Street, Lexington, KY 40536-0093
@hunter-moseley I did an experiment and it is strongly evident that psutil.cpu_percent()
is the same as numpy.mean(psutil.cpu_percent(percpu=True))
. In other words, the mean percentage across all available CPUs. As I understand it, that would be the value for system_cpu_percent. So the question is, how would we like to calculate the value for system_core_percent? I'd think that would be the sum of all the core percentages as opposed to the mean? If that isn't very meaningful (perhaps because the value would possibly be more dependent on the number of cores in the system than anything else), we could alternatively exclude system_core_percent.
Use sum.
On Wed, Apr 10, 2024, 6:56 PM Erik Huckvale @.***> wrote:
@hunter-moseley https://github.com/hunter-moseley I did an experiment and it is strongly evident that psutil.cpu_percent() is the same as numpy.mean(psutil.cpu_percent(percpu=True)). In other words, the mean percentage across all available CPUs. As I understand it, that would be the value for system_cpu_percent. So the question is, how would we like to calculate the value for system_core_percent? I'd think that would be the sum of all the core percentages as opposed to the mean? If that isn't very meaningful (perhaps because the value would possibly be more dependent on the number of cores in the system than anything else), we could alternatively exclude system_core_percent.
— Reply to this email directly, view it on GitHub https://github.com/MoseleyBioinformaticsLab/gpu_tracker/issues/13#issuecomment-2048566132, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADEP7BY6N4PRF3GAY24YYV3Y4W7S5AVCNFSM6AAAAABFJDJDNSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANBYGU3DMMJTGI . You are receiving this because you were mentioned.Message ID: @.***>
So the final implementation should be?
@dclass.dataclass
class CPUUtilization:
system_core_count: int
system_max_core_percent: float = 0.
system_max_cpu_percent: float = 0.
main_max_core_percent: float = 0.
main_max_cpu_percent: float = 0.
descendent_max_core_percent: float = 0.
descendent_max_cpu_percent: float = 0.
combined_max_core_percent: float = 0.
combined_max_cpu_percent: float = 0.
system_mean_cpu_percent: float = 0.
system_mean_core_percent: float = 0.
main_mean_core_percent: float = 0.
main_mean_cpu_percent: float = 0.
descendent_mean_core_percent: float = 0.
descendent_mean_cpu_percent: float = 0.
combined_mean_core_percent: float = 0.
combined_mean_cpu_percent: float = 0.
main_n_threads: int = 0
descendant_n_threads: int = 0
combined_n_threads: int = 0
This looks complete.
On Wed, Apr 10, 2024, 7:26 PM Erik Huckvale @.***> wrote:
So the final implementation should be?
@dclass.dataclass class CPUUtilization: system_core_count: int system_max_core_percent: float = 0. system_max_cpu_percent: float = 0. main_max_core_percent: float = 0. main_max_cpu_percent: float = 0. descendent_max_core_percent: float = 0. descendent_max_cpu_percent: float = 0. combined_max_core_percent: float = 0. combined_max_cpu_percent: float = 0. system_mean_cpu_percent: float = 0. system_mean_core_percent: float = 0. main_mean_core_percent: float = 0. main_mean_cpu_percent: float = 0. descendent_mean_core_percent: float = 0. descendent_mean_cpu_percent: float = 0. combined_mean_core_percent: float = 0. combined_mean_cpu_percent: float = 0. main_n_threads: int = 0 descendant_n_threads: int = 0 combined_n_threads: int = 0
— Reply to this email directly, view it on GitHub https://github.com/MoseleyBioinformaticsLab/gpu_tracker/issues/13#issuecomment-2048594980, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADEP7B4UUCA5AJT76VVLHMDY4XDEBAVCNFSM6AAAAABFJDJDNSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANBYGU4TIOJYGA . You are receiving this because you were mentioned.Message ID: @.***>
Fixed by #30
This may not be as helpful information when child processes are used without showing the information for the main and child processes individually as described in #11. But the user can decide whether they want to see just the sum of all CPU percentages or that in addition to the more granular version. This stack overflow describes how this can be accomplished. We should explain in the documentation that a cpu usage of greater than 100% can occur if a process uses multiple threads across multiple cores.