SlideShare a Scribd company logo
1 of 121
Download to read offline
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

More Related Content

What's hot

Scala警察のすすめ
Scala警察のすすめScala警察のすすめ
Scala警察のすすめtakezoe
 
Combining logs, metrics, and traces for unified observability
Combining logs, metrics, and traces for unified observabilityCombining logs, metrics, and traces for unified observability
Combining logs, metrics, and traces for unified observabilityElasticsearch
 
Monitoring with Prometheus
Monitoring with PrometheusMonitoring with Prometheus
Monitoring with PrometheusShiao-An Yuan
 
Sum and Product Types - The Fruit Salad & Fruit Snack Example - From F# to Ha...
Sum and Product Types -The Fruit Salad & Fruit Snack Example - From F# to Ha...Sum and Product Types -The Fruit Salad & Fruit Snack Example - From F# to Ha...
Sum and Product Types - The Fruit Salad & Fruit Snack Example - From F# to Ha...Philip Schwarz
 
Discover Quarkus and GraalVM
Discover Quarkus and GraalVMDiscover Quarkus and GraalVM
Discover Quarkus and GraalVMRomain Schlick
 
Spring Bootハンズオン ~Spring Bootで作る マイクロサービスアーキテクチャ! #jjug_ccc #ccc_r53
Spring Bootハンズオン ~Spring Bootで作る マイクロサービスアーキテクチャ! #jjug_ccc #ccc_r53Spring Bootハンズオン ~Spring Bootで作る マイクロサービスアーキテクチャ! #jjug_ccc #ccc_r53
Spring Bootハンズオン ~Spring Bootで作る マイクロサービスアーキテクチャ! #jjug_ccc #ccc_r53Toshiaki Maki
 
Reactive programming with examples
Reactive programming with examplesReactive programming with examples
Reactive programming with examplesPeter Lawrey
 
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...Domenic Denicola
 
Apache Kafka – (Pattern and) Anti-Pattern
Apache Kafka – (Pattern and) Anti-PatternApache Kafka – (Pattern and) Anti-Pattern
Apache Kafka – (Pattern and) Anti-Patternconfluent
 
ksqlDB - Stream Processing simplified!
ksqlDB - Stream Processing simplified!ksqlDB - Stream Processing simplified!
ksqlDB - Stream Processing simplified!Guido Schmutz
 
Java EE 8新機能解説 -Bean Validation 2.0編-
Java EE 8新機能解説 -Bean Validation 2.0編-Java EE 8新機能解説 -Bean Validation 2.0編-
Java EE 8新機能解説 -Bean Validation 2.0編-Masatoshi Tada
 
Native Java with GraalVM
Native Java with GraalVMNative Java with GraalVM
Native Java with GraalVMSylvain Wallez
 
Digdagによる大規模データ処理の自動化とエラー処理
Digdagによる大規模データ処理の自動化とエラー処理Digdagによる大規模データ処理の自動化とエラー処理
Digdagによる大規模データ処理の自動化とエラー処理Sadayuki Furuhashi
 
Javaのログ出力: 道具と考え方
Javaのログ出力: 道具と考え方Javaのログ出力: 道具と考え方
Javaのログ出力: 道具と考え方Taku Miyakawa
 
Microservices with event source and CQRS
Microservices with event source and CQRSMicroservices with event source and CQRS
Microservices with event source and CQRSMd Ayub Ali Sarker
 
MongoDBが遅いときの切り分け方法
MongoDBが遅いときの切り分け方法MongoDBが遅いときの切り分け方法
MongoDBが遅いときの切り分け方法Tetsutaro Watanabe
 

What's hot (20)

Scala警察のすすめ
Scala警察のすすめScala警察のすすめ
Scala警察のすすめ
 
Combining logs, metrics, and traces for unified observability
Combining logs, metrics, and traces for unified observabilityCombining logs, metrics, and traces for unified observability
Combining logs, metrics, and traces for unified observability
 
Monitoring with Prometheus
Monitoring with PrometheusMonitoring with Prometheus
Monitoring with Prometheus
 
Metaspace
MetaspaceMetaspace
Metaspace
 
