在前面的文章中,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