[20170209]理解pre_page_sga参数.txt
--昨天测试pre_page_sga=true的情况:
http://blog.itpub.net/267265/viewspace-2133198/
--//再次看看官方的定义:
http://docs.oracle.com/cd/E11882_01/server.112/e40402/initparams201.htm#REFRN10174
PRE_PAGE_SGA determines whether Oracle reads the entire SGA into memory at instance startup. Operating system page table
entries are then prebuilt for each page of the SGA. This setting can increase the amount of time necessary for instance
startup, but it is likely to decrease the amount of time necessary for Oracle to reach its full performance capacity
after startup.
Note:
This setting does not prevent your operating system from paging or swapping the SGA after it is initially read into
memory.
PRE_PAGE_SGA can increase the process startup duration, because every process that starts must access every page in the
SGA. The cost of this strategy is fixed; however, you might simply determine that 20,000 pages must be touched every
time a process starts. This approach can be useful with some applications, but not with all applications. Overhead can
be significant if your system frequently creates and destroys processes by, for example, continually logging on and
logging off.
The advantage that PRE_PAGE_SGA can afford depends on page size. For example, if the SGA is 80 MB in size and the page
size is 4 KB, then 20,000 pages must be touched to refresh the SGA (80,000/4 = 20,000).
If the system permits you to set a 4 MB page size, then only 20 pages must be touched to refresh the SGA (80,000/4,000 =
20). The page size is operating system-specific and generally cannot be changed. Some operating systems, however, have a
special implementation for shared memory whereby you can change the page size.
--//按照上面的定义如果我使用hupapage,这样启动数据库时,应该会加载全部页面.还是测试看看:
1.环境:
--//首先修改参数vm.nr_hugepages=600.
# sysctl -p
# sysctl vm.nr_hugepages
vm.nr_hugepages = 600
2.pre_page_sga=false ,使用hugepage的情况:
SYS@book> startup
ORACLE instance started.
Total System Global Area 634732544 bytes
Fixed Size 2255792 bytes
Variable Size 197133392 bytes
Database Buffers 427819008 bytes
Redo Buffers 7524352 bytes
Database mounted.
Database opened.
SYS@book> show parameter pre_page_sga
NAME TYPE VALUE
------------ -------- -------
pre_page_sga boolean FALSE
$ cat /proc/meminfo | grep -i page
AnonPages: 173732 kB
PageTables: 11052 kB
AnonHugePages: 38912 kB
HugePages_Total: 600
HugePages_Free: 393
HugePages_Rsvd: 98
HugePages_Surp: 0
Hugepagesize: 2048 kB
--//alert内存如下:
************************ Large Pages Information *******************
Per process system memlock (soft) limit = 51 GB
Total Shared Global Region in Large Pages = 610 MB (100%)
Large Pages used by this instance: 305 (610 MB)
Large Pages unused system wide = 295 (590 MB)
Large Pages configured system wide = 600 (1200 MB)
Large Page size = 2048 KB
********************************************************************
--实际上现在使用600-393=207.
--HugePages_Rsvd: 98
--207+98=305 正好对上. 换一句化将现在还有98页面块没有使用.仅仅使用207块.
--HugePages_Total-HugePages_Free+HugePages_Rsvd 就是 目前实例需要的页面数量.
3.pre_page_sga=true ,使用hugepage的情况:
SYS@book> alter system set pre_page_sga=true scope=spfile ;
System altered.
--//重启数据库.
$ cat /proc/meminfo | grep -i page
AnonPages: 179820 kB
PageTables: 11984 kB
AnonHugePages: 43008 kB
HugePages_Total: 600
HugePages_Free: 295
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
--//检查alert*.log文件:
************************ Large Pages Information *******************
Per process system memlock (soft) limit = 51 GB
Total Shared Global Region in Large Pages = 610 MB (100%)
Large Pages used by this instance: 305 (610 MB)
Large Pages unused system wide = 295 (590 MB)
Large Pages configured system wide = 600 (1200 MB)
Large Page size = 2048 KB
********************************************************************
--//HugePages_Rsvd是0.
--//600-295=305,使用305.
--//也就是pre_page_sga=true的情况下,启动时使用全部sga内存.而不像pre_page_sga=false那样,逐渐加载使用内存.
--//如果设置vm.nr_hugepages = 305,正好使用完,更加好理解,不再测试,留给大家测试.