Sum and Product Types - The Fruit Salad & Fruit Snack Example - From F# to Ha...
Sum and Product Types -The Fruit Salad & Fruit Snack Example - From F# to Ha...Sum and Product Types -The Fruit Salad & Fruit Snack Example - From F# to Ha...
Sum and Product Types - The Fruit Salad & Fruit Snack Example - From F# to Ha...
 
Discover Quarkus and GraalVM
Discover Quarkus and GraalVMDiscover Quarkus and GraalVM
Discover Quarkus and GraalVM
 
Spring Bootハンズオン ~Spring Bootで作る マイクロサービスアーキテクチャ! #jjug_ccc #ccc_r53
Spring Bootハンズオン ~Spring Bootで作る マイクロサービスアーキテクチャ! #jjug_ccc #ccc_r53Spring Bootハンズオン ~Spring Bootで作る マイクロサービスアーキテクチャ! #jjug_ccc #ccc_r53
Spring Bootハンズオン ~Spring Bootで作る マイクロサービスアーキテクチャ! #jjug_ccc #ccc_r53
 
Reactive programming with examples
Reactive programming with examplesReactive programming with examples
Reactive programming with examples
 
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
 
Apache Kafka – (Pattern and) Anti-Pattern
Apache Kafka – (Pattern and) Anti-PatternApache Kafka – (Pattern and) Anti-Pattern
Apache Kafka – (Pattern and) Anti-Pattern
 
Docker Kubernetes Istio
Docker Kubernetes IstioDocker Kubernetes Istio
Docker Kubernetes Istio
 
ksqlDB - Stream Processing simplified!
ksqlDB - Stream Processing simplified!ksqlDB - Stream Processing simplified!
ksqlDB - Stream Processing simplified!
 
Java EE 8新機能解説 -Bean Validation 2.0編-
Java EE 8新機能解説 -Bean Validation 2.0編-Java EE 8新機能解説 -Bean Validation 2.0編-
Java EE 8新機能解説 -Bean Validation 2.0編-
 
Native Java with GraalVM
Native Java with GraalVMNative Java with GraalVM
Native Java with GraalVM
 
Springboot Microservices
Springboot MicroservicesSpringboot Microservices
Springboot Microservices
 
Airflow 101
Airflow 101Airflow 101
Airflow 101
 
Digdagによる大規模データ処理の自動化とエラー処理
Digdagによる大規模データ処理の自動化とエラー処理Digdagによる大規模データ処理の自動化とエラー処理
Digdagによる大規模データ処理の自動化とエラー処理
 
Javaのログ出力: 道具と考え方
Javaのログ出力: 道具と考え方Javaのログ出力: 道具と考え方
Javaのログ出力: 道具と考え方
 
Microservices with event source and CQRS
Microservices with event source and CQRSMicroservices with event source and CQRS
Microservices with event source and CQRS
 
MongoDBが遅いときの切り分け方法
MongoDBが遅いときの切り分け方法MongoDBが遅いときの切り分け方法
MongoDBが遅いときの切り分け方法
 

Similar to CRaC JVM Checkpoint Restore

"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
 
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
 
Copper: A high performance workflow engine
Copper: A high performance workflow engineCopper: A high performance workflow engine
Copper: A high performance workflow enginedmoebius
 
NET Systems Programming Learned the Hard Way.pptx
NET Systems Programming Learned the Hard Way.pptxNET Systems Programming Learned the Hard Way.pptx
NET Systems Programming Learned the Hard Way.pptxpetabridge
 

Similar to CRaC JVM Checkpoint Restore (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
 
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
 
Copper: A high performance workflow engine
Copper: A high performance workflow engineCopper: A high performance workflow engine
Copper: A high performance workflow engine
 
NET Systems Programming Learned the Hard Way.pptx
NET Systems Programming Learned the Hard Way.pptxNET Systems Programming Learned the Hard Way.pptx
NET Systems Programming Learned the Hard Way.pptx
 

Recently uploaded

Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Hyundai Motor Group
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 

Recently uploaded (20)

Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 

CRaC JVM Checkpoint Restore

  • 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