Virtual memory systems must translate the virtual addresses of your code and data into physical memory addresses before the memory can be accessed. These translations must occur for each instrustion and data element referenced.
Virtual addresses are divided into two parts: a page number and an offset within the page, as shown below:
The low order part of the address, which is the offset within the page, is the same for both virtual and physical addresses. The high order part, which is the page number, is different for each page.
In order to perform page number translations at machine speed, a table, called the Translation Lookaside Buffer (TLB), is maintained of the most recently referenced pages. If the page requested is within this table, processing continues at machine speed. However, if the page is not found, a TLB miss occurs. This results in a significant interruption of the processing.
When a TLB miss occurs, the following actions are performed:
The performance impact of frequent TLB misses can be significant, typically 5% or more on well tuned applications.
The number of entries in the TLB is relatively small, usually about 100. Keep in mind that this table must be scanned within the machine cycle for every referenced instruction and data element. The address space spanned by all entries in the TLB is also relatively small. For example, if there are 100 entries and the page size is 4 Kbytes, the total address range that can be used without a TLB miss is 400 Kbytes. This address space includes your instructions, data and occasionally parts of the operating system. If your application repeatedly runs through an address range larger that that amount, TLB thrashing will occur.
On some systems it is possible to change the page size of the allocated memory to significantly reduce the number of TLB misses. For example, if the page size is increased to 16 Mbytes and there are 100 TLB entries, then the total address range becomes 1.5625 Gbytes. Small pages are efficient for editing or transaction processing. However they are inefficient for large scientific applications.
The following table summarizes the available and optional page sizes for several systems:
|COMPAQ||Alpha EV6||UNIX 5.1||8 Kbytes||4 Mbytes||4194304||2|
|HP||PA-RISC||HP-UX Version 11||4 Kbytes||None||N/A||N/A|
|IBM||Power 4||AIX 5.1||4 Kbytes||16 Mbytes||16777216||2|
|4 Kbytes||16 Mbytes||16777216||2|
|SGI||Mips4||IRIX 6.5||16 Kbytes||16 Mbytes||16777216||2|
|SUN||UltraSPARC-III||SUN OS||4 Kbytes||16 Mbytes||16777216||2|