Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Huge Pages and Transparent Hug

2025-03-12 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Concept:

Memory is managed by blocks, known as pages. A page has 4096 bytes. 1MB memory equals 256 pages. 1GB memory equals 256000 pages, and so on. CPU has built-in memory management units that contain lists of pages, each of which is referenced by page table entries.

There are two ways for the system to manage large amounts of memory:

a. Increase the number of page tables in the hardware memory management unit

b. Increase the page size

The first method is expensive because the hardware memory management unit in modern processors only supports hundreds or bookmark page table entries. In addition, hardware and memory management algorithms for managing thousands of pages (MB memory) may not be able to manage millions (or even billions) of pages very well. This can cause performance problems: but the program needs to use more pages than the memory management unit supports, and the system falls back to slow software-based memory management, causing the entire system to run slowly.

Red Hat Enterprise Linux 6 uses the second approach, even with oversized pages.

In short, oversized pages are blocks of memory the size of 2MB and 1GB. 2MB uses page tables to manage multiple GB memory, while 1GB pages are the best choice for TB memory.

Oversized pages must be allocated at boot time. They are also difficult to manage manually and often require code changes so that they can be used effectively. So Red Hat Enterprise Linux also deployed transparent oversized pages (THP). THP is an extraction layer that automatically creates, manages, and uses most aspects of oversized pages.

THP system administrators and developers have reduced a lot of the complexity of using oversized pages. Because THP is designed to improve performance, its developers (community and Red Hat developers) have tested and optimized THP in a variety of systems, configurations, programs, and loads. This allows the default settings of THP to improve the performance of most system configurations.

HugePages is a feature of the Linux kernel version 2.6 and later that allows large page management memory to lock SGA into physical memory as an alternative to small 4KB page sizes, eliminating the need for system page table lookups on SGA. Transparent HugePages memory is different from standard HugePages memory because kernel khugepaged threads dynamically allocate memory at run time. Standard HugePages memory is pre-allocated at startup and does not change at run time. Red

Hat Enterprise Linux 6,Red Hat Enterprise Linux 7,SUSE 11,Oracle Linux

Transparent HugePages memory is enabled by default for 6 and Oracle Linux 7, and earlier versions of Oracle Linux have Unbreakable

Enterprise Kernel 2 (UEK2) kernel.

Transparent HugePages, although more flexible than HugePages, can cause memory allocation delays at run time, resulting in node restarts and performance problems. To avoid performance problems, Oracle recommends that transparent HugePages be disabled on all Oracle database servers. Use standard HugePages to improve performance.

Advantages:

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.

Larger page size and smaller number of pages: the default page size is 4K and the Huge TLB is 2048K, which means that the system needs to process 512 times as many pages.

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.

Because HugePage covers a larger contiguous range of virtual addresses than regular pages, the TLB hit probability of using HugePages to get each TLB entry is higher than that of regular pages. This reduces the number of times the page table gets a physical address from a virtual address.

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.

On a virtual memory system (any modern operating system), each memory operation is actually two abstract memory operations. With HugePages, possible bottlenecks in page table access can be significantly avoided because of the small number of pages to be processed.

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.

From the perspective of the Oracle database, using the HugePages,Linux kernel uses less memory to create page tables to maintain virtual-to-physical mapping of the SGA address range than regular-sized pages. This makes more memory available for process-specific computing or PGA use.

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 is not interchangeable (while regular pages are). Therefore, there is no page replacement mechanism overhead. HugePages is generally considered to be fixed.

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

If a very large area is paged (that is, the 13 million-page table entry for 50GB memory), kswapd will become very busy and will use a lot of CPU resources. When using HugePages, kswapd is not involved in managing them. See also paper 361670.1

The noun explains:

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 and HugePages are not compatible:

The MEMORY_TARGET / MEMORY_MAX_TARGET instance initialization parameters enable the 11g AMM feature. The same is true for default database instances created with DBCA. Starting at 11.2.0.3, if DBCA detects that the machine's RAM exceeds 4GB, AMM is no longer configured by default. Using AMM, allocate all SGA memory by creating a file under / dev / shm. When Oracle DB performs SGA allocation, HugePages is not used. If you want to use HugePages, be sure to unset the MEMORY_TARGET / MEMORY_MAX_TARGET initialization parameters for the database instance (that is, use "ALTER SYSTEM RESET"). On systems using HugePages, trying to set MEMORY_TARGET / MEMORY_MAX_TARGET instance initialization parameters may result in the following error message: ORA-00845: MEMORY_TARGET not supported on this system

Reference:

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... (document ID 361323.1) HugePages on Oracle Linux 64-bit (document ID 361468.1)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report