Hugepages are you using it? -- Concept

Source: Internet
Author: User


Hugepages are you using it? ---- Concept

Hugepages are you using it?----Test Cases

Introduction

The system process accesses the memory through a virtual address, but the CPU must convert it to the physical memory address to truly access the memory. To improve the conversion efficiency, the CPU caches the ing between the nearest virtual memory address and the physical memory address and stores it in a CPU-maintained ing table. To increase the memory access speed as much as possible, you need to save as many mappings as possible in the ing table.
In Linux, memory is divided into pages. By default, each page is 4 kb, which means that if the physical memory is large, there will be a lot of entries in the ing table, which will affect the retrieval efficiency of the CPU. Because the memory size is fixed, to reduce the number of ing table entries, you can only increase the page size.

I,HugepagesAnd related concepts

Hugepage was introduced in the Linux2.6 kernel, mainly providing 4 K page and relatively large page options.

Some display concepts need to be clarified. Before we continue to discuss Hugepages, such as hugetlb and hugetlbfs

The data structure model of the virtual memory system on the operating system. It is used to store the correspondence between virtual addresses and physical addresses.

When we access the memory, we first access "page table", and then Linux accesses the real physical memory ram + swap through "page table" mapping)

TLB: A Translation Lookaside Buffer (TLB)

TLB is a fixed-size buffer (or cache) allocated in the cpu. It is used to save part of the "page table" content, so that the CPU can access it faster and perform address translation.

Hugetlb: Hugetlb records entries in TLB and points them to Hugepage. So HugePages is called through hugetlb entries.

Hugetlbfs: This is a new memory file system based on 2.6 kernel, like tmpfs.

In TLB, hugetlb is used to point to hugepage. The allocated hugepage is provided to the process as the memory file system hugetlbfs (similar to tmpfs.

2. Request Process of "regular page" and "huge page"

When a process requests memory, it needs to access the "page table" Pagetable of the file system to call an actual physical memory address.

650) this. width = 650; "height =" 424 "border =" 0 "src =" http://www.bkjia.com/uploads/allimg/131229/1Z055C52-0.gif "alt =" clip_image002 "title =" clip_image002 "style =" border: 0px none; "/>

After Hugepage is deployed, a common page table is still called. The biggest difference is that the Hugepage attribute is added to process pagetable and system pagetable. Therefore, the page entries in any page table can beRegular page"Or"Huge page"650) this. width = 650; "height =" 432 "border =" 0 "src =" http://www.bkjia.com/uploads/allimg/131229/1Z0551923-1.gif "alt =" clip_image004 "title =" clip_image004 "style =" border: 0px none; "/>

HugePageThe size varies from 2 MB to 256 MB according to the kernel version and hardware architecture, as shown in the following table:

HW Platform

Source Code Tree

Kernel 2.4

Kernel 2.6

Linux x86 (IA32)

I386

4 MB

4 MB *

Linux x86-64 (AMD64, EM64T)

X86_64

2 MB

2 MB

Linux Itanium (IA64)

Ia64

256 MB

256 MB

IBM Power Based Linux (PPC64)

Ppc64/powerpc

