How can using huge page improve performance?

I have read that huge pages improve performance by reducing TLB lookups and reducing the size of the page table. Can someone tell me how this helps with performance?

Is this like if I have an application that uses 4 pages of virtual memory (4*4kb=16kb) then each page is mapped directly to some physical memory location, but if we use huge pages of 16kb size then instead of mapping 4 pages it just needs to map one, thus reducing page table size, and chances of swapping this out to disk is less and hence longer TLB cache?

  • 1
    "thus reducing page table size and chances of swapping" -> non sequitur at the "and". It's not consequently of anything, it's by fiat: huge pages cannot be swapped. Note that using huge pages does not mean all memory is managed that way. You have X huge pages, the rest is normal. Great example of this here: pythian.com/blog/performance-tuning-hugepages-in-linux
    – goldilocks
    Feb 26, 2013 at 9:46
  • Why performance is better with Huge page,also some article is mentioning about a patch that swaps Huge page,however since huge is large,swapping this can take more time than normal.I just need to know why there is performance benefit.
    – kevin
    Feb 26, 2013 at 10:19
  • 1
    @kevin because the probability that your subsequent memory access causes TLB hit is much higher with 2Mb pages than with 4Kb pages. Thus, the overhead to get proper Page Table Entry is lower.
    – Serge
    Feb 26, 2013 at 10:25
  • 2
    There isn't necessarily a performance benefit, there is a potential performance benefit depending on context. Depending on context and configuration, you could also just end up substantially reducing your amount of usable memory. So if you don't understand it or do not have a clear and definable need for it, just leave it alone.
    – goldilocks
    Feb 26, 2013 at 10:31
  • @goldilocks "huge pages cannot be swapped" - From lwn.net/Articles/758677 "if a huge page is swapped out, it will be swapped back in as individual pages".
    – jimis
    Mar 19, 2020 at 11:14

2 Answers 2


Serge answered it. The TLB has a fixed number of slots. If a virtual address can be mapped to a physical address with information in the TLB, you avoid an expensive page table walk. But the TLB cannot cache mappings for all pages.

Therefore, if you use larger pages, that fixed number of virtual to physical mappings covers a greater overall address range, increasing the hit ratio of the TLB (which is a cached mapping).


The other reason for improving the performance is having access to contiguous chunk of memory. Say, you have a PCIe device that DMA data into memory. By using hugepages, it can DMA 2MB (or up to 1GB) of data into contiguous DRAM space, whereas by using the default 4KB pages, you may need to jump into many different physical pages in DRAM, which causes slow down.

  • Aren't DMAs always working at a set speed? This will always access any memory address at that given speed? Feb 4, 2020 at 6:57
  • It matters if the memory is physically contiguous. Say you want to DMA 4 GB of data to 4x 1GB HugeTLB or to one million 4KB normal pages. For the latter, at worst, you have to jump one million times, since there's no guarantee that the OS provides all the memory pages residing back to back. Feb 5, 2020 at 0:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .