Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document support for AppCDS #31497

Closed
snicoll opened this issue Oct 25, 2023 · 3 comments
Closed

Document support for AppCDS #31497

snicoll opened this issue Oct 25, 2023 · 3 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: documentation A documentation task
Milestone

Comments

@snicoll
Copy link
Member

snicoll commented Oct 25, 2023

We want to explore the ability for a Spring-based app to run in a mode at build-time that allows recording various information that can be reused to optimize the actual app. We do this already with our Spring AOT engine that triggers application context parsing. During this special refresh phase (called refreshForAot) only a subset of the standard callbacks are invoked to prevent bean instantiation as much as possible.

The purpose of this issue is to see how that can be generalized or made a little bit more easy for tools to trigger it. The first candidate is AppCDS but there might be other components that need a "training run" of the app in a certain mode.

Concretely, we'd like to achieve the following:

  • Offer a configurable way of calling the regular refresh so that the app starts in a well-defined mode. This mode should be set externally so that the build-tool can have an impact on the application startup without any additional code change
  • Define a mode for AppCDS that performs as much as possible in terms of class loading.

Without any tooling, the following example could provide the class archive:

java -XX:ArchiveClassesAtExit=app-cds.jsa -Dspring.context.startup=AppCDS spring-petclinic-3.1.0-SNAPSHOT.jar

-Dspring.context.exit=onRefresh (see #31595) allows to tune the refresh phase, forcing the context to shut down once it has reached the requested phase so that the process stops and write the archive.

Spring Boot has additional tooling that could be reused to make that even more transparent for users.

@snicoll snicoll added the type: enhancement A general enhancement label Oct 25, 2023
@snicoll snicoll added this to the 6.2.x milestone Oct 25, 2023
@snicoll snicoll self-assigned this Oct 25, 2023
@jhoeller jhoeller added the in: core Issues in core modules (aop, beans, core, context, expression) label Oct 25, 2023
@snicoll
Copy link
Member Author

snicoll commented Nov 7, 2023

Looking at the current usage, I am not sure we want to introduce something specifically for the purpose of creating the class archive. Using the -XX:ArchiveClassesAtExit flag to save the archive when the process exits, and -XX:SharedArchiveFile to use it produces the best results. In particular, the technique using two steps (one to create the classes and one to create the archive) does not work with nested jars.

To get a bit of clarity of how this is being used, I work on a little JVM log parser that produces a report of how CDS was effective for a particular run. We still need to match those with actual benchmark numbers.

@snicoll
Copy link
Member Author

snicoll commented Nov 9, 2023

The past few days, we've been working on a prototype that could improve the exploded executable JAR use case. That proves to be quite effective with AppCDS. see spring-projects/spring-boot#38276

@jhoeller jhoeller added type: documentation A documentation task and removed type: enhancement A general enhancement labels Nov 14, 2023
@jhoeller jhoeller modified the milestones: 6.2.x, 6.1.x Nov 14, 2023
@jhoeller jhoeller changed the title Add support for AppCDS Document support for AppCDS Nov 14, 2023
@snicoll
Copy link
Member Author

snicoll commented Nov 15, 2023

With #31595, it's really about providing a few pointers for anyone building applications on top of the spring framework. We expect that additional guidance can be provided at the Spring Boot level when time permits.

@snicoll snicoll modified the milestones: 6.1.x, 6.1.1 Nov 20, 2023
sdeleuze added a commit to sdeleuze/spring-framework that referenced this issue Nov 21, 2023
sdeleuze added a commit to sdeleuze/spring-framework that referenced this issue Nov 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: documentation A documentation task
Projects
None yet
Development

No branches or pull requests

2 participants