Java, MySql increased performance with Huge Pages
[Resources updates: 2010.07.07, 2009.11.03, 2009.05.27]
Long running, large memory, high performant applications often have special needs with respect to their memory management. On Linux, Solaris and other modern OSes, the translation look-aside buffer (TLB) - whose page size of 4k for many CPUs/OSes - becomes a scalability issue in these extreme conditions. In order to get around TLB scalability issues, huge page sizes are used to reduce the impact on performance. This can be of use to installations with large scale Java, MySql and other large memory applications.
300% improvement: "Well, in my case, I was able to achieve an over 3x improvement in my EJB 3 application, of which fully 60 to 70% of that was due to using large page memory with a 3.5GB heap. Now, a 3.5GB heap without the large memory pages didn't provide any benefit over smaller heaps without large pages. Besides the throughput improvements, I also noticed that GC frequency was cut down by two-thirds, and GC time was also cut down by a similar percentage (each individual GC event was much shorter in duration). Of course, your mileage will vary, but this one optimization is worth looking at for any high throughput application." [20]
25% - 300% improvement: "These memory accesses are then frequently cache misses which introduces a high latency to the memory request. Increasing page sizes from 4K to 16M significantly reduces this problem as the number of tlb misses drops. Typically it will reduce runtimes by 25-30% but in an extreme case I've seen an SPH code run 3x faster simply by enabling large pages." [8]
In this article[11], the too common problem of an intermittant, ephemeral but huge reduction in performance was solved by recognizing that 5GB of memory was taken-up in the page tables, made up of 4k pages. Solution: use Linux huge page size support and make pages larger, reducing the page table size to 200MB.
"Many Java applications, especially those using large heaps, can benefit from what the operating systems call large or huge pages."[10]
"17.26 times faster" (Linux, Java, 64bit) [19]
"While 16 GB pages are intended to only be used in very high-performance environments, 64 KB pages are general-purpose, and most workloads are likely to see a benefit by using 64 KB pages rather than 4 KB pages."[7]
Java on an OS that supports large page sizes has better performance for many application. Which applications? Use tools[43] to see the TLB cache hit rate when these applications run. Different CPUs support different page sizes:
Additional Huge Page resources
Long running, large memory, high performant applications often have special needs with respect to their memory management. On Linux, Solaris and other modern OSes, the translation look-aside buffer (TLB) - whose page size of 4k for many CPUs/OSes - becomes a scalability issue in these extreme conditions. In order to get around TLB scalability issues, huge page sizes are used to reduce the impact on performance. This can be of use to installations with large scale Java, MySql and other large memory applications.
300% improvement: "Well, in my case, I was able to achieve an over 3x improvement in my EJB 3 application, of which fully 60 to 70% of that was due to using large page memory with a 3.5GB heap. Now, a 3.5GB heap without the large memory pages didn't provide any benefit over smaller heaps without large pages. Besides the throughput improvements, I also noticed that GC frequency was cut down by two-thirds, and GC time was also cut down by a similar percentage (each individual GC event was much shorter in duration). Of course, your mileage will vary, but this one optimization is worth looking at for any high throughput application." [20]
25% - 300% improvement: "These memory accesses are then frequently cache misses which introduces a high latency to the memory request. Increasing page sizes from 4K to 16M significantly reduces this problem as the number of tlb misses drops. Typically it will reduce runtimes by 25-30% but in an extreme case I've seen an SPH code run 3x faster simply by enabling large pages." [8]
In this article[11], the too common problem of an intermittant, ephemeral but huge reduction in performance was solved by recognizing that 5GB of memory was taken-up in the page tables, made up of 4k pages. Solution: use Linux huge page size support and make pages larger, reducing the page table size to 200MB.
"Many Java applications, especially those using large heaps, can benefit from what the operating systems call large or huge pages."[10]
"17.26 times faster" (Linux, Java, 64bit) [19]
"While 16 GB pages are intended to only be used in very high-performance environments, 64 KB pages are general-purpose, and most workloads are likely to see a benefit by using 64 KB pages rather than 4 KB pages."[7]
Java on an OS that supports large page sizes has better performance for many application. Which applications? Use tools[43] to see the TLB cache hit rate when these applications run. Different CPUs support different page sizes:
- i386: 4K and 4M (2M in PAE mode)
- ia64: 4K, 8K, 64K, 256K, 1M, 4M, 16M, 256M
- PPC64: 4K and 16M
- POWER5+: 4K, 64K, 16MB, 16GB (!!)
- UltraSparc III: 8K, 64K, 512K, 4M
- UltraSparc T2: 8K, 64K, 4M, 256M
Additional Huge Page resources
- General:
- [1] Page size: Huge Pages. Wikipedia
- [2] Practical, transparent operating system support for superpages. 2002. Juan
Navarro, Sitaram Iyer, Peter Druschel, Alan Cox. 2002 paper looking at impact of huge pages on performance (up to 30% improvement)
- [3] Address Translation with Paging: Case studies for X86, SPARC, and PowerPC 2005
- [4] A transparent Linux super page kernel for Alpha, Sparc64 and IA32:reducing TLB misses of applications. 2002. Shimizu,, Naohiko and Takatori, Ken SIGARCH Comput. Archit. News 31 1. Also presentation
- [5] Accurate Cache and TLB Characterization Using Hardware Counters. 2004. Computational Science - ICCS
- [6] CMSC 611: Advanced Computer Architecture Cache and Memory 2003
- [7] AIX 5L Differences Guide Version 5.3 Addendum 2007
- [1] Page size: Huge Pages. Wikipedia
- Linux:
- [8] HugetlbUserFeedback 2006
- [9] Large page support in the Linux kernel 2002
- [10] Huge Pages and NUMA issues on Linux 2009
- [11] Performance tuning: Huge Pages in Linux 2008
- [12] Documentation / vm / hugetlbpage.txt 2008
- [13] Investigating the TLB Behavior of High-end Scientific Applications on Commodity Microprocessors
- [14] A Performance Evaluation of 64KB Pages on Linux for Power Systems. 2008
- [15] LinuxMM:HugePages 2008
- [16] HugeTLB - Large Page Support in the Linux Kernel 2008
- [17] Leverage transparent huge pages on Linux on POWER 2007
- [18] Configuring Systems and Running Applications with libhugetlbfs Utilities 2008
- [19] Linux Fork Performance Redux: Large Pages 2008
- See also [44]
- [8] HugetlbUserFeedback 2006
- Java:
- [20] JVM Performance Tuning 2008
- [21] NUMA-Aware Java Heaps for Server Applications 2005
- [22] NUMA Tuning for Java Server Applications 2005
- [23] Java SE Tuning Tip: Large Pages on Windows and Linux 2006
- [24] High Performance Java Technology in a Multi-Core World. 2007. General
performance guide, Page 44 shows howto for Linux (for CPUs that
support it)
- [25] Java Support for Large Memory Pages
- [26] Java SE 6 Performance White Paper: Support for large page heap on x86 and amd64 platforms
- [27] Java HotSpot VM Options: -XX:LargePageSizeInBytes=4m
- [28] Supersizing Java: Large Pages on the Opteron Processor, Part 1 2006
- [29] Supersizing Java: Large Pages on the Opteron Processor, Part 2 2006
- [30] Linux Fork Performance Redux: Large Pages A. 2006. Looks at Java on Linux.
- [31] Supporting Per-processor Local-allocation Buffers Using Multi-processor Restartable Critical Sections 2004
- [32] Java Knobs: How To Change Performance of the Sun JVM 2006
- [20] JVM Performance Tuning 2008
- MySql:
- Solaris/SPARC:
- [37] Supporting Multiple Page Sizes in the Solaris Operating System 2004
- [38] Developing and Tuning Applications on UltraSPARC-T1 Chip Multithreading Systems. 2007. "On UltraSPARC T1 processor-based systems, placing the Java heap on large pages generally gives a large performance increase." [p37]
- [39] UltraSPARC T1 large page projects in Solaris 2005
- [40] Taming Your Emu to Improve Application Performance 2004
- [41] OpenSolaris Virtual Memory: Large Page OS Support 2006
- [42] UltraSPARC T2: A Highly-Threaded, Power-Efficient, SPARC SOC. 2007. Solid-State Circuits Conference.
- [43] Multiple Page Size Support: Measuring MMU Overheads. 2007
- [37] Supporting Multiple Page Sizes in the Solaris Operating System 2004
- AMD
- Updates:
- 2009 05 27
- [47] Performance tuning: HugePages and Linux. [Oracle, Linux] 2008
- [48] MySQL Large Pages errors. [MySql] 2008
- [49] InnoDB Scalability Limits [MySql] 2008
- [50] Using Linux Hugepages with Oracle. [Oracle] 2008
- [51] Oracle11g Automatic Memory Management – Part I. Linux Hugepages Support. [Oracle] 2007
- [52] Oracle Database Doesn’t Use Hugepages Correctly. What’s Better, Reserved or Used? [Oracle, Linux] 2008
- [53] Hugepages revisited II: Be aware of kernel bugs! [Oracle, Linux] 2009
- [54] Dynamic Large Pages. [Linux] 2009 ****Very Good Presentation
- [55] Bazillions of Pages: The Future of Memory Management under Linux. [Linux] 2008
- [56] JVM Tuning for Multi-core Platforms. [Java, NUMA, Linux, Solaris, Windows] 2009 ****
- 2009 11 03
- [57] Calculating huge-page memory requirements for AIX dedicated memory partitions 2009
- [58] Linux / Storage: Memory – Huge Pages Overview [Linux] 2009
- [59] Number of Huge Pages on PS3 2009
- [60] Setting up 64bit Oracle 11gR1 on 64bit OEL5.4 with ramfs and hugepage configuration 2009
- [61] Implementing VLM and HugePages on production 2009
- [62] Red Hat Knowledgebase: What are Huge Pages and what are the advantages of using them? [Linux] 2009
- [63] KB42 - Huge Pages: Pros and Cons, When should I specify Huge Pages? Is there a set of guidelines on Huge Page usage? [AMD] 2009
- [64] Swiss National Supercomputing Centre: Programming and performance considerations:Huge pages support [Linux, Cray] 2009
- [65] Linux HugeTLBfs: Improve MySQL Database Application Performance [MySql, Linux] 2009
- [66] Superpages Revisited: Transparent Application of Large TLBs on Embedded Systems 2009
- [67] Using Linux Hugepages with Oracle 2009
- [68] Panyong Zhang; Bo Li; Zhigang Huo; Dan Meng, "Evaluating the Effect of Huge Page on Large Scale Applications," IEEE International Conference on Networking, Architecture, and Storage, NAS 2009. pp.74-81, 9-11 July 2009 DOI: 10.1109/NAS.2009.18
- [69] 64KB pages on Linux for Power systems 2009
- [70] Quantifying hugepages Memory Savings with Oracle Database 11g 2009
- [71] libhuge short and simple [Linux] 2009
- [72] Linux HugeTLBfs: Improve MySQL Database Application Performance 2009
- [73] Using Large Pages for Large Heap Sizes [Java] 2009
- [74] OpenSolaris Virtual Memory: Large Page OS Support 2009
- 2010 07 07
- [75] Debian HugePages [Linux] 2010
- [76] Huge Pages (Linux Weekly News article) [Linux, Java, Postgres] 2010
- [77] Linux / Storage: Memory – Huge Pages Overview [Linux] 2009
- [78] Huge pages [Linux] 2010
- [79] Large Memory Optimization [Linux, Red Hat, Oracle] 2009
- [80] Linux and Large Pages [Linux] 2010
- [81] Huge Pages and Linux-Real World example[Linux] 2010
- [82] Transparent hugepages. [Linux] 2009
- [75] Debian HugePages [Linux] 2010
Comments
I need your assistance on Java code for restoring the backup file into MySQL. If you can provide any kind of assistance that will be great.
Thanks
"5GB of memory was taken-up in the TLB" should be "5GB of memory was taken-up in the page tables".
FYI, link [54] is broken. Seems to be http://events.linuxfoundation.org/slides/lfcs09_hansen1.pdf now.