- The document discusses optimizing Java performance on hardware by leveraging features like AES-NI, transparent huge pages, and compiler intrinsics.
- It provides examples showing performance improvements from using these features, such as faster encryption times when enabling AES-NI and fewer TLB misses with transparent huge pages.
- It also discusses Java VM options, garbage collection, and the HotSpot compiler related to hardware optimization.
22. •
•
•
•
$ ulimit -v 102400
$ /usr/local/jdk1.8.0/bin/java -version
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (malloc) failed to allocate 80 bytes for AllocateHeap
# An error report file with more information is saved as:
# /home/xxx/hs_err_pid8664.log
38. $ java -cp jol-cli-0.3.1-full.jar:.
org.openjdk.jol.Main internals Test
:
Test object internals:
OFFSET SIZE TYPE DESCRIPTION VALUE
:
12 4 int Test.val1 0
16 4 int Test.val2 0
20 4 int Test.val3 0
24 4 int Test.val4 0
28 4 int Test.val5 0
Instance size: 32 bytes (reported by Instrumentation API)
Space losses: 0 bytes internal + 0 bytes external = 0 bytes total
$ java -XX:-RestrictContended -cp jol-cli-0.3.1-full.jar:.
org.openjdk.jol.Main internals Test
:
Test object internals:
OFFSET SIZE TYPE DESCRIPTION VALUE
:
12 128 (alignment/padding gap) N/A
140 4 int Test.val1 0
144 4 int Test.val2 0
148 4 int Test.val3 0
152 4 int Test.val4 0
156 4 int Test.val5 0
160 128 (loss due to the next object alignment)
Instance size: 288 bytes (reported by Instrumentation API)
Space losses: 128 bytes internal + 128 bytes external = 256 bytes total
@Contended無効 @Contended有効
ソフトウェア環境:
• Fedora21 x86_64
• kernel-3.18.7-200.fc21.x86_64
• glibc-2.20-8.fc21.x86_64
• java-1.8.0-openjdk-1.8.0.31-5.b13.fc21.x86_64
39. import sun.misc.Contended;
public class Test2{
@Contended("group")
public int val1;
@Contended("group")
public int val2;
public int val3;
public int val4;
@Contended
public int val5;
}
40. $ java -cp jol-cli-0.3.1-full.jar:.
org.openjdk.jol.Main internals Test2
:
Test2 object internals:
OFFSET SIZE TYPE DESCRIPTION VALUE
:
12 4 int Test2.val1 0
16 4 int Test2.val2 0
20 4 int Test2.val3 0
24 4 int Test2.val4 0
28 4 int Test2.val5 0
Instance size: 32 bytes (reported by Instrumentation API)
Space losses: 0 bytes internal + 0 bytes external = 0 bytes total
$ java -XX:-RestrictContended -cp jol-cli-0.3.1-full.jar:.
org.openjdk.jol.Main internals Test2
:
Test2 object internals:
OFFSET SIZE TYPE DESCRIPTION VALUE
:
12 4 int Test2.val3 0
16 4 int Test2.val4 0
20 128 (alignment/padding gap) N/A
148 4 int Test2.val5 0
152 128 (alignment/padding gap) N/A
280 4 int Test2.val1 0
284 4 int Test2.val2 0
288 128 (loss due to the next object alignment)
Instance size: 416 bytes (reported by Instrumentation API)
Space losses: 256 bytes internal + 128 bytes external = 384 bytes total
@Contended無効 @Contended有効
ソフトウェア環境:
• Fedora21 x86_64
• kernel-3.18.7-200.fc21.x86_64
• glibc-2.20-8.fc21.x86_64
• java-1.8.0-openjdk-1.8.0.31-5.b13.fc21.x86_64
53. https://wiki.openjdk.java.net/display/Sumatra/Standalone+Sumatra+Stream+API+Offload+Demo
final int length = 8;
int[] ina = new int[length];
int[] inb = new int[length];
int[] out = new int[length];
// Initialize the input arrays - this is offloadable
IntStream.range(0, length).parallel().forEach(p -> {
ina[p] = 1;
inb[p] = 2;
});
// Sum each pair of elements into out[] - this is offloadable
IntStream.range(0, length).parallel().forEach(p -> {
out[p] = ina[p] + inb[p];
});
54. We cannot speak for Project Sumatra or AMD. Project Graal decided to temporarily
remove the compiler's GPU support, because the original contributors
indicated to no longer maintain the code. We are still investigating outside
the main branch a new version of compilation support for heterogenous
architectures for Graal. If you want to compile and run a Graal version with GPU support in
the meantime, use this revision: http://hg.openjdk.java.net/graal/graal/rev/91fee1fab96d
<http://hg.openjdk.java.net/graal/graal/rev/91fee1fab96d>.
http://mail.openjdk.java.net/pipermail/sumatra-dev/2015-February/000308.html