1.5 Advantages of HugePages OverNormal Sharing Or AMM
(1) Notswappable: 不需要内存页交换
HugePages are not swappable. Therefore there is nopage-in/page-out mechanism overhead.HugePages are universally regarded aspinned.
(2)Relief of TLB pressure: 减轻TLB的压力
1)Hugepge uses fewer pages to cover thephysical address space, so the size of “book keeping” (mapping from the virtualto the physical address) decreases, so it requiring fewer entries in the TLB
2)TLB entries will cover a larger part ofthe address space when use HugePages, there will be fewer TLB misses before theentire or most of the SGA is mapped in the SGA
3)Fewer TLB entries for the SGA also meansmore for other parts of the address space
(3)Decreased page table overhead: 降低pagetable 的消耗
Each page table entry can be as large as64 bytes and if we are trying to handle 50GB of RAM, the pagetable will beapproximately 800MB in size which is practically will not fit in 880MB sizelowmem (in 2.4 kernels - the page table is not necessarily in lowmem in 2.6kernels) considering the other uses of lowmem. When 95% of memory is accessedvia 256MB hugepages, this can work with a page table of approximately 40MB intotal.
每个一个page table 的entry最大需要64 bytes的内存,如果我们管理50GB的内存,那么Pagetable 就需要约800MB的内存空间. 如果我们使用256MB的hugepage,同样对于50G的内存,我们只需要40MB的pagetable。
Dave 注释:
按普通模式,每个page 4k,那么需要的entries个数是:(50*1024*1024/4)
每个entry 是64bytes,所以总的内存大小就是:(50*1024*1024/4) * 64/1024/1024=800M
注意,这只是一个进程的page table,如果有10个进程,那么光处理这些page 就需要800*10,约8G的内存空间,而我们总共的内存也不过50G而已,所以大内存的情况下,需要HugePage就显的尤其重要。
HugePage 最大的大小从2M到256MB,按2MB算:
(50*1024/2)*64/1024/1024= 1.6M
10 进程也才16M而已。
(4)Eliminated page table lookup overhead: 降低page table 的lookup 次数
Since the pagesare not subject to replacement, page table lookups are not required.
(5)Faster overall memory performance: 提升内存的性能
On virtualmemory systems each memory operation is actually two abstract memoryoperations. Since there are fewer pages to work on, the possible bottleneck onpage table access is clearly avoided.
--virtual memory system 上的每一次内存操作实际上都需要2次内存的操作, hugepage减少了page数量从而避免了访问page table上的瓶颈。
