四 性能调试---内存性能分析( 二 )


自由内存的大小(free memory size): what is currently available,it should not be confuzed with available memory,which does not change during normal sytem operation;
swap queue length;
2)单个进程的内存衡量指标:

一个进程占用物理内存的大小(resident set size)
一个进程占用虚拟内存的大小(virtual set size)
VM reads and writes: it can show how many physical memory management reads and writes were made to and from the disk during the chosen interval.

内存资源成为系统性能的瓶颈的征兆


当内存资源成为系统性能的瓶颈时,它有一些典型的症状:

很高的换页率(high pageout rate):HP-UX是一个按需调页的操作系统,通常情况下,它只执行调入页面进入内存的操作,以让进程能够运行 。只有操作系统觉得系统需要释放一些内存空间时,才会执行从内存调出页面的操作,而过高的调出页面操作说明内存缺乏;
进程进入不活动状态(process deactivation activity):当自由的内存页面数量小于MINFREE时,很多进程将强制进入不活动状态,因为,any deactivation activity represents a condition in which normal paging is inadequate to handle the memory demands.
自由内存的数量很小,但活动的虚拟内存却很大(very small free memory and large active virtual memory)
交换区所有磁盘的活动次数可高(high disk activity on swap devices)
可高的全局系统CPU利用率(high global system CPU utilization):
很长的运行进程队列,但CPU的空闲时间却很多(large run queue with idle CPU)
内存不够出错(out of memory errors)
CPU用于vhand和swapper两中守护进程的时间(CPU time to vhand and swapper)
必须注意的是,有时候我们发现CPU很忙,这似乎是CPU资源成为系统性能的瓶颈,但如果进一步分析,发现vhand和swapper守护进程占用了大量的系统CPU时间,很显然,这时系统性能瓶颈真正所在可能是内存 。


什么地方/哪些进程是占用内存资源的大户?


下面是一些典型的占用内存资源的大户:

buffer cache
plocked process:plocked processes are those that are locked in memory and are not elogible to be paged.通常,这些进程都是一些比较重要的进程,不便调出内存 。
档案库(archive libraries):把库放入内存可以加快程序的执行,但它们将占用大量的内存;
共享内存(shared memory)
关系型数据库(relational databases)
X-终端和X-服务器进程(X-terminals and X-servers):通常,一个X-终端需要额外的2-4兆内存;一个X-服务器需要400KB以上的内存;

利用vmstat命令分析内存的利用率


vmstat-report virtual memory statistics

The vmstat command reports certain statistics kept about process, virtual memory, trap, and CPU activity. It also can clear the accumulators in the kernel sum structure.

它的语法:

vmstat [-dnS] [interval [count]]

vmstat -f | -s | -z

它的选项的说明:

-d: Report disk transfer information as a separate section, in the form of transfers per second.
-n: Provide an output format that is more easily viewed on an 80-column display device. This format separates the default output into two groups: virtual memory information and CPU data. Each group is displayed as a separate line of output. On multiprocessor systems, this display format also provides CPU utilization on a per CPU basis.
-S: Report the number of processes swapped in and out (si and so) instead of page reclaims and address translation faults (re and at)
interval: Display successive lines which are summaries over the last interval seconds. If interval is zero, the output is displayed once only. If the -d option is specified, the column headers are repeated. If -d is omitted, the column headers are not repeated.
count: Repeat the summary statistics count times. If count is omitted or zero, the output is repeated until an interrupt or quit signal is received.

推荐阅读