简体   繁体   English

如何计算好CPU百分比,例如在顶部?

[英]How is nice cpu percentage calculated, e.g. in top?

My research group is sharing time on a CentOS server, and we've been using renice +15 to try to lower the priority of long-running background tasks. 我的研究小组正在CentOS服务器上共享时间,我们一直在使用renice +15来降低长期运行的后台任务的优先级。 When running top, these processes do show up as having a nice value of 15, but the "%ni" measure of nice cpu load is always very low (less than 1%) even when these processes are churning along on 30 cores (as reported in the %CPU column). 当运行最高时,这些进程的确显示为不错的值15,但是即使这些进程在30个内核上进行搅动(如在%CPU列中报告)。 This has made us think that we are not actually using renice correctly (though the nice processes do seem to yield to higher-priority tasks). 这使我们认为我们实际上并没有正确使用renice(尽管不错的过程似乎确实可以解决较高优先级的任务)。 How exactly is the nice cpu percentage calculated in top? 最佳的cpu百分比到底如何计算?

The numbers in top come from reading the file /proc/stat. 最上面的数字来自读取文件/ proc / stat。 The first line contains a summary for all the cpus combined. 第一行包含所有cpus的摘要。 The first column is usr time, the second nice time. 第一列是usr时间,第二列是好时间。 These times are in clock ticks, usually 100 per second, and are cumulative, so you have to look over and interval and subtract the start value from the end value. 这些时间以时钟滴答为单位,通常为每秒100次,并且是累积时间,因此您必须仔细检查并间隔一下,然后从结束值中减去开始值。 You can see the docs for more details, I like http://man7.org/linux/man-pages/man5/proc.5.html 您可以查看文档以了解更多详细信息,我喜欢http://man7.org/linux/man-pages/man5/proc.5.html

The Linux kernel adds CPU time to the nice column if the nice value is greater than 0, otherwise it puts it in the usr column. 如果nice值大于0,则Linux内核将CPU时间添加到nice列,否则将其放入usr列。

The nice value for an individual process can be found by looking at column 19 of /proc/[pid]/stat. 通过查看/ proc / [pid] / stat的第19列,可以找到单个进程的不错的值。 That number should be 15 for you, and the number in column 18 should be 35 (The kernel's internal interpretation of a nice of 15.) However, if top is showing those as 15 in the NI column, it is getting that value from /proc/[pid]/stat. 这个数字对您来说应该是15,第18列中的数字应该是35(内核的内部解释是15。)但是,如果top在NI列中将其显示为15,那么它将从/中获取该值。 proc / [pid] / stat。

Comparing the CPU time used in usr and sys in /proc/[pid]/stat and then usr, nice and sys in /proc/stat will give you a good idea of where the time is going. 比较/ proc / [pid] / stat中usr和sys中使用的CPU时间,然后比较/ proc / stat中usr,nice和sys中使用的CPU时间,您将可以很好地了解时间在哪里。 Maybe there are just a ton of CPUs on the system. 也许系统上只有大量的CPU。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 Linux 上获取整体 CPU 使用率(例如 57%) - How to get overall CPU usage (e.g. 57%) on Linux Linux - 更快地读取或收集文件内容(例如每秒 cpu 温度) - Linux - read or collect file content faster (e.g. cpu temp every sec.) 如何在 Linux 上获得总体 RAM 使用率(例如 57%) - How to get overall RAM usage (e.g. 57%) on Linux 如何搜索 Linux 手册页(例如使用 grep) - How to search Linux man pages (e.g. with grep) 如何为ARM交叉编译python包(例如Numpy) - how to cross compile python packages (e.g. Numpy) for ARM 如何获得像“top”命令一样的per-cpu统计信息(system,idle,nice,...)? - How do I get per-cpu stats (system, idle, nice, …) like the “top” command does? 最高命令:进程中的CPU%如何高于总体CPU使用率百分比 - Top Command: How come CPU% in process is higher than in overall CPU Usage Percentage 如何列出所有已加载到内核的bpf程序? (例如tc-bpf) - How to list all bpf program which is loaded into kernel ? (e.g. tc-bpf) 如何像在后台该目录中一样执行脚本(例如mvnw)? - How to execute a script (e.g. mvnw) as if you were in that directory in the background? 如何为新浏览器 window 指定几何图形(例如 1280x720)? - How to specify geometry (e.g. 1280x720) for a new browser window?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM