Java Reference
In-Depth Information
tems with a large amount of memory, this will increase the number of pages that will fit in
the TLB cache and improve performance. To find the available page sizes on Solaris, use the
pagesize -a command.
QUICK SUMMARY
1. Using large pages will usually measurably speed up applications.
2. Large page support must be explicitly enabled in most operating systems.
Compressed oops
Chapter 4 mentioned that the performance of a 32-bit JVM is anywhere from 5% to 20%
faster than the performance of a 64-bit JVM for the same task. This assumes, of course, that
the application can fit in a 32-bit process space, which limits the size of the heap to less than
4 GB. (In practical terms, this often means less than 3.5 GB, since the JVM needs some nat-
ive memory space, and on certain versions of Windows, the limit is 3 GB.)
This performance gap is because of the 64-bit object references. The main reason for this is
64-bit references take up twice the space (8 bytes) in the heap as 32-bit references (4 bytes).
That leads to more GC cycles, since there is now less room in the heap for other data.
The JVM can compensate for that additional memory by using compressed oops. “oop”
stands for ordinary object pointer: oops are the handles the JVM uses as object references.
When oops are only 32 bits long, they can reference only 4 GB of memory ( ), which is
why a 32-bit JVM is limited to a 4 GB heap size. (The same restriction applies at the operat-
ing system level, which is why any 32-bit process is limited to 4GB of address space.) When
oops are 64 bits long, they can reference terabytes of memory.
There is a middle ground here: what if there were 35-bit oops? Then the pointer could refer-
ence 32 GB of memory ( ) and still take up less space in the heap than 64-bit references.
The problem is that there aren't 35-bit registers in which to store such references. Instead,
though, the JVM can assume that the last 3 bits of the reference are all 0. Now every referen-
ce can be stored in 32 bits in the heap. When the reference is stored into a 64-bit register, the
JVM can shift it left by 3 bits (adding three zeros at the end). When the reference is saved
from a register, the JVM can right-shift it by 3 bits, discarding the zeros at the end.
Search WWH ::




Custom Search