Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the purpose of compressed object pointers?

Following my question on whether the CLR could use compressed pointers, the answer was that it's pretty pointless. Still, some JVMs are implementing it, so what are the concrete benefits of this optimization, since gaining 4 bytes doesn't seem worth it?

like image 519
Julien Lebosquain Avatar asked Aug 01 '11 23:08

Julien Lebosquain


People also ask

What is UseCompressedOops?

-XX:+UseCompressedOops enables the use of compressed 32 bit OOPS in 64 bit JVM which effectively compensates the performance penalty imposed by 64 bit JVM without scarifying heap size advantage offered by them.

What is UseCompressedClassPointers?

UseCompressedClassPointers uses a 32-bit offset to represent the class pointer in a 64-bit process as does UseCompressedOops for Java object references. A region is allocated for these compressed class pointers (the 32-bit offsets).

What is the max heap size for 64-bit JVM?

For 64 bit platforms and Java stacks in general, the recommended Maximum Heap range for WebSphere Application Server, would be between (4096M - 8192M) or (4G - 8G).


3 Answers

There is huge value in compressed references. First, on x86, 64 bit modes unlock 8 new registers to be used, which is a huge performance win. Second, using 4 byte instead of 8 byte headers / object pointers significantly improves cache efficiency. We see real-world benefits in IBM Java on the order of ~5-10% relative to a "full" 64 bit JVM (your mileage will vary). This makes moving to "small 64 bit" heaps an easy and painless thing, breaking past the ~2gb memory limit in 32 bit JVMs. (the real 32 bit limit it could be anywhere from 1700mb to ~3.7gb depending on the OS).

like image 139
Trent Gray-Donald Avatar answered Oct 25 '22 07:10

Trent Gray-Donald


You can gain 4 bytes from every object reference. If object has more references, it's common in java object, you can save more memory. Small object size could cause 2 results, first, the GC pause time is reduced. 2nd, cache hit rate is increased. So java application could gain performance improvement. For benchmark test, enable CompressedOops could improve performance by 5%~10% .

like image 29
Kuai Wei Avatar answered Oct 25 '22 08:10

Kuai Wei


If your main goal is to avoid garbage collections altogether, or at least have less frequent GC runs, it is worth it, since it can lead to substantial lower memory footprints.

like image 45
pyroscope Avatar answered Oct 25 '22 07:10

pyroscope