温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Huge Pages and Transparent Hug

发布时间:2020-06-26 04:34:03 来源:网络 阅读:343 作者:jsj_007 栏目:关系型数据库

概念:

内存是由块管理,即众所周知的页面。一个页面有 4096 字节。1MB 内存等于 256 个页面。1GB 内存等于 256000 个页面等等。CPU 有内嵌的内存管理单元,这些单元中包含这些页面列表,每个页面都使用页表条目参考。
让系统管理大量内存有两种方法:
A.增加硬件内存管理单元中页表数
B.增大页面大小
第一个方法很昂贵,因为现代处理器中的硬件内存管理单元只支持数百或者书签页表条目。另外适用于管理数千页面(MB 内存)硬件和内存管理算法可能无法很好管理数百万(甚至数十亿)页面。这会造成性能问题:但程序需要使用比内存管理单元支持的更多的页面,该系统会退回到缓慢的基于软件的内存管理,从而造成整个系统运行缓慢。
红帽企业版 Linux 6 采用第二种方法,即使用超大页面。
简单说,超大页面是 2MB 和 1GB 大小的内存块。2MB 使用的页表可管理多 GB 内存,而 1GB 页是 TB 内存的最佳选择。
超大页面必须在引导时分配。它们也很难手动管理,且经常需要更改代码以便可以有效使用。因此红帽企业版 Linux 也部署了透明超大页面 (THP)。THP 是一个提取层,可自动创建、管理和使用超大页面的大多数方面。

THP 系统管理员和开发者减少了很多使用超大页面的复杂性。因为 THP 的目的是改进性能,所以其开发者(社区和红帽开发者)已在各种系统、配置、程序和负载中测试并优化了 THP。这样可让 THP 的默认设置改进大多数系统配置性能。


HugePages是Linux 2.6及以上版本内核的一个特性,它允许较大的页面管理内存,作为小型4KB页面大小的替代,它将SGA锁定到物理内存中,从而无需对SGA进行系统页表查找。透明HugePages内存与标准HugePages内存不同,因为内核khugepaged线程在运行时动态分配内存。标准HugePages内存在启动时预先分配,并且在运行时不会更改。Red
 Hat Enterprise Linux 6,Red Hat Enterprise Linux 7,SUSE 11,Oracle Linux
6和Oracle Linux 7默认启用透明HugePages内存,早期版本的Oracle Linux具有Unbreakable
Enterprise Kernel 2(UEK2)内核。

透明HugePages虽然比HugePages更加灵活却可能会在运行时导致内存分配延迟,导致节点重新启动和性能问题,为避免性能问题,Oracle建议所有Oracle数据库服务器上禁用透明HugePages。使用标准HugePages来提高性能。


优点:
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.

较大的页大小与较少的页数:默认页大小为4K,HugeTLB为2048K,相同条件下,意味着系统需要处理512倍的页面。


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覆盖了比常规页面更大的连续虚拟地址范围,因此使用HugePages获得每个TLB条目的TLB命中的概率高于常规页面。这减少了页面表从虚拟地址获取物理地址的次数。


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.

在虚拟内存系统(任何现代操作系统)上,每个内存操作实际上是两个抽象内存操作。使用HugePages,由于要处理的页面数量较少,因此可以明显避免页表访问的可能瓶颈。


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数据库的角度来看,与常规大小的页面相比,使用HugePages,Linux内核将使用更少的内存来创建页表,以维护SGA地址范围的虚拟到物理映射。这使得更多内存可用于进程专用计算或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不可交换(而常规页面是)。因此,没有页面替换机制开销。HugePages被普遍认为是固定的。


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
如果有一个非常大的区域被分页(即50GB内存的1300万页表条目),kswapd将变得非常繁忙,并将使用大量的CPU资源。使用HugePages时,kswapd不参与管理它们。另见文件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实例初始化参数启用了11g AMM功能。使用DBCA创建的默认数据库实例也是如此,从11.2.0.3开始,如果DBCA检测到机器的RAM超过4GB,则默认情况下不再配置AMM。使用AMM,通过在/ dev / shm下创建文件来分配所有SGA内存。当Oracle DB执行SGA分配时,不会使用HugePages。如果要使用HugePages,请确保为数据库实例取消设置MEMORY_TARGET / MEMORY_MAX_TARGET初始化参数(即使用“ALTER SYSTEM RESET”)。在使用HugePages的系统上,尝试设置MEMORY_TARGET / MEMORY_MAX_TARGET实例初始化参数可能会导致以下错误消息: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问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI