溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

Huge Pages and Transparent Hug

發(fā)布時(shí)間:2020-06-26 04:34:03 來(lái)源:網(wǎng)絡(luò) 閱讀:352 作者:jsj_007 欄目:關(guān)系型數(shù)據(jù)庫(kù)

概念:

內(nèi)存是由塊管理,即眾所周知的頁(yè)面。一個(gè)頁(yè)面有 4096 字節(jié)。1MB 內(nèi)存等于 256 個(gè)頁(yè)面。1GB 內(nèi)存等于 256000 個(gè)頁(yè)面等等。CPU 有內(nèi)嵌的內(nèi)存管理單元,這些單元中包含這些頁(yè)面列表,每個(gè)頁(yè)面都使用頁(yè)表?xiàng)l目參考。
讓系統(tǒng)管理大量?jī)?nèi)存有兩種方法:
A.增加硬件內(nèi)存管理單元中頁(yè)表數(shù)
B.增大頁(yè)面大小
第一個(gè)方法很昂貴,因?yàn)楝F(xiàn)代處理器中的硬件內(nèi)存管理單元只支持?jǐn)?shù)百或者書(shū)簽頁(yè)表?xiàng)l目。另外適用于管理數(shù)千頁(yè)面(MB 內(nèi)存)硬件和內(nèi)存管理算法可能無(wú)法很好管理數(shù)百萬(wàn)(甚至數(shù)十億)頁(yè)面。這會(huì)造成性能問(wèn)題:但程序需要使用比內(nèi)存管理單元支持的更多的頁(yè)面,該系統(tǒng)會(huì)退回到緩慢的基于軟件的內(nèi)存管理,從而造成整個(gè)系統(tǒng)運(yùn)行緩慢。
紅帽企業(yè)版 Linux 6 采用第二種方法,即使用超大頁(yè)面。
簡(jiǎn)單說(shuō),超大頁(yè)面是 2MB 和 1GB 大小的內(nèi)存塊。2MB 使用的頁(yè)表可管理多 GB 內(nèi)存,而 1GB 頁(yè)是 TB 內(nèi)存的最佳選擇。
超大頁(yè)面必須在引導(dǎo)時(shí)分配。它們也很難手動(dòng)管理,且經(jīng)常需要更改代碼以便可以有效使用。因此紅帽企業(yè)版 Linux 也部署了透明超大頁(yè)面 (THP)。THP 是一個(gè)提取層,可自動(dòng)創(chuàng)建、管理和使用超大頁(yè)面的大多數(shù)方面。

THP 系統(tǒng)管理員和開(kāi)發(fā)者減少了很多使用超大頁(yè)面的復(fù)雜性。因?yàn)?THP 的目的是改進(jìn)性能,所以其開(kāi)發(fā)者(社區(qū)和紅帽開(kāi)發(fā)者)已在各種系統(tǒng)、配置、程序和負(fù)載中測(cè)試并優(yōu)化了 THP。這樣可讓 THP 的默認(rèn)設(shè)置改進(jìn)大多數(shù)系統(tǒng)配置性能。


HugePages是Linux 2.6及以上版本內(nèi)核的一個(gè)特性,它允許較大的頁(yè)面管理內(nèi)存,作為小型4KB頁(yè)面大小的替代,它將SGA鎖定到物理內(nèi)存中,從而無(wú)需對(duì)SGA進(jìn)行系統(tǒng)頁(yè)表查找。透明HugePages內(nèi)存與標(biāo)準(zhǔn)HugePages內(nèi)存不同,因?yàn)閮?nèi)核khugepaged線程在運(yùn)行時(shí)動(dòng)態(tài)分配內(nèi)存。標(biāo)準(zhǔn)HugePages內(nèi)存在啟動(dòng)時(shí)預(yù)先分配,并且在運(yùn)行時(shí)不會(huì)更改。Red
?Hat Enterprise Linux 6,Red Hat Enterprise Linux 7,SUSE 11,Oracle Linux
6和Oracle Linux 7默認(rèn)啟用透明HugePages內(nèi)存,早期版本的Oracle Linux具有Unbreakable
Enterprise Kernel 2(UEK2)內(nèi)核。

透明HugePages雖然比HugePages更加靈活卻可能會(huì)在運(yùn)行時(shí)導(dǎo)致內(nèi)存分配延遲,導(dǎo)致節(jié)點(diǎn)重新啟動(dòng)和性能問(wèn)題,為避免性能問(wèn)題,Oracle建議所有Oracle數(shù)據(jù)庫(kù)服務(wù)器上禁用透明HugePages。使用標(biāo)準(zhǔn)HugePages來(lái)提高性能。


優(yōu)點(diǎn):
Larger Page Size and Less # of Pages: Default page size is 4K whereas the HugeTLB size is 2048K. That means the system would need to handle 512 times less pages.

較大的頁(yè)大小與較少的頁(yè)數(shù):默認(rèn)頁(yè)大小為4K,HugeTLB為2048K,相同條件下,意味著系統(tǒng)需要處理512倍的頁(yè)面。


Reduced Page Table Walking: Since a HugePage covers greater contiguous virtual address range than a regular sized page, a probability of getting a TLB hit per TLB entry with HugePages are higher than with regular pages. This reduces the number of times page tables are walked to obtain physical address from a virtual address.

