SlideShare une entreprise Scribd logo
What the CRaC...
Coordinated Restore at Checkpoint
on the Java Virtual Machine
Gerrit Grunwald | Developer Advocate | Azul
ABOUTME.
JAVA IS
GREAT...
VIBRANT
COMMUNITY...
HUNDREDS OF


JUGs...
THOUSANDS OF


FOSS PROJECTS...
JAVA VIRTUAL


MACHINE
JAVA VIRTUAL


MACHINE
HOW DOES


IT WORK...
MyClass.java MyClass.class
SOURCE CODE COMPILER BYTE CODE
MyClass.class
BYTE CODE CLASS LOADER JVM MEMORY
JVM MEMORY
􀊫􀈒
EXECUTION ENGINE
EXECUTION ENGINE
Interpreter C1 JIT


Compiler


(client)
C2 JIT


Compiler


(server)
􀊫
Pro
fi
ler
􀈒
Garbage


Collector
EXECUTION ENGINE
Interpreter C1 JIT


Compiler


(client)
C2 JIT


Compiler


(server)
instruction set of CPU
Detects hot spots by


counting method calls
JVM
THRESHOLD


REACHED
Pass the hot spot methods


to C1 JIT Compiler
JVM C1 JIT


COMPILER
Compiles code as quickly


as possible with low optimisation
C1 JIT


COMPILER
Compiles code as quickly


as possible with low optimisation
Pro
fi
les the running code


(detecting hot code)
JVM
THRESHOLD


REACHED
Pass the "hot" code


to C2 JIT Compiler
JVM C2 JIT


COMPILER
Compiles code with best


optimisation possible (slower)
TIERED
COMPILATION
Level 0 - Interpreted code


Level 1 - C1 compiled code (no pro
fi
ling)


Level 2 - C1 compiled code (basic pro
fi
ling)


Level 3 - C1 compiled code (full pro
fi
ling, ~35% overhead)


Level 4 - C2 compiled code (uses pro
fi
le data from previous steps)
LEVELS OF EXECUTION
Level 0 - Interpreted code


Level 1 - C1 compiled code (no pro
fi
ling)


Level 2 - C1 compiled code (basic pro
fi
ling)


Level 3 - C1 compiled code (full pro
fi
ling, ~35% overhead)


Level 4 - C2 compiled code (uses pro
fi
le data from previous steps)
LEVELS OF EXECUTION
PREFERRED
EXECUTION
CYCLE
EXECUTION CYCLE
Slow
(Execution Level 0)
EXECUTION CYCLE
Finding


"hotspots"
Slow
(Execution Level 0)
EXECUTION CYCLE
Fast compile,


low optimisation
(Execution Level 3)
Finding


"hotspots"
Slow
(Execution Level 0)
EXECUTION CYCLE
Finding


"hot code"
Fast compile,


low optimisation
(Execution Level 3)
Finding


"hotspots"
Slow
(Execution Level 0)
EXECUTION CYCLE
Slower compile,


high optimisation
(Execution Level 4)
Finding


"hot code"
Fast compile,


low optimisation
(Execution Level 3)
Finding


"hotspots"
Slow
(Execution Level 0)
EXECUTION CYCLE
Can happen


(performance hit)
Slower compile,


high optimisation
(Execution Level 4)
Finding


"hot code"
Fast compile,


low optimisation
(Execution Level 3)
Finding


"hotspots"
Slow
(Execution Level 0)
DEOPTIMISATION
DEOPTIMISATION
if (value > 0)
result = 3; result = 0;
print(result);
TRUE FALSE
CODE
DEOPTIMISATION
if (value > 0)
result = 3; result = 0;
print(result);
TRUE FALSE
CODE
Hot Path (pro
fi
led)
DEOPTIMISATION
if (value > 0)
result = 3; result = 0;
print(result);
TRUE FALSE
CODE
guard (value > 0)
result = 3;


print(result);
DEOPTIMISE
TRUE FALSE
OPTIMIZED CODE
DEOPTIMISATION
if (value > 0)
result = 3; result = 0;
print(result);
TRUE FALSE
CODE
guard (value > 0)
result = 3;


print(result);
DEOPTIMISE
TRUE FALSE
OPTIMIZED CODE
value = 3
DEOPTIMISATION
if (value > 0)
result = 3; result = 0;
print(result);
TRUE FALSE
CODE
guard (value > 0)
result = 3;


print(result);
DEOPTIMISE
TRUE FALSE
OPTIMIZED CODE
value = 0
THAT'S
GREAT...
...BUT...
...IT TAKES
TIME !
JVM PERFORMANCE GRAPH
JVM STARTUP
GarbageCollector pauses
Deoptimisations
MICROSERVICE
ENVIRONMENT
MICROSERVICE ENVIRONMENT
FIRST RUN
JVM STARTUP
SECOND RUN
JVM STARTUP
THIRD RUN
JVM STARTUP
WOULDN'T IT BE GREAT...?
FIRST RUN
JVM STARTUP
SECOND RUN
NO STARTUP OVERHEAD
THIRD RUN
NO STARTUP OVERHEAD
SOLUTIONS...?
CLASS DATA
SHARING
WHAT ABOUT CDS?
Class Data Sharing (App/Dynamic)


Dump internal class representation into
fi
le


Shared on each JVM start (CDS)


No optimization or hotspot detection


Only reduces loading time of classes


Start up could be up to 1-2 seconds faster
MyClass.class
BYTE CODE CLASS LOADER JVM MEMORY
CDS
AHEAD OF TIME
COMPILATION
WHY NOT USE AOT?
No interpreting bytecodes


No analysis of hotspots


No runtime compilation of code


Start at full speed, straight away


GraalVM native image does that
PROBLEM SOLVED...?
NOT SO FAST...
AOT is, by de
fi
nition, static


Code is compiled before it is run


Compiler has no knowledge of how the
code will actually run


Pro
fi
le Guided Optimisation (PGO)
can partially help
JVM PERFORMANCE GRAPH
AOT Compiled Code
AOT Compiled Code with Profile Guided Optimisation
Needs to run once for pro
fi
ling
AOT VS JIT
Limited use of method inlining


No runtime bytecode generation


Re
fl
ection is possible but complicated


Unable to use speculative optimisations


Overall performance will typically be lower


Deployed env != Development env.


Full speed from the start


No overhead to compile code at runtime


Small memory footprint
Can use aggressive method inlining at runtime


Can use runtime bytecode generation


Re
fl
ection is simple


Can use speculative optimisations


Overall performance will typically be higher


Deployed env. == Development env.


Requires more time to start up


Overhead to compile code at runtime


Larger memory footprint
AOT JIT
JIT DISADVANTAGES
Requires more time to start up


CPU overhead to compile code at runtime


Larger memory footprint
AOT JIT
Reduced


Max Latency
Peak Throughput
Small Packaging
Startup Speed
Low Memory


Footprint
(Chart by Thomas Wuerthinger)
A DIFFERENT


APPROACH
CRIU
CHECKPOINT RESTORE IN USERSPACE
Linux project


Part of kernel >= 3.11 (2013)


Freeze a running container/application


Checkpoint its state to disk


Restore the container/application from the saved data.


Used by/integrated in OpenVZ, LXC/LXD, Docker,
Podman and others
CHECKPOINT RESTORE IN UUSERSPACE
Mainly implemented in userspace (not kernel)


Main goal is migration of containers for microservices


Heavily relies on /proc
fi
le system


It can checkpoint:


Processes and threads


Application memory, memory mapped
fi
les and shared memory


Open
fi
les, pipes and FIFOs


Sockets


Interprocess communication channels


Timers and signals


Can rebuild TCP connection from one side without need to exchange packets
CHECKPOINT RESTORE IN UUSERSPACE
Restart from saved state on another machine
(open
fi
les, shared memory etc.)


Start multiple instances of same state on same machine
(PID will be restored which will lead to problems)


A Java Virtual Machine would assume it was continuing its tasks
(very dif
fi
cult to use effectively)
CRIU CHALLENGES
CRaC
Coordinated Restore at Checkpoint
CRaC
CRIU comes bundled with the JDK


Heap is cleaned, compacted (JVM is in a safe state)


Throws CheckpointException (in case of open
fi
les/sockets)


Comes with a simple API


Creates checkpoints using code or jcmd


Uses JVM safepoint mechanism (to stop threads etc.)
openjdk.org/projects/crac
Lead by Anton Kozlov (Azul)
RUNNING APPLICATION
Aware of checkpoint


being created
RUNNING APPLICATION
Aware of restore


happening
CRaC has more restrictions (e.g. no open
fi
les, sockets etc.)
CRaC
CRaC
START
>java -XX:CRaCCheckpointTo=PATH -jar app.jar


RESTORE
>java -XX:CRaCRestoreFrom=PATH
CRaC API
<<interface>>
Resource
beforeCheckpoint()
afterRestore()
CRaC uses Resources that can be
noti
fi
ed about a Checkpoint and
Restore


Classes in application code
implement the Resource interface


The application receives callbacks
during checkpointing and
restoring


Makes it possible to close/restore
resources (e.g. open
fi
les, sockets)
CRaC API
Resource objects need to be registered with a Context so that they
can receive noti
fi
cations


There is a global Context accessible via the static
getGlobalContext() method of the Core class
CRaC API
<<interface>>
Resource
beforeCheckpoint()
afterRestore()
Core
getGlobalContext()
CRaC API
<<abstract>>
Context
register(Resource)
CRaC API
The global Context maintains a list of Resource objects


The beforeCheckpoint() methods are called in the reverse order the
Resource objects were added


The afterRestore() methods are called in the order the Resource
objects were added


Checkpoint and restore can be done programmatically by using
Core.checkpointRestore()


Checkpoint can also be created by jcmd
SIMPLE


EXAMPLE
SIMPLE EXAMPLE
Loop 100000x
Random number


1 - 100000
isPrime(number)
Cache
Scheduled Thread
Executed every


5 seconds
SIMPLE EXAMPLE
Loop 100000x
Random number


1 - 100000
isPrime(number)
Cache
Scheduled Thread
Executed every


5 seconds
SIMPLE EXAMPLE
Loop 100000x
Random number


1 - 100000
isPrime(number)
Is result for number
in cache?
Cache
Scheduled Thread
Executed every


5 seconds
SIMPLE EXAMPLE
Loop 100000x
Random number


1 - 100000
isPrime(number)
Is result for number
in cache?
Cache
Scheduled Thread
Executed every


5 seconds
SIMPLE EXAMPLE
Loop 100000x
Random number


1 - 100000
isPrime(number)
Is result for number
in cache?
yes
Cache
FAST
Scheduled Thread
Executed every


5 seconds
SIMPLE EXAMPLE
Loop 100000x
Random number


1 - 100000
isPrime(number)
Is result for number
in cache?
Calculate if prime
no
Cache
Scheduled Thread
Executed every


5 seconds
SIMPLE EXAMPLE
Loop 100000x
Random number


1 - 100000
isPrime(number)
Is result for number
in cache?
Calculate if prime
Result
no
Cache
Scheduled Thread
Executed every


5 seconds
SIMPLE EXAMPLE
Loop 100000x
Random number


1 - 100000
isPrime(number)
Is result for number
in cache?
Calculate if prime
Result
no
Cache
Scheduled Thread
Executed every


5 seconds
SIMPLE EXAMPLE
Loop 100000x
Random number


1 - 100000
isPrime(number)
Is result for number
in cache?
Calculate if prime
Result
no
Cache
SLOW
Scheduled Thread
Executed every


5 seconds
SIMPLE EXAMPLE
Loop 100000x
Random number


1 - 100000
isPrime(number)
Is result for number
in cache?
Calculate if prime
Result
no
Cache
Scheduled Thread
Executed every


5 seconds
timeout 50 sec
SIMPLE EXAMPLE
First run is slow because the cache is empty


Time to check 100 000 random numbers for
prime should decrease with every run
Application Performance
0
0.2
0.4
0.6
0.8
1
Iterations
1 2 3 4 5 6 7 8 9 10 11 12
SIMPLE EXAMPLE
DEMO...
>java -XX:CRaCCheckpointTo=/crac-files -jar crac4.jar


>
SIMPLE EXAMPLE
SHELL 1 SHELL 2
>java -XX:CRaCCheckpointTo=/crac-files -jar crac4.jar


>
De
fi
nes where to store
fi
les


for the checkpoint
SIMPLE EXAMPLE
SHELL 1 SHELL 2
>java -XX:CRaCCheckpointTo=/crac-files -jar crac4.jar


Running on CRaC (PID 4240)


First run will take up to 30 seconds...


Register Resource: GenericCache


Register Resource: Main


1. Run: 27863 ms (63303 elements cached, 63.3%)


>
SIMPLE EXAMPLE
SHELL 1 SHELL 2
>java -XX:CRaCCheckpointTo=/crac-files -jar crac4.jar


Running on CRaC (PID 4240)


First run will take up to 30 seconds...


Register Resource: GenericCache


Register Resource: Main


1. Run: 27863 ms (63303 elements cached, 63.3%)


>
SIMPLE EXAMPLE
SHELL 1 SHELL 2
>java -XX:CRaCCheckpointTo=/crac-files -jar crac4.jar


Running on CRaC (PID 4240)


First run will take up to 30 seconds...


Register Resource: GenericCache


Register Resource: Main


1. Run: 27863 ms (63303 elements cached, 63.3%)


>
SIMPLE EXAMPLE
SHELL 1 SHELL 2
>java -XX:CRaCCheckpointTo=/crac-files -jar crac4.jar


Running on CRaC (PID 4240)


First run will take up to 30 seconds...


Register Resource: GenericCache


Register Resource: Main


1. Run: 27863 ms (63303 elements cached, 63.3%)


>
SIMPLE EXAMPLE
Slow because cache is not
fi
lled yet
SHELL 1 SHELL 2
>java -XX:CRaCCheckpointTo=/crac-files -jar crac4.jar


Running on CRaC (PID 4240)


First run will take up to 30 seconds...


Register Resource: GenericCache


Register Resource: Main


1. Run: 27863 ms (63303 elements cached, 63.3%)


2. Run: 10611 ms (86580 elements cached, 86.6%)


>
SIMPLE EXAMPLE
SHELL 1 SHELL 2
>java -XX:CRaCCheckpointTo=/crac-files -jar crac4.jar


Running on CRaC (PID 4240)


First run will take up to 30 seconds...


Register Resource: GenericCache


Register Resource: Main


1. Run: 27863 ms (63303 elements cached, 63.3%)


2. Run: 10611 ms (86580 elements cached, 86.6%)


3. Run: 3965 ms (95161 elements cached, 95.2%)
>
SIMPLE EXAMPLE
SHELL 1 SHELL 2
>java -XX:CRaCCheckpointTo=/crac-files -jar crac4.jar


Running on CRaC (PID 4240)


First run will take up to 30 seconds...


Register Resource: GenericCache


Register Resource: Main


1. Run: 27863 ms (63303 elements cached, 63.3%)


2. Run: 10611 ms (86580 elements cached, 86.6%)


3. Run: 3965 ms (95161 elements cached, 95.2%)


4. Run: 1428 ms (98245 elements cached, 98.2%)
>
SIMPLE EXAMPLE
SHELL 1 SHELL 2
>java -XX:CRaCCheckpointTo=/crac-files -jar crac4.jar


Running on CRaC (PID 4240)


First run will take up to 30 seconds...


Register Resource: GenericCache


Register Resource: Main


1. Run: 27863 ms (63303 elements cached, 63.3%)


2. Run: 10611 ms (86580 elements cached, 86.6%)


3. Run: 3965 ms (95161 elements cached, 95.2%)


4. Run: 1428 ms (98245 elements cached, 98.2%)


5. Run: 533 ms (99340 elements cached, 99.3%)
>
SIMPLE EXAMPLE
SHELL 1 SHELL 2
>java -XX:CRaCCheckpointTo=/crac-files -jar crac4.jar


Running on CRaC (PID 4240)


First run will take up to 30 seconds...


Register Resource: GenericCache


Register Resource: Main


1. Run: 27863 ms (63303 elements cached, 63.3%)


2. Run: 10611 ms (86580 elements cached, 86.6%)


3. Run: 3965 ms (95161 elements cached, 95.2%)


4. Run: 1428 ms (98245 elements cached, 98.2%)


5. Run: 533 ms (99340 elements cached, 99.3%)


6. Run: 207 ms (99750 elements cached, 99.8%)
>
SIMPLE EXAMPLE
SHELL 1 SHELL 2
>java -XX:CRaCCheckpointTo=/crac-files -jar crac4.jar


Running on CRaC (PID 4240)


First run will take up to 30 seconds...


Register Resource: GenericCache


Register Resource: Main


1. Run: 27863 ms (63303 elements cached, 63.3%)


2. Run: 10611 ms (86580 elements cached, 86.6%)


3. Run: 3965 ms (95161 elements cached, 95.2%)


4. Run: 1428 ms (98245 elements cached, 98.2%)


5. Run: 533 ms (99340 elements cached, 99.3%)


6. Run: 207 ms (99750 elements cached, 99.8%)


7. Run: 87 ms (99898 elements cached, 99.9%)
>
SIMPLE EXAMPLE
SHELL 1 SHELL 2
>java -XX:CRaCCheckpointTo=/crac-files -jar crac4.jar


Running on CRaC (PID 4240)


First run will take up to 30 seconds...


Register Resource: GenericCache


Register Resource: Main


1. Run: 27863 ms (63303 elements cached, 63.3%)


2. Run: 10611 ms (86580 elements cached, 86.6%)


3. Run: 3965 ms (95161 elements cached, 95.2%)


4. Run: 1428 ms (98245 elements cached, 98.2%)


5. Run: 533 ms (99340 elements cached, 99.3%)


6. Run: 207 ms (99750 elements cached, 99.8%)


7. Run: 87 ms (99898 elements cached, 99.9%)


8. Run: 42 ms (99960 elements cached, 100.0%)


>
SIMPLE EXAMPLE
SHELL 1 SHELL 2
>java -XX:CRaCCheckpointTo=/crac-files -jar crac4.jar


Running on CRaC (PID 4240)


First run will take up to 30 seconds...


Register Resource: GenericCache


Register Resource: Main


1. Run: 27863 ms (63303 elements cached, 63.3%)


2. Run: 10611 ms (86580 elements cached, 86.6%)


3. Run: 3965 ms (95161 elements cached, 95.2%)


4. Run: 1428 ms (98245 elements cached, 98.2%)


5. Run: 533 ms (99340 elements cached, 99.3%)


6. Run: 207 ms (99750 elements cached, 99.8%)


7. Run: 87 ms (99898 elements cached, 99.9%)


8. Run: 42 ms (99960 elements cached, 100.0%)


9. Run: 25 ms (99986 elements cached, 100.0%)


>
SIMPLE EXAMPLE
SHELL 1 SHELL 2
>java -XX:CRaCCheckpointTo=/crac-files -jar crac4.jar


Running on CRaC (PID 4240)


First run will take up to 30 seconds...


Register Resource: GenericCache


Register Resource: Main


1. Run: 27863 ms (63303 elements cached, 63.3%)


2. Run: 10611 ms (86580 elements cached, 86.6%)


3. Run: 3965 ms (95161 elements cached, 95.2%)


4. Run: 1428 ms (98245 elements cached, 98.2%)


5. Run: 533 ms (99340 elements cached, 99.3%)


6. Run: 207 ms (99750 elements cached, 99.8%)


7. Run: 87 ms (99898 elements cached, 99.9%)


8. Run: 42 ms (99960 elements cached, 100.0%)


9. Run: 25 ms (99986 elements cached, 100.0%)


10. Run: 20 ms (99992 elements cached, 100.0%)
>
SIMPLE EXAMPLE
SHELL 1 SHELL 2
>java -XX:CRaCCheckpointTo=/crac-files -jar crac4.jar


Running on CRaC (PID 4240)


First run will take up to 30 seconds...


Register Resource: GenericCache


Register Resource: Main


1. Run: 27863 ms (63303 elements cached, 63.3%)


2. Run: 10611 ms (86580 elements cached, 86.6%)


3. Run: 3965 ms (95161 elements cached, 95.2%)


4. Run: 1428 ms (98245 elements cached, 98.2%)


5. Run: 533 ms (99340 elements cached, 99.3%)


6. Run: 207 ms (99750 elements cached, 99.8%)


7. Run: 87 ms (99898 elements cached, 99.9%)


8. Run: 42 ms (99960 elements cached, 100.0%)


9. Run: 25 ms (99986 elements cached, 100.0%)


10. Run: 20 ms (99992 elements cached, 100.0%)


11. Run: 17 ms (99999 elements cached, 100.0%)
>
SIMPLE EXAMPLE
SHELL 1 SHELL 2
>java -XX:CRaCCheckpointTo=/crac-files -jar crac4.jar


Running on CRaC (PID 4240)


First run will take up to 30 seconds...


Register Resource: GenericCache


Register Resource: Main


1. Run: 27863 ms (63303 elements cached, 63.3%)


2. Run: 10611 ms (86580 elements cached, 86.6%)


3. Run: 3965 ms (95161 elements cached, 95.2%)


4. Run: 1428 ms (98245 elements cached, 98.2%)


5. Run: 533 ms (99340 elements cached, 99.3%)


6. Run: 207 ms (99750 elements cached, 99.8%)


7. Run: 87 ms (99898 elements cached, 99.9%)


8. Run: 42 ms (99960 elements cached, 100.0%)


9. Run: 25 ms (99986 elements cached, 100.0%)


10. Run: 20 ms (99992 elements cached, 100.0%)


11. Run: 17 ms (99999 elements cached, 100.0%)
>
SIMPLE EXAMPLE
Fast because cache is
fi
lled
SHELL 1 SHELL 2
>java -XX:CRaCCheckpointTo=/crac-files -jar crac4.jar


Running on CRaC (PID 4240)


First run will take up to 30 seconds...


Register Resource: GenericCache


Register Resource: Main


1. Run: 27863 ms (63303 elements cached, 63.3%)


2. Run: 10611 ms (86580 elements cached, 86.6%)


3. Run: 3965 ms (95161 elements cached, 95.2%)


4. Run: 1428 ms (98245 elements cached, 98.2%)


5. Run: 533 ms (99340 elements cached, 99.3%)


6. Run: 207 ms (99750 elements cached, 99.8%)


7. Run: 87 ms (99898 elements cached, 99.9%)


8. Run: 42 ms (99960 elements cached, 100.0%)


9. Run: 25 ms (99986 elements cached, 100.0%)


10. Run: 20 ms (99992 elements cached, 100.0%)


11. Run: 17 ms (99999 elements cached, 100.0%)
SIMPLE EXAMPLE
>jcmd crac4.jar JDK.checkpoint
SHELL 1 SHELL 2
>java -XX:CRaCCheckpointTo=/crac-files -jar crac4.jar


Running on CRaC (PID 4240)


First run will take up to 30 seconds...


Register Resource: GenericCache


Register Resource: Main


1. Run: 27863 ms (63303 elements cached, 63.3%)


2. Run: 10611 ms (86580 elements cached, 86.6%)


3. Run: 3965 ms (95161 elements cached, 95.2%)


4. Run: 1428 ms (98245 elements cached, 98.2%)


5. Run: 533 ms (99340 elements cached, 99.3%)


6. Run: 207 ms (99750 elements cached, 99.8%)


7. Run: 87 ms (99898 elements cached, 99.9%)


8. Run: 42 ms (99960 elements cached, 100.0%)


9. Run: 25 ms (99986 elements cached, 100.0%)


10. Run: 20 ms (99992 elements cached, 100.0%)


11. Run: 17 ms (99999 elements cached, 100.0%)
SIMPLE EXAMPLE
>jcmd crac4.jar JDK.checkpoint CREATE CHECKPOINT
SHELL 1 SHELL 2
>java -XX:CRaCCheckpointTo=/crac-files -jar crac4.jar


Running on CRaC (PID 4240)


First run will take up to 30 seconds...


Register Resource: GenericCache


Register Resource: Main


1. Run: 27863 ms (63303 elements cached, 63.3%)


2. Run: 10611 ms (86580 elements cached, 86.6%)


3. Run: 3965 ms (95161 elements cached, 95.2%)


4. Run: 1428 ms (98245 elements cached, 98.2%)


5. Run: 533 ms (99340 elements cached, 99.3%)


6. Run: 207 ms (99750 elements cached, 99.8%)


7. Run: 87 ms (99898 elements cached, 99.9%)


8. Run: 42 ms (99960 elements cached, 100.0%)


9. Run: 25 ms (99986 elements cached, 100.0%)


10. Run: 20 ms (99992 elements cached, 100.0%)


11. Run: 17 ms (99999 elements cached, 100.0%)


beforeCheckpoint() called in Main


beforeCheckpoint() called in GenericCache


CR: Checkpoint ...


Killed


>


SIMPLE EXAMPLE
>jcmd crac4.jar JDK.checkpoint


4240:


Command executed successfully


>
SHELL 1 SHELL 2
>java -XX:CRaCCheckpointTo=/crac-files -jar crac4.jar


Running on CRaC (PID 4240)


First run will take up to 30 seconds...


Register Resource: GenericCache


Register Resource: Main


1. Run: 27863 ms (63303 elements cached, 63.3%)


2. Run: 10611 ms (86580 elements cached, 86.6%)


3. Run: 3965 ms (95161 elements cached, 95.2%)


4. Run: 1428 ms (98245 elements cached, 98.2%)


5. Run: 533 ms (99340 elements cached, 99.3%)


6. Run: 207 ms (99750 elements cached, 99.8%)


7. Run: 87 ms (99898 elements cached, 99.9%)


8. Run: 42 ms (99960 elements cached, 100.0%)


9. Run: 25 ms (99986 elements cached, 100.0%)


10. Run: 20 ms (99992 elements cached, 100.0%)


11. Run: 17 ms (99999 elements cached, 100.0%)


beforeCheckpoint() called in Main


beforeCheckpoint() called in GenericCache


CR: Checkpoint ...


Killed


>


SIMPLE EXAMPLE
>jcmd crac4.jar JDK.checkpoint


4240:


Command executed successfully


>
SHELL 1 SHELL 2
>java -XX:CRaCCheckpointTo=/crac-files -jar crac4.jar


Running on CRaC (PID 4240)


First run will take up to 30 seconds...


Register Resource: GenericCache


Register Resource: Main


1. Run: 27863 ms (63303 elements cached, 63.3%)


2. Run: 10611 ms (86580 elements cached, 86.6%)


3. Run: 3965 ms (95161 elements cached, 95.2%)


4. Run: 1428 ms (98245 elements cached, 98.2%)


5. Run: 533 ms (99340 elements cached, 99.3%)


6. Run: 207 ms (99750 elements cached, 99.8%)


7. Run: 87 ms (99898 elements cached, 99.9%)


8. Run: 42 ms (99960 elements cached, 100.0%)


9. Run: 25 ms (99986 elements cached, 100.0%)


10. Run: 20 ms (99992 elements cached, 100.0%)


11. Run: 17 ms (99999 elements cached, 100.0%)


beforeCheckpoint() called in Main


beforeCheckpoint() called in GenericCache


CR: Checkpoint ...


Killed


>java -XX:CRaCRestoreFrom=/crac-files


SIMPLE EXAMPLE
>jcmd crac4.jar JDK.checkpoint


4240:


Command executed successfully


>
SHELL 1 SHELL 2
>java -XX:CRaCCheckpointTo=/crac-files -jar crac4.jar


Running on CRaC (PID 4240)


First run will take up to 30 seconds...


Register Resource: GenericCache


Register Resource: Main


1. Run: 27863 ms (63303 elements cached, 63.3%)


2. Run: 10611 ms (86580 elements cached, 86.6%)


3. Run: 3965 ms (95161 elements cached, 95.2%)


4. Run: 1428 ms (98245 elements cached, 98.2%)


5. Run: 533 ms (99340 elements cached, 99.3%)


6. Run: 207 ms (99750 elements cached, 99.8%)


7. Run: 87 ms (99898 elements cached, 99.9%)


8. Run: 42 ms (99960 elements cached, 100.0%)


9. Run: 25 ms (99986 elements cached, 100.0%)


10. Run: 20 ms (99992 elements cached, 100.0%)


11. Run: 17 ms (99999 elements cached, 100.0%)


beforeCheckpoint() called in Main


beforeCheckpoint() called in GenericCache


CR: Checkpoint ...


Killed


>java -XX:CRaCRestoreFrom=/crac-files


SIMPLE EXAMPLE
>jcmd crac4.jar JDK.checkpoint


4240:


Command executed successfully


>
RESTORE
SHELL 1 SHELL 2
>java -XX:CRaCCheckpointTo=/crac-files -jar crac4.jar


Running on CRaC (PID 4240)


First run will take up to 30 seconds...


Register Resource: GenericCache


Register Resource: Main


1. Run: 27863 ms (63303 elements cached, 63.3%)


2. Run: 10611 ms (86580 elements cached, 86.6%)


3. Run: 3965 ms (95161 elements cached, 95.2%)


4. Run: 1428 ms (98245 elements cached, 98.2%)


5. Run: 533 ms (99340 elements cached, 99.3%)


6. Run: 207 ms (99750 elements cached, 99.8%)


7. Run: 87 ms (99898 elements cached, 99.9%)


8. Run: 42 ms (99960 elements cached, 100.0%)


9. Run: 25 ms (99986 elements cached, 100.0%)


10. Run: 20 ms (99992 elements cached, 100.0%)


11. Run: 17 ms (99999 elements cached, 100.0%)


beforeCheckpoint() called in Main


beforeCheckpoint() called in GenericCache


CR: Checkpoint ...


Killed


>java -XX:CRaCRestoreFrom=/crac-files


afterRestore() called in GenericCache


afterRestore() called in Main


12. Run: 23 ms (99999 elements cached, 100.0%)


SIMPLE EXAMPLE
>jcmd crac4.jar JDK.checkpoint


4240:


Command executed successfully


>
SHELL 1 SHELL 2
>java -XX:CRaCCheckpointTo=/crac-files -jar crac4.jar


Running on CRaC (PID 4240)


First run will take up to 30 seconds...


Register Resource: GenericCache


Register Resource: Main


1. Run: 27863 ms (63303 elements cached, 63.3%)


2. Run: 10611 ms (86580 elements cached, 86.6%)


3. Run: 3965 ms (95161 elements cached, 95.2%)


4. Run: 1428 ms (98245 elements cached, 98.2%)


5. Run: 533 ms (99340 elements cached, 99.3%)


6. Run: 207 ms (99750 elements cached, 99.8%)


7. Run: 87 ms (99898 elements cached, 99.9%)


8. Run: 42 ms (99960 elements cached, 100.0%)


9. Run: 25 ms (99986 elements cached, 100.0%)


10. Run: 20 ms (99992 elements cached, 100.0%)


11. Run: 17 ms (99999 elements cached, 100.0%)


beforeCheckpoint() called in Main


beforeCheckpoint() called in GenericCache


CR: Checkpoint ...


Killed


>java -XX:CRaCRestoreFrom=/crac-files


afterRestore() called in GenericCache


afterRestore() called in Main


12. Run: 23 ms (99999 elements cached, 100.0%)


SIMPLE EXAMPLE
>jcmd crac4.jar JDK.checkpoint


4240:


Command executed successfully


>
Continues to run...fast
SHELL 1 SHELL 2
>java -XX:CRaCCheckpointTo=/crac-files -jar crac4.jar


Running on CRaC (PID 4240)


First run will take up to 30 seconds...


Register Resource: GenericCache


Register Resource: Main


1. Run: 27863 ms (63303 elements cached, 63.3%)


2. Run: 10611 ms (86580 elements cached, 86.6%)


3. Run: 3965 ms (95161 elements cached, 95.2%)


4. Run: 1428 ms (98245 elements cached, 98.2%)


5. Run: 533 ms (99340 elements cached, 99.3%)


6. Run: 207 ms (99750 elements cached, 99.8%)


7. Run: 87 ms (99898 elements cached, 99.9%)


8. Run: 42 ms (99960 elements cached, 100.0%)


9. Run: 25 ms (99986 elements cached, 100.0%)


10. Run: 20 ms (99992 elements cached, 100.0%)


11. Run: 17 ms (99999 elements cached, 100.0%)


beforeCheckpoint() called in Main


beforeCheckpoint() called in GenericCache


CR: Checkpoint ...


Killed


>java -XX:CRaCRestoreFrom=/crac-files


afterRestore() called in GenericCache


afterRestore() called in Main


12. Run: 23 ms (99999 elements cached, 100.0%)


13. Run: 21 ms (99995 elements cached, 100.0%)
SIMPLE EXAMPLE
>jcmd crac4.jar JDK.checkpoint


4240:


Command executed successfully


>
SHELL 1 SHELL 2
>java -XX:CRaCCheckpointTo=/crac-files -jar crac4.jar


Running on CRaC (PID 4240)


First run will take up to 30 seconds...


Register Resource: GenericCache


Register Resource: Main


1. Run: 27863 ms (63303 elements cached, 63.3%)


2. Run: 10611 ms (86580 elements cached, 86.6%)


3. Run: 3965 ms (95161 elements cached, 95.2%)


4. Run: 1428 ms (98245 elements cached, 98.2%)


5. Run: 533 ms (99340 elements cached, 99.3%)


6. Run: 207 ms (99750 elements cached, 99.8%)


7. Run: 87 ms (99898 elements cached, 99.9%)


8. Run: 42 ms (99960 elements cached, 100.0%)


9. Run: 25 ms (99986 elements cached, 100.0%)


10. Run: 20 ms (99992 elements cached, 100.0%)


11. Run: 17 ms (99999 elements cached, 100.0%)


beforeCheckpoint() called in Main


beforeCheckpoint() called in GenericCache


CR: Checkpoint ...


Killed


>java -XX:CRaCRestoreFrom=/crac-files


afterRestore() called in GenericCache


afterRestore() called in Main


12. Run: 23 ms (99999 elements cached, 100.0%)


13. Run: 21 ms (99995 elements cached, 100.0%)


14. Run: 24 ms (99997 elements cached, 100.0%)
SIMPLE EXAMPLE
>jcmd crac4.jar JDK.checkpoint


4240:


Command executed successfully


>
SHELL 1 SHELL 2
FROM THE COMMAND LINE:
>jcmd YOUR_AWESOME.jar JDK.checkpoint
CREATING A CHECKPOINT
CREATING A CHECKPOINT
FROM CODE:
Core.checkpointRestore();
github.com/HanSolo/crac4
OK...BUT
HOW GOOD IS IT...?
Time to
fi
rst opera
ti
on
Spring-Boot
Micronaut
Quarkus
xml-transform
[ms]
0 1250 2500 3750 5000
4 352
980
1 001
3 898
OpenJDK
Time to
fi
rst opera
ti
on
Spring-Boot
Micronaut
Quarkus
xml-transform
[ms]
0 1250 2500 3750 5000
53
33
46
38
4 352
980
1 001
3 898
OpenJDK OpenJDK on CRaC
SUMMARY...
SUMMARY...
CRaC is a way to pause a JVM based application


And restore it at some point in the future


Bene
fi
t is potentially extremely fast time to full performance level


Eleminates the need for hotspot identi
fi
cation, method compiles,
recompiles and deoptimisations


Improved throughput from start


CRaC is an OpenJDK project


CRaC can save infrastructure cost
CPU
Utilization
0 %
25 %
50 %
75 %
100 %
Time
INFRASTRUCTURE COST
Checkpoint
JVM startup time
Interpretation +


Compilation Overhead
Start after restore
Eliminates startup time


Eliminates cpu overhead
github.com/CRaC
wiki.openjdk.org/display/crac
DEMO...
THANK
YOU

Contenu connexe

Tendances

Java Concurrency Gotchas
Java Concurrency GotchasJava Concurrency Gotchas
Java Concurrency GotchasAlex Miller
 
REST APIs with Spring
REST APIs with SpringREST APIs with Spring
REST APIs with SpringJoshua Long
 
Spring Native and Spring AOT
Spring Native and Spring AOTSpring Native and Spring AOT
Spring Native and Spring AOTVMware Tanzu
 
Batching and Java EE (jdk.io)
Batching and Java EE (jdk.io)Batching and Java EE (jdk.io)
Batching and Java EE (jdk.io)Ryan Cuprak
 
Introduction to GraalVM
Introduction to GraalVMIntroduction to GraalVM
Introduction to GraalVMSHASHI KUMAR
 
Optimizing Kubernetes Resource Requests/Limits for Cost-Efficiency and Latenc...
Optimizing Kubernetes Resource Requests/Limits for Cost-Efficiency and Latenc...Optimizing Kubernetes Resource Requests/Limits for Cost-Efficiency and Latenc...
Optimizing Kubernetes Resource Requests/Limits for Cost-Efficiency and Latenc...Henning Jacobs
 
Thread Dump Analysis
Thread Dump AnalysisThread Dump Analysis
Thread Dump AnalysisDmitry Buzdin
 
Cloud Native Java GraalVM 이상과 현실
Cloud Native Java GraalVM 이상과 현실Cloud Native Java GraalVM 이상과 현실
Cloud Native Java GraalVM 이상과 현실Taewan Kim
 
Common issues with Apache Kafka® Producer
Common issues with Apache Kafka® ProducerCommon issues with Apache Kafka® Producer
Common issues with Apache Kafka® Producerconfluent
 
From Spring Framework 5.3 to 6.0
From Spring Framework 5.3 to 6.0From Spring Framework 5.3 to 6.0
From Spring Framework 5.3 to 6.0VMware Tanzu
 
How and Why GraalVM is quickly becoming relevant for developers (ACEs@home - ...
How and Why GraalVM is quickly becoming relevant for developers (ACEs@home - ...How and Why GraalVM is quickly becoming relevant for developers (ACEs@home - ...
How and Why GraalVM is quickly becoming relevant for developers (ACEs@home - ...Lucas Jellema
 
Spring boot - an introduction
Spring boot - an introductionSpring boot - an introduction
Spring boot - an introductionJonathan Holloway
 
Graal and Truffle: One VM to Rule Them All
Graal and Truffle: One VM to Rule Them AllGraal and Truffle: One VM to Rule Them All
Graal and Truffle: One VM to Rule Them AllThomas Wuerthinger
 
JMockit Framework Overview
JMockit Framework OverviewJMockit Framework Overview
JMockit Framework OverviewMario Peshev
 
Selenium Tutorial For Beginners | Selenium Automation Testing Tutorial | Sele...
Selenium Tutorial For Beginners | Selenium Automation Testing Tutorial | Sele...Selenium Tutorial For Beginners | Selenium Automation Testing Tutorial | Sele...
Selenium Tutorial For Beginners | Selenium Automation Testing Tutorial | Sele...Simplilearn
 
Reactive Microservices with Spring 5: WebFlux
Reactive Microservices with Spring 5: WebFlux Reactive Microservices with Spring 5: WebFlux
Reactive Microservices with Spring 5: WebFlux Trayan Iliev
 

Tendances (20)

Java Concurrency Gotchas
Java Concurrency GotchasJava Concurrency Gotchas
Java Concurrency Gotchas
 
REST APIs with Spring
REST APIs with SpringREST APIs with Spring
REST APIs with Spring
 
JUnit 5
JUnit 5JUnit 5
JUnit 5
 
Java Spring Framework
Java Spring FrameworkJava Spring Framework
Java Spring Framework
 
Spring Native and Spring AOT
Spring Native and Spring AOTSpring Native and Spring AOT
Spring Native and Spring AOT
 
Batching and Java EE (jdk.io)
Batching and Java EE (jdk.io)Batching and Java EE (jdk.io)
Batching and Java EE (jdk.io)
 
Introduction to GraalVM
Introduction to GraalVMIntroduction to GraalVM
Introduction to GraalVM
 
Optimizing Kubernetes Resource Requests/Limits for Cost-Efficiency and Latenc...
Optimizing Kubernetes Resource Requests/Limits for Cost-Efficiency and Latenc...Optimizing Kubernetes Resource Requests/Limits for Cost-Efficiency and Latenc...
Optimizing Kubernetes Resource Requests/Limits for Cost-Efficiency and Latenc...
 
Thread Dump Analysis
Thread Dump AnalysisThread Dump Analysis
Thread Dump Analysis
 
Quarkus k8s
Quarkus   k8sQuarkus   k8s
Quarkus k8s
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Cloud Native Java GraalVM 이상과 현실
Cloud Native Java GraalVM 이상과 현실Cloud Native Java GraalVM 이상과 현실
Cloud Native Java GraalVM 이상과 현실
 
Common issues with Apache Kafka® Producer
Common issues with Apache Kafka® ProducerCommon issues with Apache Kafka® Producer
Common issues with Apache Kafka® Producer
 
From Spring Framework 5.3 to 6.0
From Spring Framework 5.3 to 6.0From Spring Framework 5.3 to 6.0
From Spring Framework 5.3 to 6.0
 
How and Why GraalVM is quickly becoming relevant for developers (ACEs@home - ...
How and Why GraalVM is quickly becoming relevant for developers (ACEs@home - ...How and Why GraalVM is quickly becoming relevant for developers (ACEs@home - ...
How and Why GraalVM is quickly becoming relevant for developers (ACEs@home - ...
 
Spring boot - an introduction
Spring boot - an introductionSpring boot - an introduction
Spring boot - an introduction
 
Graal and Truffle: One VM to Rule Them All
Graal and Truffle: One VM to Rule Them AllGraal and Truffle: One VM to Rule Them All
Graal and Truffle: One VM to Rule Them All
 
JMockit Framework Overview
JMockit Framework OverviewJMockit Framework Overview
JMockit Framework Overview
 
Selenium Tutorial For Beginners | Selenium Automation Testing Tutorial | Sele...
Selenium Tutorial For Beginners | Selenium Automation Testing Tutorial | Sele...Selenium Tutorial For Beginners | Selenium Automation Testing Tutorial | Sele...
Selenium Tutorial For Beginners | Selenium Automation Testing Tutorial | Sele...
 
Reactive Microservices with Spring 5: WebFlux
Reactive Microservices with Spring 5: WebFlux Reactive Microservices with Spring 5: WebFlux
Reactive Microservices with Spring 5: WebFlux
 

Similaire à What the CRaC - Superfast JVM startup

"Load Testing Distributed Systems with NBomber 4.0", Anton Moldovan
"Load Testing Distributed Systems with NBomber 4.0",  Anton Moldovan"Load Testing Distributed Systems with NBomber 4.0",  Anton Moldovan
"Load Testing Distributed Systems with NBomber 4.0", Anton MoldovanFwdays
 
Silicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM MechanicsSilicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM MechanicsAzul Systems, Inc.
 
JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?Doug Hawkins
 
100 bugs in Open Source C/C++ projects
100 bugs in Open Source C/C++ projects 100 bugs in Open Source C/C++ projects
100 bugs in Open Source C/C++ projects Andrey Karpov
 
Cassandra 2.1 boot camp, Overview
Cassandra 2.1 boot camp, OverviewCassandra 2.1 boot camp, Overview
Cassandra 2.1 boot camp, OverviewJoshua McKenzie
 
Apache Con NA 2013 - Cassandra Internals
Apache Con NA 2013 - Cassandra InternalsApache Con NA 2013 - Cassandra Internals
Apache Con NA 2013 - Cassandra Internalsaaronmorton
 
Android Boot Time Optimization
Android Boot Time OptimizationAndroid Boot Time Optimization
Android Boot Time OptimizationKan-Ru Chen
 
Code Red Security
Code Red SecurityCode Red Security
Code Red SecurityAmr Ali
 
Native Java with GraalVM
Native Java with GraalVMNative Java with GraalVM
Native Java with GraalVMSylvain Wallez
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Apache Cassandra in Bangalore - Cassandra Internals and Performance
Apache Cassandra in Bangalore - Cassandra Internals and PerformanceApache Cassandra in Bangalore - Cassandra Internals and Performance
Apache Cassandra in Bangalore - Cassandra Internals and Performanceaaronmorton
 
GroovyServ - Technical Part
GroovyServ - Technical PartGroovyServ - Technical Part
GroovyServ - Technical PartYasuharu Nakano
 
Learning spark ch10 - Spark Streaming
Learning spark ch10 - Spark StreamingLearning spark ch10 - Spark Streaming
Learning spark ch10 - Spark Streamingphanleson
 
Why async matters
Why async mattersWhy async matters
Why async matterstimbc
 
php & performance
 php & performance php & performance
php & performancesimon8410
 
002 hbase clientapi
002 hbase clientapi002 hbase clientapi
002 hbase clientapiScott Miao
 
Anton Moldovan "Load testing which you always wanted"
Anton Moldovan "Load testing which you always wanted"Anton Moldovan "Load testing which you always wanted"
Anton Moldovan "Load testing which you always wanted"Fwdays
 
Puppet Camp DC 2015: Distributed OpenSCAP Compliance Validation with MCollective
Puppet Camp DC 2015: Distributed OpenSCAP Compliance Validation with MCollectivePuppet Camp DC 2015: Distributed OpenSCAP Compliance Validation with MCollective
Puppet Camp DC 2015: Distributed OpenSCAP Compliance Validation with MCollectivePuppet
 

Similaire à What the CRaC - Superfast JVM startup (20)

"Load Testing Distributed Systems with NBomber 4.0", Anton Moldovan
"Load Testing Distributed Systems with NBomber 4.0",  Anton Moldovan"Load Testing Distributed Systems with NBomber 4.0",  Anton Moldovan
"Load Testing Distributed Systems with NBomber 4.0", Anton Moldovan
 
Silicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM MechanicsSilicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM Mechanics
 
JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?
 
100 bugs in Open Source C/C++ projects
100 bugs in Open Source C/C++ projects 100 bugs in Open Source C/C++ projects
100 bugs in Open Source C/C++ projects
 
Java On CRaC
Java On CRaCJava On CRaC
Java On CRaC
 
Cassandra 2.1 boot camp, Overview
Cassandra 2.1 boot camp, OverviewCassandra 2.1 boot camp, Overview
Cassandra 2.1 boot camp, Overview
 
Apache Con NA 2013 - Cassandra Internals
Apache Con NA 2013 - Cassandra InternalsApache Con NA 2013 - Cassandra Internals
Apache Con NA 2013 - Cassandra Internals
 
Android Boot Time Optimization
Android Boot Time OptimizationAndroid Boot Time Optimization
Android Boot Time Optimization
 
Code Red Security
Code Red SecurityCode Red Security
Code Red Security
 
Native Java with GraalVM
Native Java with GraalVMNative Java with GraalVM
Native Java with GraalVM
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Apache Cassandra in Bangalore - Cassandra Internals and Performance
Apache Cassandra in Bangalore - Cassandra Internals and PerformanceApache Cassandra in Bangalore - Cassandra Internals and Performance
Apache Cassandra in Bangalore - Cassandra Internals and Performance
 
GroovyServ - Technical Part
GroovyServ - Technical PartGroovyServ - Technical Part
GroovyServ - Technical Part
 
Learning spark ch10 - Spark Streaming
Learning spark ch10 - Spark StreamingLearning spark ch10 - Spark Streaming
Learning spark ch10 - Spark Streaming
 
Lambdas puzzler - Peter Lawrey
Lambdas puzzler - Peter LawreyLambdas puzzler - Peter Lawrey
Lambdas puzzler - Peter Lawrey
 
Why async matters
Why async mattersWhy async matters
Why async matters
 
php & performance
 php & performance php & performance
php & performance
 
002 hbase clientapi
002 hbase clientapi002 hbase clientapi
002 hbase clientapi
 
Anton Moldovan "Load testing which you always wanted"
Anton Moldovan "Load testing which you always wanted"Anton Moldovan "Load testing which you always wanted"
Anton Moldovan "Load testing which you always wanted"
 
Puppet Camp DC 2015: Distributed OpenSCAP Compliance Validation with MCollective
Puppet Camp DC 2015: Distributed OpenSCAP Compliance Validation with MCollectivePuppet Camp DC 2015: Distributed OpenSCAP Compliance Validation with MCollective
Puppet Camp DC 2015: Distributed OpenSCAP Compliance Validation with MCollective
 

Dernier

Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀DianaGray10
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...Product School
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Product School
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...Product School
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...Product School
 
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...CzechDreamin
 
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya HalderCustom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya HalderCzechDreamin
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor TurskyiFwdays
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3DianaGray10
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backElena Simperl
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Product School
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaCzechDreamin
 
Introduction to Open Source RAG and RAG Evaluation
Introduction to Open Source RAG and RAG EvaluationIntroduction to Open Source RAG and RAG Evaluation
Introduction to Open Source RAG and RAG EvaluationZilliz
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesThousandEyes
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Alison B. Lowndes
 
AI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekAI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekCzechDreamin
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...Product School
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyJohn Staveley
 
UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1DianaGray10
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualityInflectra
 

Dernier (20)

Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
 
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya HalderCustom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara Laskowska
 
Introduction to Open Source RAG and RAG Evaluation
Introduction to Open Source RAG and RAG EvaluationIntroduction to Open Source RAG and RAG Evaluation
Introduction to Open Source RAG and RAG Evaluation
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
AI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekAI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří Karpíšek
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John Staveley
 
UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 

What the CRaC - Superfast JVM startup

  • 1. What the CRaC... Coordinated Restore at Checkpoint on the Java Virtual Machine
  • 2. Gerrit Grunwald | Developer Advocate | Azul ABOUTME.
  • 10. MyClass.class BYTE CODE CLASS LOADER JVM MEMORY
  • 12. EXECUTION ENGINE Interpreter C1 JIT Compiler (client) C2 JIT Compiler (server) 􀊫 Pro fi ler 􀈒 Garbage Collector
  • 13. EXECUTION ENGINE Interpreter C1 JIT Compiler (client) C2 JIT Compiler (server)
  • 14. instruction set of CPU Detects hot spots by counting method calls JVM THRESHOLD REACHED
  • 15. Pass the hot spot methods to C1 JIT Compiler JVM C1 JIT COMPILER Compiles code as quickly as possible with low optimisation
  • 16. C1 JIT COMPILER Compiles code as quickly as possible with low optimisation Pro fi les the running code (detecting hot code) JVM THRESHOLD REACHED
  • 17. Pass the "hot" code to C2 JIT Compiler JVM C2 JIT COMPILER Compiles code with best optimisation possible (slower)
  • 19. Level 0 - Interpreted code Level 1 - C1 compiled code (no pro fi ling) Level 2 - C1 compiled code (basic pro fi ling) Level 3 - C1 compiled code (full pro fi ling, ~35% overhead) Level 4 - C2 compiled code (uses pro fi le data from previous steps) LEVELS OF EXECUTION
  • 20. Level 0 - Interpreted code Level 1 - C1 compiled code (no pro fi ling) Level 2 - C1 compiled code (basic pro fi ling) Level 3 - C1 compiled code (full pro fi ling, ~35% overhead) Level 4 - C2 compiled code (uses pro fi le data from previous steps) LEVELS OF EXECUTION PREFERRED
  • 24. EXECUTION CYCLE Fast compile, low optimisation (Execution Level 3) Finding "hotspots" Slow (Execution Level 0)
  • 25. EXECUTION CYCLE Finding "hot code" Fast compile, low optimisation (Execution Level 3) Finding "hotspots" Slow (Execution Level 0)
  • 26. EXECUTION CYCLE Slower compile, high optimisation (Execution Level 4) Finding "hot code" Fast compile, low optimisation (Execution Level 3) Finding "hotspots" Slow (Execution Level 0)
  • 27. EXECUTION CYCLE Can happen (performance hit) Slower compile, high optimisation (Execution Level 4) Finding "hot code" Fast compile, low optimisation (Execution Level 3) Finding "hotspots" Slow (Execution Level 0)
  • 29. DEOPTIMISATION if (value > 0) result = 3; result = 0; print(result); TRUE FALSE CODE
  • 30. DEOPTIMISATION if (value > 0) result = 3; result = 0; print(result); TRUE FALSE CODE Hot Path (pro fi led)
  • 31. DEOPTIMISATION if (value > 0) result = 3; result = 0; print(result); TRUE FALSE CODE guard (value > 0) result = 3; print(result); DEOPTIMISE TRUE FALSE OPTIMIZED CODE
  • 32. DEOPTIMISATION if (value > 0) result = 3; result = 0; print(result); TRUE FALSE CODE guard (value > 0) result = 3; print(result); DEOPTIMISE TRUE FALSE OPTIMIZED CODE value = 3
  • 33. DEOPTIMISATION if (value > 0) result = 3; result = 0; print(result); TRUE FALSE CODE guard (value > 0) result = 3; print(result); DEOPTIMISE TRUE FALSE OPTIMIZED CODE value = 0
  • 37. JVM PERFORMANCE GRAPH JVM STARTUP GarbageCollector pauses Deoptimisations
  • 39. MICROSERVICE ENVIRONMENT FIRST RUN JVM STARTUP SECOND RUN JVM STARTUP THIRD RUN JVM STARTUP
  • 40.
  • 41. WOULDN'T IT BE GREAT...? FIRST RUN JVM STARTUP SECOND RUN NO STARTUP OVERHEAD THIRD RUN NO STARTUP OVERHEAD
  • 44. WHAT ABOUT CDS? Class Data Sharing (App/Dynamic) Dump internal class representation into fi le Shared on each JVM start (CDS) No optimization or hotspot detection Only reduces loading time of classes Start up could be up to 1-2 seconds faster
  • 45. MyClass.class BYTE CODE CLASS LOADER JVM MEMORY CDS
  • 47. WHY NOT USE AOT? No interpreting bytecodes No analysis of hotspots No runtime compilation of code Start at full speed, straight away GraalVM native image does that PROBLEM SOLVED...?
  • 48. NOT SO FAST... AOT is, by de fi nition, static Code is compiled before it is run Compiler has no knowledge of how the code will actually run Pro fi le Guided Optimisation (PGO) can partially help
  • 49. JVM PERFORMANCE GRAPH AOT Compiled Code AOT Compiled Code with Profile Guided Optimisation Needs to run once for pro fi ling
  • 50. AOT VS JIT Limited use of method inlining No runtime bytecode generation Re fl ection is possible but complicated Unable to use speculative optimisations Overall performance will typically be lower Deployed env != Development env. Full speed from the start No overhead to compile code at runtime Small memory footprint Can use aggressive method inlining at runtime Can use runtime bytecode generation Re fl ection is simple Can use speculative optimisations Overall performance will typically be higher Deployed env. == Development env. Requires more time to start up Overhead to compile code at runtime Larger memory footprint AOT JIT
  • 51. JIT DISADVANTAGES Requires more time to start up CPU overhead to compile code at runtime Larger memory footprint
  • 52. AOT JIT Reduced Max Latency Peak Throughput Small Packaging Startup Speed Low Memory Footprint (Chart by Thomas Wuerthinger)
  • 55. Linux project Part of kernel >= 3.11 (2013) Freeze a running container/application Checkpoint its state to disk Restore the container/application from the saved data. Used by/integrated in OpenVZ, LXC/LXD, Docker, Podman and others CHECKPOINT RESTORE IN UUSERSPACE
  • 56. Mainly implemented in userspace (not kernel) Main goal is migration of containers for microservices Heavily relies on /proc fi le system It can checkpoint: Processes and threads Application memory, memory mapped fi les and shared memory Open fi les, pipes and FIFOs Sockets Interprocess communication channels Timers and signals Can rebuild TCP connection from one side without need to exchange packets CHECKPOINT RESTORE IN UUSERSPACE
  • 57. Restart from saved state on another machine (open fi les, shared memory etc.) Start multiple instances of same state on same machine (PID will be restored which will lead to problems) A Java Virtual Machine would assume it was continuing its tasks (very dif fi cult to use effectively) CRIU CHALLENGES
  • 59. CRaC CRIU comes bundled with the JDK Heap is cleaned, compacted (JVM is in a safe state) Throws CheckpointException (in case of open fi les/sockets) Comes with a simple API Creates checkpoints using code or jcmd Uses JVM safepoint mechanism (to stop threads etc.)
  • 61. RUNNING APPLICATION Aware of checkpoint being created RUNNING APPLICATION Aware of restore happening CRaC has more restrictions (e.g. no open fi les, sockets etc.) CRaC
  • 62. CRaC START >java -XX:CRaCCheckpointTo=PATH -jar app.jar RESTORE >java -XX:CRaCRestoreFrom=PATH
  • 64. <<interface>> Resource beforeCheckpoint() afterRestore() CRaC uses Resources that can be noti fi ed about a Checkpoint and Restore Classes in application code implement the Resource interface The application receives callbacks during checkpointing and restoring Makes it possible to close/restore resources (e.g. open fi les, sockets) CRaC API
  • 65. Resource objects need to be registered with a Context so that they can receive noti fi cations There is a global Context accessible via the static getGlobalContext() method of the Core class CRaC API
  • 67. CRaC API The global Context maintains a list of Resource objects The beforeCheckpoint() methods are called in the reverse order the Resource objects were added The afterRestore() methods are called in the order the Resource objects were added Checkpoint and restore can be done programmatically by using Core.checkpointRestore() Checkpoint can also be created by jcmd
  • 69. SIMPLE EXAMPLE Loop 100000x Random number 1 - 100000 isPrime(number) Cache Scheduled Thread Executed every 5 seconds
  • 70. SIMPLE EXAMPLE Loop 100000x Random number 1 - 100000 isPrime(number) Cache Scheduled Thread Executed every 5 seconds
  • 71. SIMPLE EXAMPLE Loop 100000x Random number 1 - 100000 isPrime(number) Is result for number in cache? Cache Scheduled Thread Executed every 5 seconds
  • 72. SIMPLE EXAMPLE Loop 100000x Random number 1 - 100000 isPrime(number) Is result for number in cache? Cache Scheduled Thread Executed every 5 seconds
  • 73. SIMPLE EXAMPLE Loop 100000x Random number 1 - 100000 isPrime(number) Is result for number in cache? yes Cache FAST Scheduled Thread Executed every 5 seconds
  • 74. SIMPLE EXAMPLE Loop 100000x Random number 1 - 100000 isPrime(number) Is result for number in cache? Calculate if prime no Cache Scheduled Thread Executed every 5 seconds
  • 75. SIMPLE EXAMPLE Loop 100000x Random number 1 - 100000 isPrime(number) Is result for number in cache? Calculate if prime Result no Cache Scheduled Thread Executed every 5 seconds
  • 76. SIMPLE EXAMPLE Loop 100000x Random number 1 - 100000 isPrime(number) Is result for number in cache? Calculate if prime Result no Cache Scheduled Thread Executed every 5 seconds
  • 77. SIMPLE EXAMPLE Loop 100000x Random number 1 - 100000 isPrime(number) Is result for number in cache? Calculate if prime Result no Cache SLOW Scheduled Thread Executed every 5 seconds
  • 78. SIMPLE EXAMPLE Loop 100000x Random number 1 - 100000 isPrime(number) Is result for number in cache? Calculate if prime Result no Cache Scheduled Thread Executed every 5 seconds timeout 50 sec
  • 79. SIMPLE EXAMPLE First run is slow because the cache is empty Time to check 100 000 random numbers for prime should decrease with every run
  • 80. Application Performance 0 0.2 0.4 0.6 0.8 1 Iterations 1 2 3 4 5 6 7 8 9 10 11 12 SIMPLE EXAMPLE
  • 82. >java -XX:CRaCCheckpointTo=/crac-files -jar crac4.jar > SIMPLE EXAMPLE SHELL 1 SHELL 2
  • 83. >java -XX:CRaCCheckpointTo=/crac-files -jar crac4.jar > De fi nes where to store fi les for the checkpoint SIMPLE EXAMPLE SHELL 1 SHELL 2
  • 84. >java -XX:CRaCCheckpointTo=/crac-files -jar crac4.jar Running on CRaC (PID 4240) First run will take up to 30 seconds... Register Resource: GenericCache Register Resource: Main 1. Run: 27863 ms (63303 elements cached, 63.3%) > SIMPLE EXAMPLE SHELL 1 SHELL 2
  • 85. >java -XX:CRaCCheckpointTo=/crac-files -jar crac4.jar Running on CRaC (PID 4240) First run will take up to 30 seconds... Register Resource: GenericCache Register Resource: Main 1. Run: 27863 ms (63303 elements cached, 63.3%) > SIMPLE EXAMPLE SHELL 1 SHELL 2
  • 86. >java -XX:CRaCCheckpointTo=/crac-files -jar crac4.jar Running on CRaC (PID 4240) First run will take up to 30 seconds... Register Resource: GenericCache Register Resource: Main 1. Run: 27863 ms (63303 elements cached, 63.3%) > SIMPLE EXAMPLE SHELL 1 SHELL 2
  • 87. >java -XX:CRaCCheckpointTo=/crac-files -jar crac4.jar Running on CRaC (PID 4240) First run will take up to 30 seconds... Register Resource: GenericCache Register Resource: Main 1. Run: 27863 ms (63303 elements cached, 63.3%) > SIMPLE EXAMPLE Slow because cache is not fi lled yet SHELL 1 SHELL 2
  • 88. >java -XX:CRaCCheckpointTo=/crac-files -jar crac4.jar Running on CRaC (PID 4240) First run will take up to 30 seconds... Register Resource: GenericCache Register Resource: Main 1. Run: 27863 ms (63303 elements cached, 63.3%) 2. Run: 10611 ms (86580 elements cached, 86.6%) > SIMPLE EXAMPLE SHELL 1 SHELL 2
  • 89. >java -XX:CRaCCheckpointTo=/crac-files -jar crac4.jar Running on CRaC (PID 4240) First run will take up to 30 seconds... Register Resource: GenericCache Register Resource: Main 1. Run: 27863 ms (63303 elements cached, 63.3%) 2. Run: 10611 ms (86580 elements cached, 86.6%) 3. Run: 3965 ms (95161 elements cached, 95.2%) > SIMPLE EXAMPLE SHELL 1 SHELL 2
  • 90. >java -XX:CRaCCheckpointTo=/crac-files -jar crac4.jar Running on CRaC (PID 4240) First run will take up to 30 seconds... Register Resource: GenericCache Register Resource: Main 1. Run: 27863 ms (63303 elements cached, 63.3%) 2. Run: 10611 ms (86580 elements cached, 86.6%) 3. Run: 3965 ms (95161 elements cached, 95.2%) 4. Run: 1428 ms (98245 elements cached, 98.2%) > SIMPLE EXAMPLE SHELL 1 SHELL 2
  • 91. >java -XX:CRaCCheckpointTo=/crac-files -jar crac4.jar Running on CRaC (PID 4240) First run will take up to 30 seconds... Register Resource: GenericCache Register Resource: Main 1. Run: 27863 ms (63303 elements cached, 63.3%) 2. Run: 10611 ms (86580 elements cached, 86.6%) 3. Run: 3965 ms (95161 elements cached, 95.2%) 4. Run: 1428 ms (98245 elements cached, 98.2%) 5. Run: 533 ms (99340 elements cached, 99.3%) > SIMPLE EXAMPLE SHELL 1 SHELL 2
  • 92. >java -XX:CRaCCheckpointTo=/crac-files -jar crac4.jar Running on CRaC (PID 4240) First run will take up to 30 seconds... Register Resource: GenericCache Register Resource: Main 1. Run: 27863 ms (63303 elements cached, 63.3%) 2. Run: 10611 ms (86580 elements cached, 86.6%) 3. Run: 3965 ms (95161 elements cached, 95.2%) 4. Run: 1428 ms (98245 elements cached, 98.2%) 5. Run: 533 ms (99340 elements cached, 99.3%) 6. Run: 207 ms (99750 elements cached, 99.8%) > SIMPLE EXAMPLE SHELL 1 SHELL 2
  • 93. >java -XX:CRaCCheckpointTo=/crac-files -jar crac4.jar Running on CRaC (PID 4240) First run will take up to 30 seconds... Register Resource: GenericCache Register Resource: Main 1. Run: 27863 ms (63303 elements cached, 63.3%) 2. Run: 10611 ms (86580 elements cached, 86.6%) 3. Run: 3965 ms (95161 elements cached, 95.2%) 4. Run: 1428 ms (98245 elements cached, 98.2%) 5. Run: 533 ms (99340 elements cached, 99.3%) 6. Run: 207 ms (99750 elements cached, 99.8%) 7. Run: 87 ms (99898 elements cached, 99.9%) > SIMPLE EXAMPLE SHELL 1 SHELL 2
  • 94. >java -XX:CRaCCheckpointTo=/crac-files -jar crac4.jar Running on CRaC (PID 4240) First run will take up to 30 seconds... Register Resource: GenericCache Register Resource: Main 1. Run: 27863 ms (63303 elements cached, 63.3%) 2. Run: 10611 ms (86580 elements cached, 86.6%) 3. Run: 3965 ms (95161 elements cached, 95.2%) 4. Run: 1428 ms (98245 elements cached, 98.2%) 5. Run: 533 ms (99340 elements cached, 99.3%) 6. Run: 207 ms (99750 elements cached, 99.8%) 7. Run: 87 ms (99898 elements cached, 99.9%) 8. Run: 42 ms (99960 elements cached, 100.0%) > SIMPLE EXAMPLE SHELL 1 SHELL 2
  • 95. >java -XX:CRaCCheckpointTo=/crac-files -jar crac4.jar Running on CRaC (PID 4240) First run will take up to 30 seconds... Register Resource: GenericCache Register Resource: Main 1. Run: 27863 ms (63303 elements cached, 63.3%) 2. Run: 10611 ms (86580 elements cached, 86.6%) 3. Run: 3965 ms (95161 elements cached, 95.2%) 4. Run: 1428 ms (98245 elements cached, 98.2%) 5. Run: 533 ms (99340 elements cached, 99.3%) 6. Run: 207 ms (99750 elements cached, 99.8%) 7. Run: 87 ms (99898 elements cached, 99.9%) 8. Run: 42 ms (99960 elements cached, 100.0%) 9. Run: 25 ms (99986 elements cached, 100.0%) > SIMPLE EXAMPLE SHELL 1 SHELL 2
  • 96. >java -XX:CRaCCheckpointTo=/crac-files -jar crac4.jar Running on CRaC (PID 4240) First run will take up to 30 seconds... Register Resource: GenericCache Register Resource: Main 1. Run: 27863 ms (63303 elements cached, 63.3%) 2. Run: 10611 ms (86580 elements cached, 86.6%) 3. Run: 3965 ms (95161 elements cached, 95.2%) 4. Run: 1428 ms (98245 elements cached, 98.2%) 5. Run: 533 ms (99340 elements cached, 99.3%) 6. Run: 207 ms (99750 elements cached, 99.8%) 7. Run: 87 ms (99898 elements cached, 99.9%) 8. Run: 42 ms (99960 elements cached, 100.0%) 9. Run: 25 ms (99986 elements cached, 100.0%) 10. Run: 20 ms (99992 elements cached, 100.0%) > SIMPLE EXAMPLE SHELL 1 SHELL 2
  • 97. >java -XX:CRaCCheckpointTo=/crac-files -jar crac4.jar Running on CRaC (PID 4240) First run will take up to 30 seconds... Register Resource: GenericCache Register Resource: Main 1. Run: 27863 ms (63303 elements cached, 63.3%) 2. Run: 10611 ms (86580 elements cached, 86.6%) 3. Run: 3965 ms (95161 elements cached, 95.2%) 4. Run: 1428 ms (98245 elements cached, 98.2%) 5. Run: 533 ms (99340 elements cached, 99.3%) 6. Run: 207 ms (99750 elements cached, 99.8%) 7. Run: 87 ms (99898 elements cached, 99.9%) 8. Run: 42 ms (99960 elements cached, 100.0%) 9. Run: 25 ms (99986 elements cached, 100.0%) 10. Run: 20 ms (99992 elements cached, 100.0%) 11. Run: 17 ms (99999 elements cached, 100.0%) > SIMPLE EXAMPLE SHELL 1 SHELL 2
  • 98. >java -XX:CRaCCheckpointTo=/crac-files -jar crac4.jar Running on CRaC (PID 4240) First run will take up to 30 seconds... Register Resource: GenericCache Register Resource: Main 1. Run: 27863 ms (63303 elements cached, 63.3%) 2. Run: 10611 ms (86580 elements cached, 86.6%) 3. Run: 3965 ms (95161 elements cached, 95.2%) 4. Run: 1428 ms (98245 elements cached, 98.2%) 5. Run: 533 ms (99340 elements cached, 99.3%) 6. Run: 207 ms (99750 elements cached, 99.8%) 7. Run: 87 ms (99898 elements cached, 99.9%) 8. Run: 42 ms (99960 elements cached, 100.0%) 9. Run: 25 ms (99986 elements cached, 100.0%) 10. Run: 20 ms (99992 elements cached, 100.0%) 11. Run: 17 ms (99999 elements cached, 100.0%) > SIMPLE EXAMPLE Fast because cache is fi lled SHELL 1 SHELL 2
  • 99. >java -XX:CRaCCheckpointTo=/crac-files -jar crac4.jar Running on CRaC (PID 4240) First run will take up to 30 seconds... Register Resource: GenericCache Register Resource: Main 1. Run: 27863 ms (63303 elements cached, 63.3%) 2. Run: 10611 ms (86580 elements cached, 86.6%) 3. Run: 3965 ms (95161 elements cached, 95.2%) 4. Run: 1428 ms (98245 elements cached, 98.2%) 5. Run: 533 ms (99340 elements cached, 99.3%) 6. Run: 207 ms (99750 elements cached, 99.8%) 7. Run: 87 ms (99898 elements cached, 99.9%) 8. Run: 42 ms (99960 elements cached, 100.0%) 9. Run: 25 ms (99986 elements cached, 100.0%) 10. Run: 20 ms (99992 elements cached, 100.0%) 11. Run: 17 ms (99999 elements cached, 100.0%) SIMPLE EXAMPLE >jcmd crac4.jar JDK.checkpoint SHELL 1 SHELL 2
  • 100. >java -XX:CRaCCheckpointTo=/crac-files -jar crac4.jar Running on CRaC (PID 4240) First run will take up to 30 seconds... Register Resource: GenericCache Register Resource: Main 1. Run: 27863 ms (63303 elements cached, 63.3%) 2. Run: 10611 ms (86580 elements cached, 86.6%) 3. Run: 3965 ms (95161 elements cached, 95.2%) 4. Run: 1428 ms (98245 elements cached, 98.2%) 5. Run: 533 ms (99340 elements cached, 99.3%) 6. Run: 207 ms (99750 elements cached, 99.8%) 7. Run: 87 ms (99898 elements cached, 99.9%) 8. Run: 42 ms (99960 elements cached, 100.0%) 9. Run: 25 ms (99986 elements cached, 100.0%) 10. Run: 20 ms (99992 elements cached, 100.0%) 11. Run: 17 ms (99999 elements cached, 100.0%) SIMPLE EXAMPLE >jcmd crac4.jar JDK.checkpoint CREATE CHECKPOINT SHELL 1 SHELL 2
  • 101. >java -XX:CRaCCheckpointTo=/crac-files -jar crac4.jar Running on CRaC (PID 4240) First run will take up to 30 seconds... Register Resource: GenericCache Register Resource: Main 1. Run: 27863 ms (63303 elements cached, 63.3%) 2. Run: 10611 ms (86580 elements cached, 86.6%) 3. Run: 3965 ms (95161 elements cached, 95.2%) 4. Run: 1428 ms (98245 elements cached, 98.2%) 5. Run: 533 ms (99340 elements cached, 99.3%) 6. Run: 207 ms (99750 elements cached, 99.8%) 7. Run: 87 ms (99898 elements cached, 99.9%) 8. Run: 42 ms (99960 elements cached, 100.0%) 9. Run: 25 ms (99986 elements cached, 100.0%) 10. Run: 20 ms (99992 elements cached, 100.0%) 11. Run: 17 ms (99999 elements cached, 100.0%) beforeCheckpoint() called in Main beforeCheckpoint() called in GenericCache CR: Checkpoint ... Killed > SIMPLE EXAMPLE >jcmd crac4.jar JDK.checkpoint 4240: Command executed successfully > SHELL 1 SHELL 2
  • 102. >java -XX:CRaCCheckpointTo=/crac-files -jar crac4.jar Running on CRaC (PID 4240) First run will take up to 30 seconds... Register Resource: GenericCache Register Resource: Main 1. Run: 27863 ms (63303 elements cached, 63.3%) 2. Run: 10611 ms (86580 elements cached, 86.6%) 3. Run: 3965 ms (95161 elements cached, 95.2%) 4. Run: 1428 ms (98245 elements cached, 98.2%) 5. Run: 533 ms (99340 elements cached, 99.3%) 6. Run: 207 ms (99750 elements cached, 99.8%) 7. Run: 87 ms (99898 elements cached, 99.9%) 8. Run: 42 ms (99960 elements cached, 100.0%) 9. Run: 25 ms (99986 elements cached, 100.0%) 10. Run: 20 ms (99992 elements cached, 100.0%) 11. Run: 17 ms (99999 elements cached, 100.0%) beforeCheckpoint() called in Main beforeCheckpoint() called in GenericCache CR: Checkpoint ... Killed > SIMPLE EXAMPLE >jcmd crac4.jar JDK.checkpoint 4240: Command executed successfully > SHELL 1 SHELL 2
  • 103. >java -XX:CRaCCheckpointTo=/crac-files -jar crac4.jar Running on CRaC (PID 4240) First run will take up to 30 seconds... Register Resource: GenericCache Register Resource: Main 1. Run: 27863 ms (63303 elements cached, 63.3%) 2. Run: 10611 ms (86580 elements cached, 86.6%) 3. Run: 3965 ms (95161 elements cached, 95.2%) 4. Run: 1428 ms (98245 elements cached, 98.2%) 5. Run: 533 ms (99340 elements cached, 99.3%) 6. Run: 207 ms (99750 elements cached, 99.8%) 7. Run: 87 ms (99898 elements cached, 99.9%) 8. Run: 42 ms (99960 elements cached, 100.0%) 9. Run: 25 ms (99986 elements cached, 100.0%) 10. Run: 20 ms (99992 elements cached, 100.0%) 11. Run: 17 ms (99999 elements cached, 100.0%) beforeCheckpoint() called in Main beforeCheckpoint() called in GenericCache CR: Checkpoint ... Killed >java -XX:CRaCRestoreFrom=/crac-files SIMPLE EXAMPLE >jcmd crac4.jar JDK.checkpoint 4240: Command executed successfully > SHELL 1 SHELL 2
  • 104. >java -XX:CRaCCheckpointTo=/crac-files -jar crac4.jar Running on CRaC (PID 4240) First run will take up to 30 seconds... Register Resource: GenericCache Register Resource: Main 1. Run: 27863 ms (63303 elements cached, 63.3%) 2. Run: 10611 ms (86580 elements cached, 86.6%) 3. Run: 3965 ms (95161 elements cached, 95.2%) 4. Run: 1428 ms (98245 elements cached, 98.2%) 5. Run: 533 ms (99340 elements cached, 99.3%) 6. Run: 207 ms (99750 elements cached, 99.8%) 7. Run: 87 ms (99898 elements cached, 99.9%) 8. Run: 42 ms (99960 elements cached, 100.0%) 9. Run: 25 ms (99986 elements cached, 100.0%) 10. Run: 20 ms (99992 elements cached, 100.0%) 11. Run: 17 ms (99999 elements cached, 100.0%) beforeCheckpoint() called in Main beforeCheckpoint() called in GenericCache CR: Checkpoint ... Killed >java -XX:CRaCRestoreFrom=/crac-files SIMPLE EXAMPLE >jcmd crac4.jar JDK.checkpoint 4240: Command executed successfully > RESTORE SHELL 1 SHELL 2
  • 105. >java -XX:CRaCCheckpointTo=/crac-files -jar crac4.jar Running on CRaC (PID 4240) First run will take up to 30 seconds... Register Resource: GenericCache Register Resource: Main 1. Run: 27863 ms (63303 elements cached, 63.3%) 2. Run: 10611 ms (86580 elements cached, 86.6%) 3. Run: 3965 ms (95161 elements cached, 95.2%) 4. Run: 1428 ms (98245 elements cached, 98.2%) 5. Run: 533 ms (99340 elements cached, 99.3%) 6. Run: 207 ms (99750 elements cached, 99.8%) 7. Run: 87 ms (99898 elements cached, 99.9%) 8. Run: 42 ms (99960 elements cached, 100.0%) 9. Run: 25 ms (99986 elements cached, 100.0%) 10. Run: 20 ms (99992 elements cached, 100.0%) 11. Run: 17 ms (99999 elements cached, 100.0%) beforeCheckpoint() called in Main beforeCheckpoint() called in GenericCache CR: Checkpoint ... Killed >java -XX:CRaCRestoreFrom=/crac-files afterRestore() called in GenericCache afterRestore() called in Main 12. Run: 23 ms (99999 elements cached, 100.0%) SIMPLE EXAMPLE >jcmd crac4.jar JDK.checkpoint 4240: Command executed successfully > SHELL 1 SHELL 2
  • 106. >java -XX:CRaCCheckpointTo=/crac-files -jar crac4.jar Running on CRaC (PID 4240) First run will take up to 30 seconds... Register Resource: GenericCache Register Resource: Main 1. Run: 27863 ms (63303 elements cached, 63.3%) 2. Run: 10611 ms (86580 elements cached, 86.6%) 3. Run: 3965 ms (95161 elements cached, 95.2%) 4. Run: 1428 ms (98245 elements cached, 98.2%) 5. Run: 533 ms (99340 elements cached, 99.3%) 6. Run: 207 ms (99750 elements cached, 99.8%) 7. Run: 87 ms (99898 elements cached, 99.9%) 8. Run: 42 ms (99960 elements cached, 100.0%) 9. Run: 25 ms (99986 elements cached, 100.0%) 10. Run: 20 ms (99992 elements cached, 100.0%) 11. Run: 17 ms (99999 elements cached, 100.0%) beforeCheckpoint() called in Main beforeCheckpoint() called in GenericCache CR: Checkpoint ... Killed >java -XX:CRaCRestoreFrom=/crac-files afterRestore() called in GenericCache afterRestore() called in Main 12. Run: 23 ms (99999 elements cached, 100.0%) SIMPLE EXAMPLE >jcmd crac4.jar JDK.checkpoint 4240: Command executed successfully > Continues to run...fast SHELL 1 SHELL 2
  • 107. >java -XX:CRaCCheckpointTo=/crac-files -jar crac4.jar Running on CRaC (PID 4240) First run will take up to 30 seconds... Register Resource: GenericCache Register Resource: Main 1. Run: 27863 ms (63303 elements cached, 63.3%) 2. Run: 10611 ms (86580 elements cached, 86.6%) 3. Run: 3965 ms (95161 elements cached, 95.2%) 4. Run: 1428 ms (98245 elements cached, 98.2%) 5. Run: 533 ms (99340 elements cached, 99.3%) 6. Run: 207 ms (99750 elements cached, 99.8%) 7. Run: 87 ms (99898 elements cached, 99.9%) 8. Run: 42 ms (99960 elements cached, 100.0%) 9. Run: 25 ms (99986 elements cached, 100.0%) 10. Run: 20 ms (99992 elements cached, 100.0%) 11. Run: 17 ms (99999 elements cached, 100.0%) beforeCheckpoint() called in Main beforeCheckpoint() called in GenericCache CR: Checkpoint ... Killed >java -XX:CRaCRestoreFrom=/crac-files afterRestore() called in GenericCache afterRestore() called in Main 12. Run: 23 ms (99999 elements cached, 100.0%) 13. Run: 21 ms (99995 elements cached, 100.0%) SIMPLE EXAMPLE >jcmd crac4.jar JDK.checkpoint 4240: Command executed successfully > SHELL 1 SHELL 2
  • 108. >java -XX:CRaCCheckpointTo=/crac-files -jar crac4.jar Running on CRaC (PID 4240) First run will take up to 30 seconds... Register Resource: GenericCache Register Resource: Main 1. Run: 27863 ms (63303 elements cached, 63.3%) 2. Run: 10611 ms (86580 elements cached, 86.6%) 3. Run: 3965 ms (95161 elements cached, 95.2%) 4. Run: 1428 ms (98245 elements cached, 98.2%) 5. Run: 533 ms (99340 elements cached, 99.3%) 6. Run: 207 ms (99750 elements cached, 99.8%) 7. Run: 87 ms (99898 elements cached, 99.9%) 8. Run: 42 ms (99960 elements cached, 100.0%) 9. Run: 25 ms (99986 elements cached, 100.0%) 10. Run: 20 ms (99992 elements cached, 100.0%) 11. Run: 17 ms (99999 elements cached, 100.0%) beforeCheckpoint() called in Main beforeCheckpoint() called in GenericCache CR: Checkpoint ... Killed >java -XX:CRaCRestoreFrom=/crac-files afterRestore() called in GenericCache afterRestore() called in Main 12. Run: 23 ms (99999 elements cached, 100.0%) 13. Run: 21 ms (99995 elements cached, 100.0%) 14. Run: 24 ms (99997 elements cached, 100.0%) SIMPLE EXAMPLE >jcmd crac4.jar JDK.checkpoint 4240: Command executed successfully > SHELL 1 SHELL 2
  • 109. FROM THE COMMAND LINE: >jcmd YOUR_AWESOME.jar JDK.checkpoint CREATING A CHECKPOINT
  • 110. CREATING A CHECKPOINT FROM CODE: Core.checkpointRestore();
  • 113. Time to fi rst opera ti on Spring-Boot Micronaut Quarkus xml-transform [ms] 0 1250 2500 3750 5000 4 352 980 1 001 3 898 OpenJDK
  • 114. Time to fi rst opera ti on Spring-Boot Micronaut Quarkus xml-transform [ms] 0 1250 2500 3750 5000 53 33 46 38 4 352 980 1 001 3 898 OpenJDK OpenJDK on CRaC
  • 116. SUMMARY... CRaC is a way to pause a JVM based application And restore it at some point in the future Bene fi t is potentially extremely fast time to full performance level Eleminates the need for hotspot identi fi cation, method compiles, recompiles and deoptimisations Improved throughput from start CRaC is an OpenJDK project CRaC can save infrastructure cost
  • 117. CPU Utilization 0 % 25 % 50 % 75 % 100 % Time INFRASTRUCTURE COST Checkpoint JVM startup time Interpretation + Compilation Overhead Start after restore Eliminates startup time Eliminates cpu overhead