Slide 1

Slide 1 text

Moritz Halbritter @mhalbritter mhalbritter.github.io Step up the performance game with Spring Boot and Project Leyden

Slide 2

Slide 2 text

Why do we care about runtime efficiency? Cheaper hosting Sustainability Optimized containers

Slide 3

Slide 3 text

We’re going to take a look at 3 variants CDS AOT Cache AOT Cache with profiling and code compilation

Slide 4

Slide 4 text

Workflow Training run Cache Deployment run Startup Fast startup even on cheap servers or scale to zero Memory More applications on less servers Warmup Peak performance immediately

Slide 5

Slide 5 text

Optimize your Spring Boot applications with CDS

Slide 6

Slide 6 text

Requirements for Spring Boot with CDS Java 17+ Spring Boot 3.3+

Slide 7

Slide 7 text

java -Dspring.context.exit=onRefresh Start Exit on Refresh non-lazy singletons instantiated afterPropertiesSet invoked Lifecycle start invoked ContextRefreshedEvent published Running

Slide 8

Slide 8 text

Self-extracting executable JARs my-app.jar 35 MB java -Djarmode=tools -jar my-app.jar extract my-app/ lib/ my-app.jar 0.7 MB Library jars as files for optimized class loading Application classes + manifest file defining the classpath java -jar my-app/my-app.jar

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

Spring Petclinic startup time (seconds) 1.2x 1.9x 2.2x

Slide 11

Slide 11 text

Spring Petclinic RSS memory (MB) 3.3% 19.1% 19.6%

Slide 12

Slide 12 text

CDS requirements JVM The same JVM must be used. Classpath Must be specified as a list of jars. No directories, no wildcard, no nested jars. Deployment classpath must be a superset of the training one. Files The timestamps of the jars must be preserved. Training run When/how to do the training run? Application may try to connect to remote services like databases.

Slide 13

Slide 13 text

Training run configuration for your database https://github.com/spring-projects/spring-lifecycle-smoke-tests/tree/main#training-run-configuration

Slide 14

Slide 14 text

Training run configuration for your database

Slide 15

Slide 15 text

CDS support in Buildpacks Spring Boot Buildpacks + mvn spring-boot:build-image gradle bootBuildImage = The CDS training run is performed transparently when building the container image, ensuring that the same JVM is used

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

Optimize your Spring Boot applications with AOT Cache

Slide 18

Slide 18 text

AOT Cache and Spring AOT are different - but combine well AOT Cache JVM feature developed via Project Leyden to improve the efficiency of the JVM. It supersedes CDS. Spring AOT Spring feature mandatory for GraalVM native images support. Can also be used on the JVM to speed up the startup process and lower the memory consumption. Precomputes the bean arrangement for specific Spring profiles [1]. [1] https://github.com/sdeleuze/demo-profile-aot

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

Requirements for Spring Boot with AOT Cache Java 24+ Spring Boot 3.3+

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

Spring Petclinic startup time (seconds) 1.2x 1.9x 2.2x 2.6x

Slide 23

Slide 23 text

Spring Petclinic RSS memory (MB) 3.3% 19.1% 19.1% 22.7%

Slide 24

Slide 24 text

Whatʼs coming next via Project Leyden?

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

No content

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

Spring Petclinic startup time (seconds) 1.2x 2.2x 3.9x 4.4x

Slide 30

Slide 30 text

4.4x

Slide 31

Slide 31 text

440%

Slide 32

Slide 32 text

JVM warmup compared Time elapsed (s) Requests / s

Slide 33

Slide 33 text

Comparing GraalVM, Project CRaC and AOT Cache

Slide 34

Slide 34 text

Moritz Halbritter @mhalbritter mhalbritter.github.io THANKS!!!

Slide 35

Slide 35 text

SLIDE TITLE • Bullet 1 • Sub-bullet • Bullet 2 • Bullet 3 • Bullet 4