由于HugePage覆蓋了比常規(guī)頁(yè)面更大的連續(xù)虛擬地址范圍,因此使用HugePages獲得每個(gè)TLB條目的TLB命中的概率高于常規(guī)頁(yè)面。這減少了頁(yè)面表從虛擬地址獲取物理地址的次數(shù)。


Less Overhead for Memory Operations: On virtual memory systems (any modern OS) each memory operation is actually two abstract memory operations. With HugePages, since there are less number of pages to work on, the possible bottleneck on page table access is clearly avoided.

在虛擬內(nèi)存系統(tǒng)(任何現(xiàn)代操作系統(tǒng))上,每個(gè)內(nèi)存操作實(shí)際上是兩個(gè)抽象內(nèi)存操作。使用HugePages,由于要處理的頁(yè)面數(shù)量較少,因此可以明顯避免頁(yè)表訪問(wèn)的可能瓶頸。


Less Memory Usage: From the Oracle Database perspective, with HugePages, the Linux kernel will use less memory to create pagetables to maintain virtual to physical mappings for SGA address range, in comparison to regular size pages. This makes more memory to be available for process-private computations or PGA usage.

從Oracle數(shù)據(jù)庫(kù)的角度來(lái)看,與常規(guī)大小的頁(yè)面相比,使用HugePages,Linux內(nèi)核將使用更少的內(nèi)存來(lái)創(chuàng)建頁(yè)表,以維護(hù)SGA地址范圍的虛擬到物理映射。這使得更多內(nèi)存可用于進(jìn)程專用計(jì)算或PGA使用。


No Swapping: We must avoid swapping to happen on Linux OS at all Document 1295478.1. HugePages are not swappable (whereas regular pages are). Therefore there is no page replacement mechanism overhead. HugePages are universally regarded as pinned.

HugePages不可交換(而常規(guī)頁(yè)面是)。因此,沒(méi)有頁(yè)面替換機(jī)制開(kāi)銷(xiāo)。HugePages被普遍認(rèn)為是固定的。


No 'kswapd' Operations: kswapd will get very busy if there is a very large area to be paged (i.e. 13 million page table entries for 50GB memory) and will use an incredible amount of CPU resource. When HugePages are used, kswapd is not involved in managing them. See also Document 361670.1
如果有一個(gè)非常大的區(qū)域被分頁(yè)(即50GB內(nèi)存的1300萬(wàn)頁(yè)表?xiàng)l目),kswapd將變得非常繁忙,并將使用大量的CPU資源。使用HugePages時(shí),kswapd不參與管理它們。另見(jiàn)文件361670.1


名詞解釋:

Page Table: A page table is the data structure of a virtual memory system in an operating system to store the mapping between virtual addresses and physical addresses. This means that on a virtual memory system, the memory is accessed by first accessing a page table and then accessing the actual memory location implicitly.
TLB: A Translation Lookaside Buffer (TLB) is a buffer (or cache) in a CPU that contains parts of the page table. This is a fixed size buffer being used to do virtual address translation faster.
hugetlb: This is an entry in the TLB that points to a HugePage (a large/big page larger than regular 4K and predefined in size). HugePages are implemented via hugetlb entries, i.e. we can say that a HugePage is handled by a "hugetlb page entry". The 'hugetlb" term is also (and mostly) used synonymously with a HugePage (See Note 261889.1). In this document the term "HugePage" is going to be used but keep in mind that mostly "hugetlb" refers to the same concept.
hugetlbfs: This is a new in-memory filesystem like tmpfs and is presented by 2.6 kernel. Pages allocated on hugetlbfs type filesystem are allocated in HugePages.


AMM和HugePages不兼容:

MEMORY_TARGET / MEMORY_MAX_TARGET實(shí)例初始化參數(shù)啟用了11g AMM功能。使用DBCA創(chuàng)建的默認(rèn)數(shù)據(jù)庫(kù)實(shí)例也是如此,從11.2.0.3開(kāi)始,如果DBCA檢測(cè)到機(jī)器的RAM超過(guò)4GB,則默認(rèn)情況下不再配置AMM。使用AMM,通過(guò)在/ dev / shm下創(chuàng)建文件來(lái)分配所有SGA內(nèi)存。當(dāng)Oracle DB執(zhí)行SGA分配時(shí),不會(huì)使用HugePages。如果要使用HugePages,請(qǐng)確保為數(shù)據(jù)庫(kù)實(shí)例取消設(shè)置MEMORY_TARGET / MEMORY_MAX_TARGET初始化參數(shù)(即使用“ALTER SYSTEM RESET”)。在使用HugePages的系統(tǒng)上,嘗試設(shè)置MEMORY_TARGET / MEMORY_MAX_TARGET實(shí)例初始化參數(shù)可能會(huì)導(dǎo)致以下錯(cuò)誤消息:ORA-00845: MEMORY_TARGET not supported on this system


引用:

https://access.redhat.com/documentation/zh-cn/red_hat_enterprise_linux/6/html/performance_tuning_guide/s-memory-transhuge?
HugePages?on?Linux:?What?It?Is...?and?What?It?Is?Not...?(文檔?ID?361323.1)
HugePages?on?Oracle?Linux?64-bit?(文檔?ID?361468.1)


向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI