13. •
Finding class representation and creating runtime representation of class in the
JVM (in the method area)
Done by a class loader, and triggered by another type referencing the class in
its run-time constant pool
14. •
Bootstrap class loader (built into the JVM)
User-defined class loaders (subclass of ClassLoader)
•
•
1. Its fully qualified name
2. Its defining class loader
15. •
verifying correct structure of class representation
creating and initializing static fields
Resolves symbolic references from the constant pool
Examples:
iconst_0
istore_0
aload_0 VerifyError due to wrong type
16. •
Triggered upon execution of new, getstatic, putstatic, invokestatic; or
upon initialization of a subclass
JVM synchronizes the initialization to avoid multiple threads initializing the
same class or recursive initialization.
22. objectref
invokevirtual indexbyte1 indexbyte2
Invokes an instance method based on the object reference on the operand stack
1. indexbyte1 and indexbyte2 are used to fetch method from constant pool
2. The method is looked up from the class containing the method
3. The actual method invoked depends on the actual class C of objectref (could be declared
in C, its superclass or superinterfaces)
arg2
arg1
objectref
. . .
New
frame
. . .
arg1 arg2
Local variables
23. invokestatic indexbyte1 indexbyte2
Invokes a static method based
indexbyte1 and indexbyte2 are used to fetch method from constant pool
Class or interface declaring the method is initialized if not already done
arg2
arg1
(double)
. . .
New
frame
. . . arg1 arg2
Local variables
arg1
arg1
30. public void foo() {
int sum = add(8, 10);
// ...
}
public int add(int x, int y) {
return x + y;
}
-XX:InlineSmallCode=n
-XX:MaxInlineSize=35
-XX:FreqInlineSize=n
31. public void foo() {
int[] input = getInput();
int value = computeValue(input);
// we don’t use value
}
public int computeValue(int[] array) {
...
}
32. public void loopInvariantHosting(int size) {
for (int i = 0; i < 1000; i++) {
int x = 3;
int result = size * x;
// ...
}
}
public void loopInvariantHosting(int size) {
int x = 3;
int result = size * x;
for (int i = 0; i < 1000; i++) {
// ...
}
}
33. public void loopUnswitching(int[] array, boolean condition) {
for (int i = 0; i < array.length; i++) {
if(condition) {
// branch1
} else {
// branch2
}
}
}
public void loopUnswitching(int[] array, boolean condition) {
if(condition) {
for (int i = 0; i < array.length; i++) {
// branch1
}
} else {
for (int i = 0; i < array.length; i++) {
// branch2
}
}
}
34. public void escapeAnalysis() {
BooleanContainer obj = new BooleanContainer(false);
// ...
}
class BooleanContainer {
boolean f;
}
public void escapeAnalysis() {
// equivalent to boolean b = false;
// ...
}
38. • Allocate and deallocate memory to the program
• Determine areas of heap memory that are used by the program
• Free unused memory to be reused for subsequent allocations
• Available GC algorithms in HotSpot:
1. Serial collector (-XX:+UseSerialGC)
2. Parallel collector (-XX:+UseParallelGC)
3. Concurrent Mark Sweep (CMS) collector (-XX:+UseConcMarkSweepGC)
4. G1 collector (-XX:+UseG1GC) (default since Java 9)
• All collectors parallelize their workload, except the serial GC
• Serial collector is suitable for small programs: heap size < 100 MB
• G1 is suitable for large, multithreaded programs running on a machine with high
amount of memory
39. • Measured in three key aspects:
1. Pause time: time it takes to stop the application and run GC
Controlled using -XX:MaxGCPauseMillis=millis
2. Throughput: ratio of GC time / application time
Controlled using -XX:GCTimeRatio=nn
Maximum 1 / (1 + nn) of the application execution time be spent in the
collector
e.g. value of 19 means desired GC time ratio is 1/20 or 5%
3. Footprint: size of heap. GC can adjust heap size based on behavior
40. • There is usually a trade-off between pause time and throughput
• High throughput is suitable for a web server
• Short pause time is suitable for GUI application
• In an ideal situation the heap will grow to a value (less than the maximum) that will support
the chosen throughput goal.
• -verbose:gc or (-XX:+PrintGC) can be used to print GC messages
• -XX:-PrintGCDetails for more details
41. • Heap memory is composed of generations holding objects by age:
1. Young generation
2. Old generation
• Young gen triggers minor collection; old gen triggers major collection
Young gen
Eden
S
1
S
2
Old gen
Serial GC
generational
collection
Minor GC Major GC
42. • Unless you have problems with pauses, try granting as much memory as possible to the virtual
machine. The default size is often too small.
• Setting -Xms and -Xmx to the same value increases predictability by removing the most
important sizing decision from the virtual machine. However, the virtual machine is then unable
to compensate if you make a poor choice.
• In general, increase the memory as you increase the number of processors, because allocation
can be made parallel.
–XX:NewRatio: Ratio of old/new generation sizes. The default value is 2.
-XX:MinHeapFreeRatio=40: Minimum percentage of heap free after GC to avoid expansion.
-XX:MaxHeapFreeRatio=70: Maximum percentage of heap free after GC to avoid shrinking.
43. • Default GC for server VM (until Java 9)
• Uses multiple threads to collect unused memory
• Number of threads used for GC is a fraction of hardware threads (hardware configuration). It can
be changed using -XX:ParallelGCThreads=<N>
• Goal priority:
1. maximum pause-time goal
2. throughput goal
3. footprint goal
• Throws OutOfMemoryError in > 98% of time spent on GC and < 2% of object heap is claimed
(GC overhead limit)
Les volumes explosent, les latences se réduisent de plus en plus pour rester compétitif, respecter les réglementations (et éviter la prochaine crise financière) …
Par exemple, on fait du Big Data, du calcul sur GPU, du calcul In-Memory.
Le métier de la finance reste tout aussi riche qu’avant. Si vous aimez faire de la modélisation métier, c’est un domaine de rêve pour appliquer des techniques comme le BDD ou le DDD.
Juste quelque chiffres, Murex c’est 17 bureaux avec 2000 personnes dont 350 devs dans le monde, répartis entre Paris, Beyrouth, Dublin New York et Singapour.
On cherche des bons devs ! Venez nous parler à la pause ou allez faire un tour sur notre site si vous êtes intéressés.
Frame size is implementation-specific, but depends on method (number of local variables, depth needed for intermediate operands)