Home > Database > Mysql Tutorial > body text

topas中PgSp字段的含义

WBOY
Release: 2016-06-07 15:29:15
Original
2173 people have browsed it

$topas -P Topas Monitor for host: jhhost Interval: 2 Thu Aug 26 16:23:57 2010 DATA TEXT PAGE PGFAULTS USER PID PPID PRI NI RES RES SPACE TIME CPU% I/O OTH COMMAND oracle 324076 1 102 20 1293 4827 1293 3:07 21.7 0 0 oracle patrol 307496 1 8

$topas -P
Topas Monitor for host: jhhost Interval: 2 Thu Aug 26 16:23:57 2010

DATA TEXT PAGE PGFAULTS
USER PID PPID PRI NI RES RES SPACE TIME CPU% I/O OTH COMMAND
oracle 324076 1 102 20 1293 4827 1293 3:07 21.7 0 0 oracle
patrol 307496 1 80 30 5072 619 11840 2465:39 0.3 0 230 PatrolAgent
patrol 241988 1 60 20 685 6 835 438:53 0.1 0 0 snmpmagt
oracle 463258 508290 60 20 441 49 441 0:00 0.0 0 0 topas
root 172464 156076 60 20 67 0 345 510:40 0.0 0 0 dtgreet
oracle 467318 1 60 20 1014 4827 1014 0:00 0.0 0 0 oracle
oracle 327748 1 60 20 256 4827 1084 16:25 0.0 0 0 oracle
patrol 299382 307496 60 20 187 954 539 39:58 0.0 0 0 sqlplus
oracle 311356 1 60 20 134 4827 1396 20:18 0.0 0 0 oracle
oracle 303164 1 60 20 131 4827 2167 25:44 0.0 0 0 oracle
root 278788 205276 60 20 40 61 306 47:43 0.0 0 0 i4llmd
root 28972 0 37 41 24 0 29 75:29 0.0 0 0 gil
root 61592 160160 60 20 64 26 651 20:13 0.0 0 0 X
root 4384 0 16 41 11 0 12 37:30 0.0 0 0 swapper
oracle 307258 1 60 20 469 4827 1873 17:29 0.0 0 0 oracle
root 221672 1 60 20 257 31 1600 9:26 0.0 0 0 ltid
root 282672 1 60 20 296 19 6578 7:27 0.0 0 0 vmd
root 225300 1 60 20 177 308 716 12:42 0.0 0 0 naviagen
root 204816 1 60 20 45 0 47 11:55 0.0 0 0 rpc.lock
root 192708 0 60 20 11 0 12 0:22 0.0 0 0 n4bg

$ topas
Topas Monitor for host: jhhost EVENTS/QUEUES FILE/TTY
Thu Aug 26 16:24:56 2010 Interval: 2 Cswitch 346 Readch 88771
Syscall 2742 Writech 23220
Kernel 0.5 |# | Reads 141 Rawin 0
User 42.3 |############# | Writes 124 Ttyout 259
Wait 0.1 |# | Forks 0 Igets 0
Idle 57.1 |################# | Execs 0 Namei 78
Runqueue 0.0 Dirblk 0
Network KBPS I-Pack O-Pack KB-In KB-Out Waitqueue 0.0
en0 69.2 112.5 118.5 45.7 23.5
lo0 2.0 3.5 3.5 1.0 1.0 PAGING MEMORY
en1 0.7 8.5 0.0 0.7 0.0 Faults 54 Real,MB 3728
Steals 0 % Comp 87.7
Disk Busy% KBPS TPS KB-Read KB-Writ PgspIn 0 % Noncomp 8.5
hdisk46 0.0 39.2 0.5 0.0 39.2 PgspOut 0 % Client 8.5
skpower7 0.0 39.2 0.5 0.0 39.2 PageIn 0
hdisk1 1.0 8.0 2.0 0.0 8.0 PageOut 0 PAGING SPACE
Sios 0 Size,MB 16384
Name PID CPU% PgSp Owner % Used 15.1
oracle 410020 24.9 5.0 oracle NFS (calls/sec) % Free 84.8
oracle 324076 23.4 5.1 oracle ServerV2 0
PatrolAgent 307496 0.1 46.2 patrol ClientV2 0 Press:
topas 389584 0.1 1.8 oracle ServerV3 0 "h" for help
dtgreet 172464 0.1 1.3 root ClientV3 0 "q" to quit

上面是在 AIX 5.3 系统下的两份 topas 输出,第一份是仅输出进程(带 -P 选项),第二份是囊括 CPU、内存、交换空间、I/O 和进程多项资源指标于一个界面的 topas 标准输出。PgSp 是一项描述进程的指标,是 Page Space 的缩写,本义指的是进程所用页空间大小,在两份输出中,topas -P 显示的 Page Space 以页为单位(1页等于4KB),topas 标准输出中 PgSp 以 MB 为单位。

比较 HP-UX 、 Linux 和 AIX 上 top 输出中与 PgSp 相似的字段( HP-UX 上是 SIZE ,Linux 上是 VIRT),PgSp 实在是名字起得不好,太容易和 Paging Space 混淆,注意一个是名词 Page,一个是动词 Paging,Paging Space 在 AIX 中与 Swap Space 是互换使用的,Paging Space 是换页空间,也是交换区所在。PgSp 是虚空间(Virtual Space),不是换页空间或交换区空间。man topas 手册页对 Page Space 说明如下:

Virtual working set size used by process (4KB pages). Note: The true paging space allocations per process are not available using the topas command. Refer to the svmon command for more detailed.

PgSp 只包括进程私有数据段以及堆栈段虚空间,不含执行映象、共享库、共享内存部分,PgSp 的值一定大于或等于 DATA RES(见前面 topas -P 输出) 的值,因为 PgSp 会包括不在内存中的不活动的私有数据段部分或者已被交换到换页空间上的部分。什么叫不活动的数据段,举个例子,你有一个应用程序通过 malloc 系统调用申请了 1MB 内存空间,系统并非马上就在物理内存中就给它划了那么多空间,你如果一直不用这段内存(譬如作 I/O 操作),那么这段空间只在虚空间里存在。在前面 topas -P 输出中,我们看到一个进程号是 324076 的 oracle 进程,其 PgSp 与 Data RES 相同,都是 1293 页;一个进程号是 327748 的 oracle 进程,其 PgSp 是 1084 页,Data RES 是 256 页;一个进程号是 307496 的 PatrolAgent 进程,其 PgSp 是 11840 页,Data RES 是 5072 页。一般内存充裕的情况下,PgSp 与 Data RES 是一致的,除非你程序编得不好,申请一个大内存又不用。前面 topas 标准输出中我的计算内存(%Comp)已占到总内存的 88%,换页空间(paging space)使用了 15%,这不是一个内存很充分的系统。

大家会有一个问题:我如何知道换页空间(paging space)是被哪些进程占用了?前面那段英文交代得很清楚,topas 没法告诉你这些,用 svmon 命令可看到进程使用换页空间的情况。

另外要说明的是 ps 命令中也有类似 PgSp 的字段,以 PatrolAgent 这个进程(pid 号为 307496)为例,执行以下命令:

$ ps avx | head -1; ps avx | grep 307496
PID TTY STAT TIME PGIN SIZE RSS LIM TSIZ TRS %CPU %MEM COMMAND
307496 - A 2478:25 309661 47360 21900 32768 3632 2332 0.1 1.0 PatrolAgent

SIZE 字段与 PgSp 等义。ps 输出中与内存/虚存有关的单位是 KB,看 SIZE 值是 47360KB(46.2MB),也就是 11840 页,与 top 中的 PgSp 完全相同。

前面说过要了解 AIX 中某个进程使用换页空间的情况,正规方法是用 svmon 命令,不过你也可以用 ps 命令作个大致换算,看前面 PatrolAgent 进程的 ps 输出,SIZE-(RSS-TRS)=47360-(21900-2332)=27792KB, 这个 PatrolAgent 进程大概使用了26MB 的换页空间,嘿,这 26MB 也可能是未使用的虚空间呢。

你可以用下面的 shell 脚本来估算你的系统中全部进程占用了多少换页空间(提醒你只是估算):

$ ps avx | sed -e "1d" | awk 'BEGIN { total = 0 } { total += ( $6 - ( $7 - $10 ))} END { print "total = ",total }'

注意 AIX 的 ps 输出中 SIZE 字段以及 RSS 字段都不包括共享内存(shared memory)部分,这点与 Linux 不同,使用 ps 要注意到这种差异。一般数据库服务器的共享内存段都常驻内存,不会用到换页空间,如果上面 shell 脚本算出的换页空间占用量明显小于 lsps -s 命令显示的换页空间使用量,有可能大的共享内存段被交换出去了,这是非常糟糕的情况,要赶紧打报告,扩内存了。
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!