我目前正在分析Solaris上的一个命令,该命令从文件中读取,性能非常低。truss -D命令显示了占用0.03秒的read系统调用,但是当我使用truss -E时,它们总是0.0000或0.0001 (比-D选项低两个数量级)。在man页面中,它说:
-D
Includes a time delta on each line of trace output. The
value appears as a field containing seconds.fraction and
represents the elapsed time for the LWP that incurred
the event since the last reported event incurred by that
LWP. Specifically, for system calls, this is not the
time spent within the system call.
-E
Includes a time delta on each line of trace output. The
value appears as a field containing seconds.fraction and
represents the difference in time elapsed between the
beginning and end of a system call.
In contrast to the -D option, this is the amount of
time spent within the system call.因此,-E选项度量系统调用的实际时间,而-D不.有人能解释一下到底是什么原因造成了这种差异吗?在“系统呼叫”之外的剩余时间内正在做什么?
发布于 2014-11-21 21:08:36
根据您引用的文档,我发现非常清楚的是,一个包含了从一个系统调用到下一个系统调用的整个期间,而另一个只覆盖了系统调用中的时间。
系统调用内部的时间百分比与系统调用外部时间的百分比大致会告诉您进程是否受CPU约束。
CPU绑定进程的大部分时间都花在系统调用之外。这是进程在执行计算时所处的状态。对于CPU绑定进程,这两个数字之间的差异将很大,而且可能至少有一个数量级。
不受CPU限制的进程大部分时间都会被阻塞,等待事件发生。因为阻塞只能在系统调用中发生。对于不受CPU限制的进程,数字将大致相同(可能仅相差1位数百分比)。
这是一个简单的解释,实际上还有几个方面需要考虑。由于内存映射和交换,进程实际上可以被阻塞,而不需要在系统调用中。此外,内核还可以提供一些特性,包括在内核代码中进行计算。这可能导致进程在系统调用中花费大部分时间,并且仍然受到CPU的限制。例如,后者可能在使用加密文件系统时发生。
发布于 2014-11-21 19:00:19
系统调用之外的时间是在程序进入下一个系统调用之前运行程序代码所花费的时间。
https://serverfault.com/questions/645850
复制相似问题