Skip to content

Commit 3290260

Browse files
committed
Polishing
1 parent fff5065 commit 3290260

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
11
[[checkpoint-restore]]
22
= JVM Checkpoint Restore
33

4-
The Spring Framework integrates with checkpoint/restore as implemented by https://github.com/CRaC/docs[Project CRaC] in order to allow implementing systems capable to reduce the startup and warmup times of Spring-based Java applications with the JVM.
4+
The Spring Framework integrates with checkpoint/restore as implemented by https://github.com/CRaC/docs[Project CRaC] in order to allow implementing systems capable of reducing the startup and warmup times of Spring-based Java applications with the JVM.
55

66
Using this feature requires:
77

88
* A checkpoint/restore enabled JVM (Linux only for now).
9-
* The presence in the classpath of the https://github.com/CRaC/org.crac[`org.crac:crac`] library (version `1.4.0` and above are supported).
10-
* Specifying the required `java` command line parameters like `-XX:CRaCCheckpointTo=PATH` or `-XX:CRaCRestoreFrom=PATH`.
9+
* The presence of the https://github.com/CRaC/org.crac[`org.crac:crac`] library (version `1.4.0` and above are supported) in the classpath.
10+
* Specifying the required `java` command-line parameters like `-XX:CRaCCheckpointTo=PATH` or `-XX:CRaCRestoreFrom=PATH`.
1111

12-
WARNING: The files generated in the path specified by `-XX:CRaCCheckpointTo=PATH` when a checkpoint is requested contain a representation of the memory of the running JVM, which may contain secrets and other sensitive data. Using this feature should be done with the assumption that any value "seen" by the JVM, such as configuration properties coming from the environment, will be stored in those CRaC files. As a consequence, the security implications of where and how those files are generated, stored and accessed should be carefully assessed.
12+
WARNING: The files generated in the path specified by `-XX:CRaCCheckpointTo=PATH` when a checkpoint is requested contain a representation of the memory of the running JVM, which may contain secrets and other sensitive data. Using this feature should be done with the assumption that any value "seen" by the JVM, such as configuration properties coming from the environment, will be stored in those CRaC files. As a consequence, the security implications of where and how those files are generated, stored, and accessed should be carefully assessed.
1313

14-
Conceptually, checkpoint and restore match with xref:core/beans/factory-nature.adoc#beans-factory-lifecycle-processor[Spring `Lifecycle` contract] for individual beans.
14+
Conceptually, checkpoint and restore align with the xref:core/beans/factory-nature.adoc#beans-factory-lifecycle-processor[Spring `Lifecycle` contract] for individual beans.
1515

16-
== On demand checkpoint/restore of a running application
16+
== On-demand checkpoint/restore of a running application
1717

1818
A checkpoint can be created on demand, for example using a command like `jcmd application.jar JDK.checkpoint`. Before the creation of the checkpoint, Spring Framework
19-
stops all the running beans, giving them a chance to close resources if needed by implementing `Lifecycle.stop`. After restore, the same beans are restarted, with `Lifecycle.start` allowing to reopen resources when relevant. For libraries not depending on Spring, checkpoint/restore custom integration can be provided by implementing `org.crac.Resource` and registering the related instance.
19+
stops all the running beans, giving them a chance to close resources if needed by implementing `Lifecycle.stop`. After restore, the same beans are restarted, with `Lifecycle.start` allowing beans to reopen resources when relevant. For libraries that do not depend on Spring, custom checkpoint/restore integration can be provided by implementing `org.crac.Resource` and registering the related instance.
2020

2121
WARNING: Leveraging checkpoint/restore of a running application typically requires additional lifecycle management to gracefully stop and start using resources like files or sockets and stop active threads.
2222

2323
NOTE: If the checkpoint is created on a warmed-up JVM, the restored JVM will be equally warmed-up, allowing potentially peak performance immediately. This method typically requires access to remote services, and thus requires some level of platform integration.
2424

2525
== Automatic checkpoint/restore at startup
2626

27-
When the `-Dspring.context.checkpoint=onRefresh` Java system property is set, a checkpoint is created automatically during
28-
the startup at `LifecycleProcessor.onRefresh` level. At this phase, all non-lazy initialized singletons are instantiated,
29-
`InitializingBean#afterPropertiesSet` callbacks have been invoked, but the lifecycle has not started and
27+
When the `-Dspring.context.checkpoint=onRefresh` JVM system property is set, a checkpoint is created automatically at
28+
startup during the `LifecycleProcessor.onRefresh` phase. After this phase has completed, all non-lazy initialized singletons have been instantiated, and
29+
`InitializingBean#afterPropertiesSet` callbacks have been invoked; but the lifecycle has not started, and the
3030
`ContextRefreshedEvent` has not yet been published.
3131

3232
WARNING: As mentioned above, and especially in use cases where the CRaC files are shipped as part of a deployable artifact (a container image for example), operate with the assumption that any sensitive data "seen" by the JVM ends up in the CRaC files, and assess carefully the related security implications.
3333

34-
NOTE: Here checkpoint/restore is a way to "fast-forward" the startup of the application to a phase where the application context is about to start, but does not allow to have a fully warmed-up JVM.
34+
NOTE: Automatic checkpoint/restore is a way to "fast-forward" the startup of the application to a phase where the application context is about to start, but it does not allow to have a fully warmed-up JVM.

framework-docs/modules/ROOT/pages/integration/class-data-sharing.adoc

+7-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
= Class Data Sharing
33

44
Class Data Sharing (CDS) is a https://docs.oracle.com/en/java/javase/17/vm/class-data-sharing.html[JVM feature]
5-
that can help reduce the startup time and memory footprints of Java applications.
5+
that can help reduce the startup time and memory footprint of Java applications.
66

77
To use this feature, a CDS archive should be created for the particular classpath of the
88
application. The Spring Framework provides a hook-point to ease the creation of the
@@ -12,15 +12,16 @@ archive. Once the archive is available, users should opt in to use it via a JVM
1212

1313
A CDS archive for an application can be created when the application exits. The Spring
1414
Framework provides a mode of operation where the process can exit automatically once the
15-
`ApplicationContext` has refreshed. In this mode, all non-lazy initialized singletons are
16-
instantiated, `InitializingBean#afterPropertiesSet` callbacks have been invoked, but the
17-
lifecycle has not started and `ContextRefreshedEvent` has not been published.
15+
`ApplicationContext` has refreshed. In this mode, all non-lazy initialized singletons
16+
have been instantiated, and `InitializingBean#afterPropertiesSet` callbacks have been
17+
invoked; but the lifecycle has not started, and the `ContextRefreshedEvent` has not yet
18+
been published.
1819

1920
To create the archive, two additional JVM flags must be specified:
2021

2122
* `-XX:ArchiveClassesAtExit=app-cds.jsa`: creates the CDS archive on exit
22-
* `-Dspring.context.exit=onRefresh`: starts and then immediately exit your Spring
23-
application as described above.
23+
* `-Dspring.context.exit=onRefresh`: starts and then immediately exits your Spring
24+
application as described above
2425

2526
To create a CDS archive, your JDK must have a base image. If you add the flags above to
2627
your startup script, you may get a warning that looks like this:

0 commit comments

Comments
 (0)