N/**

16 MB

IBM zSeries Based Linux

S390

N/

N/

Ibm s/390 Based Linux

S390

N/

N/

Iii. Advantages of hugepage

1.HugePages will be allocated directly when the system is started and the corresponding memory area will be retained

2.HugePages will not be released or changed after it is started without administrator intervention.

3.Not swappable:HugePages is not swap. That is, there is no page-in/page-out. HugePages is always pin in memory

4.Relief of TLB pressure:

The purge TLB reduces the loading of transaction entries and improves the performance.

After Hugepages is used, TLB can cover a larger memory address space and speed up address conversion.

Fewer TLB entries mean a larger space for recording other address spaces

  1. No 'swapd 'operations: in Linux, the process "kswapd" manages swap. If it is large memory, the number of pages is very large. For example: 50 GB memory contains 1 million 3 million page table entries), which consumes amazing CPU resources. If hugepages is used, kswapd does not consume resources to manage it. You can view document 361670.1.
  2. Eliminated page table lookup overhead:Because hugepage is not swappable, there is no page table lookups.
  3. Faster overall memory performance:Because the virtual memory requires two steps to actually correspond to the physical memory address, less pages reduces page table access and avoids page table hotspot bottlenecks.

 

4. How to configure Hugepages

Configure Hugepages according to the following steps. To modify Hugepages, restart the machine. Please plan the downtime.

Step 1:You need to set the memlock value (unit: KB) in/etc/security/limits. conf. The value is smaller than the memory size. For example, if your memory size is 64 GB, you can set the following values:

* Soft memlock 60397977
* Hard memlock 60397977

There is no harm if this value is greater than the SGA requirement.

For more information about the parameters of the Exadata server, see section 1284261.1.


Step 2:Log on to the root and oracle users again and checkMemlockLimit

$ Ulimit-l
60397977

Step 3:If you use 11G or a later version, AMM is enabled by default, but AMM and Hugepages are incompatible, you must disable AMM first.
-----------------------------------------------------------------

Disable the memory_max_target and memory_target Parameters

Note that the official document says "unset". directly alter system set memory_target = 0 scope = spfile; the change is unsuccessful. Set it to '0' directly. The following error is returned:

ORA-00843: Parameter not taking MEMORY_MAX_TARGET into account.
ORA-00849: SGA_TARGET 35433480192 cannot be set to more than MEMORY_MAX_TARGET 0.
ORA-01078: failure in processing system parameters

Create a pfile. ora file and delete the two parameters "MEMORY_TARGET/MEMORY_MAX_TARGET" in the file ". Then create a spfile.

-----------------------------------------------------------------

Step 4:

Make sure that all your instances have been started (including ASM) andHugepages_settings.sh to evaluate the size of Hugepages to be set.

$./Hugepages_settings.sh
...
Recommended setting: vm. nr_hugepages = 1496

Note: You can also calculate the required Hugepages size, which is actually Hugepages size> all of the SGA size.
Step 5:Edit/etc/sysctl. conf to set the vm. nr_hugepages parameter:

...
Vm. nr_hugepages = 1496
...

Step 6:Stop the instance and restart the OS

Step 7:Check whether the settings take effect

After the system restarts, start all the databases and run the following command to check

# Grep HugePages/proc/meminfo
HugePages_Total: 1496
HugePages_Free: 485
HugePages_Rsvd: 446
HugePages_Surp: 0

HugePages_Free<HugePages_TotalIt indicates that Hugepages has taken effect, andHugePages_Rsvd is not "0".

5. How to control whether the database SGA uses Hugepages?

In versions earlier than 11.2.0.2, the database SGA can only use hugepages or do not use hugepages at all.

In Versions later than 11.2.0.2, oracle added a new parameter "USE_LARGE_PAGES" to manage how the database uses hugepages.

USE_LARGE_PAGESThe parameter has three values: "true" (default), "only", "false" and "auto" (since 11.2.0.3 patchset ).

1. The default value is "true". If Hugepages is set by the system, the SGA will give priority to hugepages.
11.2.0.2 if there is not enough hugepages, SGA will not use hugepages. this causes a ORA-4030 error because hugepages has been allocated from the physical memory, But SGA does not use it, but uses other parts of the memory, resulting in insufficient memory resources
However, in version 11.2.0.3, the usage policy is changed. In SGA, hugepages can be used in part, and small pages can be used in the rest. In this way, SGA will use hugepages only, and then use regular sized pages after hugepages is used up.

2. If it is set to "false", SGA will not use hugepages

3. If it is set to "only", if the hugepages size is not enough, the database instance cannot be started (to prevent memory overflow ).

4. After version 11.2.0.3, you can set it to "auto". This option will trigger the oradism process to reconfigure the Linux kernel to increase the number of hugepages. Oradism must be granted the following permissions:

-Rwsr-x --- 1 root <oracle group>

It does not change the hugepages value in the/etc/sysctl. conf file. After the OS is restarted, the system restores the hugepages value configured in/etc/sysctl. conf.

6. What if the Database/SGA configuration changes?

When your system involves the following changes, you need to note that Hugepages may need to be reset.

  • Linux OS physical memory size change
  • Install a new database instance
  • The SGA size is changed on one or more database instances.

If the settings do not match your system changes, you will need the following questions:

  • Poor database performance
  • Poor database performance
  • System memory overflow or a large number of swapping
  • Database instance cannot be started
  • Core System Service failed

Based on the"Hugepages are you using it? -- Test Case.

 

Oracle official documentation

HugePages on Linux: What It Is... and What It Is Not... (Doc ID 361323.1)

HugePages on Oracle Linux 64-bit (docid 361468.1)

HugePages and Oracle Database 11g Automatic Memory Management (AMM) on Linux (Doc ID 749851.1)

Linux IA64 example of allocating 48 gb sga using hugepages (Doc ID 397568.1)

Shell Script to Calculate Values Recommended Linux HugePages/HugeTLB Configuration (Doc ID 401749.1)

USE_LARGE_PAGES To Enable HugePages In 11.2 (docid 1392497.1)

650) this. width = 650; "height =" 32 "border =" 0 "src =" http://www.bkjia.com/uploads/allimg/131229/1Z0551493-2.gif "alt =" clip_image005 "title =" clip_image005 "style =" border: 0px none; & quot;/> 650) this. length = 650; "height =" 32 "border =" 0 "src =" http://www.bkjia.com/uploads/allimg/131229/1Z0553J2-3.gif "alt =" clip_image005 [1] "title =" clip_image005 [1] "style =" border: 0px none; "/>

 

This article is from the blog "Little Dog's nest" and will not be reposted!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.