在前面的文章中,Oracle共享池體系結構進化論裡面,我們注意到,Oracle把共享池(Shared Pool)根據一定的規則劃分成許多的subpools,這種把大的需要管理對象按照一定規則切分成小對象進行分片管理的做法,在AIX UNIX操作系統的內存管理裡面也有用到,在這裡介紹給大家。下面是IBM文檔裡面的原文引述:
Introduction:
Starting with AIX V4.3.3, real memory is divided into one or more memory pools depending on the amount of real memory and the number of CPUs in an MP system.
The number of memory pools will be the maximum of #of CPUs/8 or RAMinGB/16, but not more than the # of CPUs and not less than 1. Memory pools are divided into one or
more framesets which allows concurrent memory allocation out of a memory pool.
Each memory pool has its own page replacement daemon, lrud (Least Recently Used Daemon).
Memory allocation is done round-robin across the memory pools where two pages per pool are allocated before moving to the next memory pool.
It is not recommended to change the number of memory pools or number of framesets per memory pool without advice from AIX development.
Memory pools:
To determine the number of memory pools on a machine, use:
- AIX 5L V5.2 and later: vmstat -v | grep “memory pools”
Note: The number of memory pools shown by vmo -a might not represent the actual number of active memory pools, thus vmstat must be used.
- AIX 5L V5.1 and earlier: vmtune -a | grep mempools
The number of memory pools can be changed with:
- AIX 5L V5.2 and later: vmo -r -o mempools=number_of_memory_pools
- AIX 5L V5.1 and earlier: vmtune -m number_of_memory_pools
Changes to the number of memory pools requires bosboot and reboot. While bosboot must be run manually on AIX 5L V5.1 and earlier, the vmo command on
AIX 5L V5.2 and later prompts for running bosboot automatically.
The number of memory pools cannot be changed with vmtune command on AIX 5L V5.2 and later, changes can only be done with vmo.
Framesets:
Each memory pool furthermore consists of one or more framesets. The default is two
framesets per memory pool. This allows concurrent memory allocation out of a single
memory pool. The number of concurrent memory allocations out of one memory pool is equal to the number of framesets in this pool.
The number of framesets in the first memory pool on a system might be different to the number of framesets in all other memory pools.
To determine the number of framesets on a machine:
- AIX 5L V5.2 and later: vmo -a | grep framesets
- AIX 5L V5.1 and earlier: vmtune -a | grep total_frame_sets
As for the number of active memory pools, vmo -a might not show the actual number of active framesets per memory pool.
The number of framesets per memory pool can be changed with:
- AIX 5L V5.2 and later: vmo -r -o framesets=number_of_framesets
- AIX 5L V5.1 and earlier: vmtune -v number_of_framesets
The number of framesets per memory pool cannot be changed with vmtune on AIX 5L V5.2, changes can only be done with vmo.
LRU Buckets:
Rather than scanning the entire page frame list of a memory pool to find pages to steal the page frame list is divided into buckets of page frames. The page replacement algorithm will scan the frames in the bucket and then start over on that bucket for a second scan. Then it will move on to the next bucket.
The default number of frames in a bucket is 131072 and can be changed with vmo/vmtune command.
Reducing the number of frames in an LRU bucket can reduce scanning overhead and latency in page replacement on large memory machines.
內存池個數可由下列參數控制:
testdb:/@root>#vmo -a|grep pool
mempools = 6 --這個
soft_min_lgpgs_vmpool = 0
vmo -o mempools=number_of_memory_pools 命令允許更改系統引導時配置的內存池數。若沒有充分理解系統行為以及 VMM 算法,建議不要更改這個值。不能更改 UP 內核和 MP 內核上的 mempools 值,此更改會寫到內核文件中。在IBM工程師的建議下,才可調整此參數,平時就不要自己去動它了。
對於系統中使用了哪些內存頁,我們常常會用到如下的命令,下面作一些簡單的列舉:
操作系統版本
testdb:/home/oracle>$oslevel -s
5300-07-00-0000
可以用此命令查看所有頁使用情況
testdb:/>#vmstat -P all
System configuration: mem=5888MB
pgsz memory page
----- -------------------------- ------------------------------------
siz avm fre re pi po fr sr cy
4K 1296880 1092224 80384 0 0 0 0 0 0
64K 13153 2618 10535 0 0 0 0 0 0
查看4k的頁使用情況
testdb:/>#vmstat -p 4k
System configuration: lcpu=4 mem=5888MB
kthr memory page faults cpu
----- ----------- ------------------------ ------------ -----------
r b avm fre re pi po fr sr cy in sy cs us sy id wa
1 1 1134110 248946 0 0 0 0 0 0 10 1357 98 0 0 99 0
psz avm fre re pi po fr sr cy siz
4K 1092223 80385 0 0 0 0 0 0 1296880
查看64k的頁使用情況
testdb:/>#vmstat -p 64k
System configuration: lcpu=4 mem=5888MB
kthr memory page faults cpu
----- ----------- ------------------------ ------------ -----------
r b avm fre re pi po fr sr cy in sy cs us sy id wa
1 1 1134104 248952 0 0 0 0 0 0 10 1357 98 0 0 99 0
psz avm fre re pi po fr sr cy siz
64K 2618 10535 0 0 0 0 0 0 13153
也可以通過svmon -G命令來查看整個系統的內存頁使用情況
testdb:/>#svmon -G --在AIX不同的版本中,此命令的輸出會有所差異
size inuse free pin virtual
memory 1507328 1260556 246772 988028 1136280
pg space 1507328 3166
work pers clnt other
pin 931389 0 0 56639
in use 1136280 0 124276
PageSize PoolSize inuse pgsp pin virtual
s 4 KB - 1218508 3166 964636 1094232
m 64 KB - 2628 0 1462 2628