Solaris学习笔记(1)
作者: Badcoffee
Email: blog.oliver@gmail.com
Blog: http://blog.csdn.net/yayong
2005年6月
这方面比较好的参考资料有:
1. Solaris internal
Jim Mauro and Richard McDougall写的这部书实 在是太经典了,第一版是有中文版的,
第二版马上也要出了。下面是这本书的网站,上面有作者的blog和其它一些有用的资料:
http://www.solarisinternals.com
2. Sun官方文档站点
http://docs.sun.com
Solaris的man手册,还有很多有用的学习资料,比如mdb,dtrace的手册,都可以在这里找到。
下面就是我学习mpstat命令的笔记,就先从这里开始吧。
mpstat(1M)
NAME | SYNOPSIS | DESCRIPTION | OPTIONS | EXAMPLES | ATTRIBUTES | SEE ALSO | NOTES
NAME
- mpstat– report per-processor or
per-processor-set
statistics
报告每个处理器或者每个处理器集合的统计数据
SYNOPSIS
- /usr/bin/mpstat [-aq]
[-p| -Pset] [interval
[count]]
DESCRIPTION
- mpstat命令报告如下信息:
- CPU or SET
-
Without the -a option, mpstat reports CPU statistics for a processor ID. With the -a option, mpstat reports SET statistics for a processor set ID.
- 没有-a选项,mpstat以处理器ID来报 告CPU统计数据。有-a选项,mpstat以SET(处理器集合)ID来报告SET统计数据
- 问题:什么是SET?它与CPU差别?
The mpstat command reports processor statistics in tabular form. Each row of the table represents the activity of one processor. The first table summarizes all activity since boot. Each subsequent table summarizes activity for the preceding interval. All values are rates listed as events per second unless otherwise noted.
mpstat命令以列表形式报告处理器统计数据。表格的每行对应一个处理器的活动状态。第一个表格统计了从系统引导以来的所有活动数据。接下来
每个顺序的表统计了到之前表时间间隔的活动数据。除非特别注明,所有列出的数据是按照每秒种事件速率。
During execution of the kernel status command, the state
of the kernel can change. If relevant, a state change message is
included
in the mpstat output,
in one of the following forms:
在执行内核状态命令时,内核的状态会改变。如果相关,状态改变的信息被包括在mpstat的输出里,可以是下面的形式:
< |
The mpstat command reports the following information:
器集合上。 详细信息可以看psrset(1M)。例如,可以创建一个具有两个 CPU 的处
理器集,将我们的关键 应用的进程与该处理器集绑定。另外,禁止该处理器集中的
CPU 上的中断,从而不会有中断发 生在该处理器集中的处理器上。这样,这2个
CPU就只为我们的关键应用服务了,从而保证服务 稳定而且高效。
- minf
-
minor faults
- 辅助错误minor faults个数
- mjf
-
major faults
- 主要错误major faults个数
Solaris虚拟内存管理是借助MMU来实现的,一般MMU定义了三种异常:
major page faults、minor page faults、protection faults
major page faults发生在试图访问一个虚拟内存单元,该单元虽已经被map
到Solaris的某个段映像,但是并不存在于物理内存中,这时,MMU会触发一个
缺页中断(x86)或者trap(sparc),导致内核处理程序比较该内存错误地址发生在
哪个段。如果不属于任何一个段则给进程发送一个段错误SIGSEGV。否则,将
调用该段驱动程序的page-fault例程。调用该例程的结果可能是两种:
1. 该内存存在于swap区,段驱动通过vnode的getpage函数,从swap读入
到物理内存
2. 该内存从未被使用,需要新生成该页
minor page faults发生在试图访问一个虚拟内存单元,该单元已经被map到
Solaris的某个段映像,并且已经存在于物理内存,但还未建立物理内存与虚拟地址
空间 转换关系。例如系统种的共享库,就属于这种情形,实际上多个进程只是共享
同一共享 库的物理内存页,第一个引用共享库的进程导致一个major page faults,
而之后的其 它进程引用则只是minor page faults,attach在该库的物理内存上。
protection faults发生在试图访问一个虚拟内存单元,该单元访问方式与所在段的
访问 方式相悖。例如写程序的代码段将会导致该错误。
- xcal
-
inter-processor cross-calls
- 交叉调用cross-calls的数目。
交叉调用即cross-calls(xcalls),是处理器到处理器的中断。通常在SMP的系统中,
应用 于MMU的TLB coherency任务,CPU控制,或者强制一个CPU进入内核态。
例如,在 一个用户进程提交一个unmap的操作,会通过cross-calls来通知多个CPU
将MMU的TLB中的入口删除。
- intr
-
interrupts
- 中断数。
- ithr
-
interrupts as threads (not counting clock interrupt)
- csw
-
context switches
- 上下文切换数
- icsw
-
involuntary context switches
- 非主动的上下文切换数
- migr
-
thread migrations (to another processor)
- smtx
-
spins on mutexes (lock not acquired on first try)
-
在互斥锁mutexes上的自旋(即第一次试图获得锁未果)的次数
- srw
-
spins on readers/writer locks (lock not acquired on first try)
- syscl
-
system calls
- usr
-
percent user time
- sys
-
percent system time
- wt
-
time CPUs are idle pending I/O operations. See the NOTES section for more information on wt time.
-
CPU等待IO操作的空闲时间。更多信息参考
NOTES小节的wt时间
- idl
-
percent idle time
- sze
-
number of processors in the requested processor set
- 请求的处理器集合中的处理器个数
- set
-
processor set membership of each CPU
OPTIONS
- -a
-
Aggregate output by processor set. Sort the output by set. The default output is sorted by CPU number.
The following options are supported:
- -p
-
Report processor set membership of each CPU. Sort the output by set. The default output is sorted by CPU number.
- -P set
-
Display only those processors in the specified set.
- -q
-
Suppress messages related to state changes.
- interval
-
Report once each interval seconds.
- 每次报告间隔的秒数
- count
-
Only print count reports.
- 只显示指定次数的报告
EXAMPLES
Example 1 Using mpstat to Generate User and System Operation Statistics
例1 使用mpstat产生用户和系统操作统计数据
The following command generates processor statistics over a
five–second
interval in two reports. The command shows the processor set membership
of
each CPU. The default output is sorted by CPU number, aggregated by processor
set, for user (usr) and system (sys)
operations. See the NOTES section for more information on wt
time.
下面的命令以5秒的间隔产生了2个处理器的统计数据报告。命令显示了处理器集合与每个CPU的成员关系。默认用户和系统操作的输出是按照CPU
号,处理器集合排序。关于wt时间的更多信息请看NOTES小节。
example% mpstat -ap 5 2 |
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
ATTRIBUTE TYPE | ATTRIBUTE VALUE |
---|---|
Availability | SUNWcsu |
Interface Stability | See below. |
Invocation is evolving. Human readable output is unstable.
SEE ALSO
sar(1), iostat(1M), sar(1M), vmstat(1M), attributes(5)
NOTES
The sum of CPU utilization might vary slightly from 100 due to rounding errors in the production of a percentage figure.
CPU占用率的统计由于舍入错误,也许在百分比数字的总和略有不同,不是100。
The total time used for CPU processing is the sum of usr and sys output values, reported for user and system operations. The wt value reports the time that processors are idle pending I/O operations. The idl value reports the time that the CPU is idle for any reason other than pending disk I/O operations. The total amount of idle CPU time is, therefore, the sum of wt and idl output values.
CPU处理的总时间是用户和系统操作报告的值usr和值sys的和。值wt报告的是处理器空闲等待IO操作的时间。值idl报告的是CPU除去
等待磁盘IO操作外的因为任何原因而空闲的时间。CPU空闲的时间总数因此应该是wt和idl输出值之和。
High wt times indicate problems in the disk subsystem, not problems with CPUs or other processing elements. Excessive wt times must be addressed by improving the performance, especially the service times, of the busiest disk devices. Run the iostat command with the -x option to report I/O service times in svc_t output. The iostat utility also reports the same wt, user (us), and system (sy) statistics. See iostat(1M) for more information.
wt的时间高意味着磁盘子系统的问题,不是CPU和其他部分的问题。过高的wt时间必须通过提高性能,特别是最忙的磁盘设备的服务
时间来解决。
When executing in a zone and if the pools facility
is active, mpstat(1M)
will only provide information for
those processors which are a member of the processor set of the pool to
which
the zone is bound.
当在一个zone里执行,如果pools
facility处于活动状态,mpstat将只提供属于zone绑定的pool的处理器集合的成员的那些处理器的信息。
个人体会:mpstat与其它统计工具一样,不能够仅靠一个工具,或者工具报告的一个值就简单的给系统下结论。而且,统计数据的值到底达到多少
才算很高,也和系统的 配置,具体环境相关。分析系统性能,需要利用多个工具,相互印证,找出联系。Solaris
10推出的dtrace超越了传统的unix系统提供的性能工具,我们可以用dtrace的sysinfo provider来完成所有的性能分析工作。
Technorati tags: OpenSolaris Solaris
文章来源于领测软件测试网 https://www.ltesting.net/