MySQL huge page will give a performance upgrade it?

Has recently been doing things related to the performance of the pressure test, there is public consultation number of readers have praised the database server has no open huge page, I have heard huge page performance has improved, we would check it out. Of course not interested can look conclusions directly.

Two Huge Page context

2.1 Why Huge Page

When you run large memory footprint applications on Linux Caozuojitong, since it uses the default page size is 4KB, and thus will produce more TLB Miss and page fault, which greatly affect the performance of the application. When Caozuojitong even greater as a unit with 2MB paging, will greatly reduce the number of TLB Miss and page fault, and significantly improve the performance of your application. This is why the direct introduction of the Linux kernel supports large pages. The benefits are obvious, assuming that the application needs to 2MB of memory, if Caozuoxitong to 4KB page as a unit, you need 512 pages, in turn, requires 512 entries in the TLB, but also need 512 page table entries, operations the system needs to undergo at least 512 times and 512 times TLB Miss page fault in order to map the entire 2MB of space applications to physical memory; however, when using the basic unit of 2MB Caozuojitong as paging, just once TLB Miss and a page fault , that can 2MB of space applications to establish the actual situation mapping, and during operation without having to go through TLB Miss and page fault (assuming no TLB entry and replace Swap occur).

In order to enable large page support to minimize the cost, Linux operating system with a large page support 2M bytes hugetlbfs special file system. This special file system embodiment in the form of support for large pages, such that the flexibility to choose the application virtual memory page size according to need, without being forced to use large 2MB pages. via (InnoDB enable large memory pages)

2.2 HugePage advantages:

1. Increase TLB hit rate

2.Page is locked in memory, reducing memory exchange;

3. Lock memory, the memory is released and reduced performance degradation resulting footprint;

4. To improve memory performance and reduce CPU load.

Three mysql How huge page

huge pages the size of the different systems may be different, we use centos7 huge page size defaults to 2M.

How many huge pages 3.1 computing needs

First we have to calculate how many huge page assigned to use mysql before enabling huge page. General advice is to use the mysql total memory size plus 10%. Calculated as follows

S =  (query_cache_size + table_open_cache + innodb_buffer_pool_size + innodb_log_file_size + performance_schema.memory) + 10 %

So the size of the number is huge pages

vm.nr_hugepages=S/2M

3.2 Set mysql user group using huge pages

You get mysql located by id mysql group id

# id mysqluid=27(mysql) gid=27(mysql) groups=27(mysql)

echo 27 > /proc/sys/vm/hugetlb_shm_group

3.3 memlock limit provided for mysql user "unlimited" value

Edit increase /etc/security/limits.conf

# <Domain> <type> <Item> <value> 
#
#where:
# <Domain> CAN BE:
# - User name A
# - indicates not limited @mysql mysql user group
## disposed mysql using hugepages
@mysql
Soft Unlimited MEMLOCK
@mysql
Hard MEMLOCK Unlimited

Edit my.cnf increase in [mysqld] inside

large_pages=1

3.4 verify whether the entry into force hugepage

# cat /proc/meminfo | grep HugeAnonHugePages:   1294336 kBHugePages_Total:    5834HugePages_Free:     1394HugePages_Rsvd:      921HugePages_Surp:        0Hugepagesize:       2048 kB

That there is no value of 0, HugePagesFree less than HugePagesTotal.

MySQL 3.5 startup problems you might encounter

When starting mysql, the most likely to report the error is:

[Warning] InnoDB: Failed to allocate 140509184 bytes. errno 12[Warning] InnoDB: Using conventional memory pool

Appears above tips because of high probability

1.nr_hugepages value is smaller than the memory size * 2M innodb used to adjust the value of nr_hugepages.

2. Is Set for memlock mysql user group. When you start mysql, be sure to check to see with ulimit -a max locked memory set is reasonable.

3.6 Pressure test results

OS centos 7.10 3.10 kernel 

DB-related parameters measured pressure

MySQL huge page will give a performance upgrade it?

 

 

MySQL huge page will give a performance upgrade it?

 

Two instances of a large pages open and unopened no difference in performance. And online information that is inconsistent performance will be improved.

Four summary

According to information I have official documents and the Internet, check out the steps to open a large page memory is not unusual, but the pressure measured twice. If there is pressure measured huge page readers and friends have performance improvement, please leave a message mutual exchange of learning.

Reference article

Official Documents

https://dev.mysql.com/doc/refman/5.7/en/large-page-support.html

InnoDB enable large memory pages

https://www.cnblogs.com/gomysql/p/3627915.html

Huge Page is whether to save the performance panacea?

http://cenalulu.github.io/linux/huge-page-on-numa/

Guess you like

Origin www.cnblogs.com/CQqfjy/p/12454289.html