[20170209]理解pre_page_sga引數.txt

lfree發表於2017-02-09

[20170209]理解pre_page_sga引數.txt

--昨天測試pre_page_sga=true的情況:
http://blog.itpub.net/267265/viewspace-2133198/

--//再次看看官方的定義:

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,正好使用完,更加好理解,不再測試,留給大家測試.

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2133260/,如需轉載,請註明出處,否則將追究法律責任。

相關文章