In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "what is the big memory page in Linux". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "what is the big memory page in Linux"?
What is the "big memory page" in Linux?
Large memory pages help Linux systems to manage virtual memory. As the name implies, in addition to standard 4KB-sized pages, they can also help manage large pages in memory. Using "large memory pages", you can define the page size of 1GB.
During system startup, you can use "large memory pages" to reserve some memory for your application. This part of memory, that is, the memory occupied by "large memory pages", will never be swapped out of memory. It will remain in it unless you change the configuration. This can greatly improve the performance of applications that require a lot of memory, such as Oracle databases.
Why use large memory pages?
In virtual memory management, the kernel maintains a table that maps virtual memory addresses to physical addresses, and the kernel needs to load the relevant mapping for each page operation. If your memory pages are small, you will have a lot of pages to load, causing the kernel to load more mapping tables. And this degrades performance.
Using "large memory pages" means fewer pages are needed. This greatly reduces the number of mapping tables loaded by the kernel. This improves kernel-level performance and ultimately benefits the performance of the application.
In short, by enabling large memory pages, the system only needs to process fewer page mapping tables, thus reducing the overhead of accessing / maintaining them!
How do I configure large memory pages?
Run the following command to view the details of the current "large memory page".
Root@kerneltalks # grep Huge / proc/meminfoAnonHugePages: 0 kBHugePages_Total: 0HugePages_Free: 0HugePages_Rsvd: 0HugePages_Surp: 0Hugepagesize: 2048 kB
As you can see from the output above, the size of each page is 2MB (Hugepagesize) and there are currently 0 "large memory pages" (HugePages_Total) in the system. Here the size of the "large memory page" can be increased from 2MB to 1GB.
Run the following script to know how many large pages the system currently needs. The script is taken from Oracle.
#! / bin/bash## hugepages_settings.sh## Linux bash script to compute values for the# recommended HugePages/HugeTLB configuration## Note: This script does calculation for all shared memory# segments available when the script is run, no matter it# is an Oracle RDBMS shared memory segment or not.# Check for the kernel versionKERN= `uname-r | awk-F. '{printf ("% d% d\ n", $1) }'`# Find out the HugePage sizeHPG_SZ= `grep Hugepagesize / proc/meminfo | awk {'print $2'} `# Start from 1 pages to be on the safe side and guarantee 1 free HugePageNUM_PG=1# Cumulative number of pages required to handle the running shared memory segmentsfor SEG_BYTES in `ipcs-m | awk {' print $5'} | grep "[0-9] [0-9] *" `do MIN_PG= `echo "$SEG_BYTES/ ($HPG_SZ*1024)" | bc-q`if [$MIN_PG-gt 0] Then NUM_PG= `echo "$NUM_PG+$MIN_PG+1" | bc-q`fidone# Finish with resultscase $KERN in '2.4') HUGETLB_POOL= `echo "$NUM_PG*$HPG_SZ/1024" | bc-q`; echo "Recommended setting: vm.hugetlb_pool = $HUGETLB_POOL";;' 2.6' | '3.8' |' 3.10' | '4.1') echo "Recommended setting: vm.nr_hugepages = $NUM_PG";; *) echo "Unrecognized kernel version $KERN. Exiting. "; esac# End
Save it to / tmp as hugepages_settings.sh, and then run it:
Root@kerneltalks # sh / tmp/hugepages_settings.shRecommended setting: vm.nr_hugepages = 124
Your output is similar to the result above, but there will be some discrepancies in the numbers.
This means that your system needs 124 "large memory pages" for each 2MB! If you set the page size to 4MB, the result becomes 62. Do you understand?
Configure "large memory pages" in the kernel
Part of this article is to configure the kernel parameters mentioned above and then reload them. Add the following to / etc/sysctl.conf and issue the sysctl-p command to reload the configuration.
Vm.nr_hugepages=126
Notice that we have added two extra pages here, because we want some extra free pages in addition to the actual number of pages we need.
Now, the kernel is configured, but to enable applications to use these "large memory pages" also need to increase the memory usage threshold. The new memory threshold should be 126 pages x 2 MB = 252 MB per page, which is 258048 KB.
You need to edit the following configuration in / etc/security/limits.conf:
Soft memlock 258048hard memlock 258048
In some cases, these settings are configured in the file of the specified application, such as Oracle DB is configured in / etc/security/limits.d/99-grid-oracle-limits.conf.
It's done! You may also need to restart the app to allow the app to use these new huge pages.
How do I disable large memory pages?
Large memory Page is turned on by default. Use the following command to view the current status of the large memory Page.
Root@kerneltalks# cat / sys/kernel/mm/transparent_hugepage/ enabled[always] madvise never
The [always] flag in the output indicates that the system has "large memory pages" enabled.
If you are using a RedHat-based system, the file path you should view is / sys/kernel/mm/redhat_transparent_hugepage/enabled.
If you want to disable large memory pages, add transparent_hugepage=never after the kernel line in / etc/grub.conf, and then restart the system.
At this point, I believe you have a deeper understanding of "what is a big memory page in Linux". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.