SlideShare une entreprise Scribd logo
1  sur  61
Télécharger pour lire hors ligne
Sébastien Deleuze
September 2021
Spring Native
Copyright © 2021 VMware, Inc. or its affiliates.
Disclaimer
This presentation may contain product features or functionality that are currently under
development.
This overview of new technology represents no commitment from VMware to deliver these
features in any generally available product.
Features are subject to change, and must not be included in contracts, purchase orders, or
sales agreements of any kind.
Technical feasibility and market demand will affect final delivery.
Pricing and packaging for any new features/functionality/technology discussed or
presented, have not been determined.
The information in this presentation is for informational purposes only and may not be incorporated into any contract. There is no
commitment or obligation to deliver any items presented herein.
Join the discussion
● Make sure you’ve already registered at
https://springone.io/register
● Go to https://springone.slack.com
● Sign in using your springone.io credentials
● Join #session-spring-native channel
● Discuss and provide feedback during the talk
● A link to Q&A session will be posted there at the
end of this talk
Flashback
In march, the Spring team announced something special
Spring Native Beta!
Huge community feedback
What is Spring Native?
What is Spring Native
Spring Native provides beta support for compiling Spring Boot
applications to native executables with GraalVM, providing a
new way to deploy Spring Boot applications that then run
extremely efficiently.
JVM and Native offer different tradeoffs
Typical use cases
Sustainability
Smaller and cheaper instances
in the Cloud
Serverless
Instant startup
Kubernetes
Lighter pods, scalability & Knative
Microservices
Reduce the cost of splitting
Our goal
Allow developers to compile their Spring Boot applications to
native executables with as few changes as possible.
Challenges
On GraalVM side
● Some JVM features are not supported
● No class lazy loading
● Configuration required for reflection, proxies,
resources, etc.
● JVM libraries mostly untested on native
● Compatibility versus footprint
● Long build times
On Spring side
● Runtime reflection used with the annotation
based programming model
● API backward compatibility
● No major architectural change since based on
Spring Boot 2.x and Spring Framework 5.x
Getting started
Your native journey starts on start.spring.io
Or from its integration in popular IDEs
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<classifier>${repackage.classifier}</classifier>
<image>
<builder>paketobuildpacks/builder:tiny</builder>
<env>
<BP_NATIVE_IMAGE>true</BP_NATIVE_IMAGE>
</env>
</image>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.experimental</groupId>
<artifactId>spring-aot-maven-plugin</artifactId>
<version>${spring-native.version}</version>
...
</plugin>
</plugins>
</build>
Build configuration for native is done automatically
Maven Gradle
plugins {
id 'org.springframework.boot' version '2.5.4'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
id 'org.springframework.experimental.aot' version '0.10.3'
id 'org.graalvm.buildtools.native' version '0.9.3'
}
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
bootBuildImage {
builder = 'paketobuildpacks/builder:tiny'
environment = ['BP_NATIVE_IMAGE': 'true']
}
See generated Help.md for building native images
Spring Native reference documentation
2 ways of building native executables with Spring Native
Buildpacks
● Container based native builds based on
Buildpacks integration in Spring Boot
● Application compilation support
● Require Docker but not GraalVM native-image
compiler
● Produce a Linux container image
○ x86 is supported
○ ARM support work in progress, follow
https://github.com/buildpacks/lifecycle/iss
ues/435 for updates.
Native Build Tools
● Started as a collaboration between Spring and
GraalVM teams, and recently the Micronaut team
have joined us.
● https://github.com/graalvm/native-build-tools/
● Application compilation and testing support
● Require GraalVM native-image compiler
● Produce a native executable (no cross compilation)
○ Linux (x86, ARM)
○ MacOS (x86)
○ Windows (x86)
Native compilation
Buildpacks Native Build Tools
Almost instant startup for any Spring application
Buildpacks Native Build Tools
Supported languages
Kotlin
Current scope of the Spring support
● Actuator
● Data Elasticsearch
● Data JDBC
● Data JPA
● Data MongoDB
● Data Neo4j
● Data R2DBC
● Data Redis
● Hateoas
● JDBC
● Integration
● Mail
● Thymeleaf
● RSocket
● Validation
● Security
● Oauth2 resource server
● Oauth2 client
● Webflux
● WebMVC
● Websocket
● Quartz
● Testing with JUnit5
● Cloud config client
● Cloud config server
● Cloud Eureka client
● Cloud task
● Cloud function
● Cloud Sleuth
● Logback
● Wavefront
GraalVM native configuration with reflect-config.json
[
{
"name": "com.example.commandlinerunner.CLR",
"allDeclaredFields": true,
"allDeclaredConstructors": true,
"allDeclaredMethods": true,
"allPublicMethods": true,
"allDeclaredClasses": true
},
{
"name": "com.example.commandlinerunner.CommandlinerunnerApplication",
"allDeclaredFields": true,
"allDeclaredConstructors": true,
"allDeclaredMethods": true
},
{
"name": "java.io.Serializable",
"allDeclaredConstructors": true,
"allPublicMethods": true
}
]
Native hints
// native-image option or trigger for other hints -> native-image.properties
@NativeHint(options = "--enable-https")
// Reflection -> reflect-config.json ; *.class resources -> resource-config.json
@TypeHint(types = Data.class, typeNames = "com.example.webclient.Data$SuperHero")
// Additional resource to include in the native executable -> resource-config.json
@ResourceHint(patterns = "custom.sql" )
// JDK dynamic proxy on interfaces -> proxy-config.json
@JdkProxyHint(types = { org.springframework.context.annotation.Lazy.class,
org.springframework.core.annotation.SynthesizedAnnotation.class})
// Class with serialization support -> serialization-config.json
@SerializationHint(types = org.springframework.samples.petclinic.model.Person.class)
// Used to configure which class should be initialized at build-time -> native-image.properties
@InitializationHint(types = com.google.protobuf.Extension.class,
initTime = InitializationTime.BUILD)
Recent enhancements
Native testing
Ahead-of-time proxies usable on classes
// Typical security use case of a class proxy now supported on native
@Service
public class GreetingService {
public String hello() {
return "Hello!";
}
@PreAuthorize("hasRole('ADMIN')")
public String adminHello() {
return "Goodbye!";
}
}
// Hint for Build-time proxy on classes
-> Spring AOT plugin
@AotProxyHint(targetClass =
org.springframework.batch.core.launch.su
pport.SimpleJobOperator.class,
proxyFeatures = ProxyBits.IS_STATIC)
Compression support in Buildpacks
New in 0.11
● Buildpacks now supports compressing native
executables
● UPX allows 4x size reduction!
● Compression takes some time but native-image
has already long build time
● At runtime, startup is usually faster because
decompression is more than compensated by
less IO!
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<image>
<builder>paketobuildpacks/builder:tiny</builder>
<env>
<BP_NATIVE_IMAGE>true</BP_NATIVE_IMAGE>
<BP_BINARY_COMPRESSION_METHOD>upx</BP_BINARY_COMPRESSION_METHOD>
</env>
</image>
</configuration>
</plugin>
Ahead of Time transformations
Spring AOT plugins
Spring AOT Maven and Gradle plugins perform powerful
build-time transformations on Spring Boot applications to
improve efficiency on native, and potentially on the JVM too!
Compiling a Spring Boot application to native
native-image
compiler
Spring AOT plugin
javac
javac
Spring Boot
application
sources
Application
bytecode
AOT
sources
Native
configuration
AOT
bytecode
Native
executable
AOT application context processing
Huge effort during the summer
done by Stéphane Nicoll and Brian
Clozel to process Spring
application context beans at
build-time.
New in 0.11
Spring AOT plugin deep dive
Generate
source code
Native
configuration
inference
AOT application
context processing
New in 0.11
Spring AOT plugin
@Conditional
filtering
Classpath spring.factories
Application
properties
@NativeHint
Programmatic
Spring
factories
AOT proxy
generation
javac
Application
bytecode
Programmatic
application
context
Bytecode with
AOT proxies
Native
configuration
Spring Boot regular runtime
SpringApplication
@Configuration
spring.factories
Reflection
Reflection
*.class
resources
ASM
class
reading
Generated
bytecode
@Configuration(proxyBeanMethods = false)
@ConditionalOnClass({Jsonb.class})
@ConditionalOnResource( resources = ...)
public class JsonbAutoConfiguration {
public JsonbAutoConfiguration() { }
@Bean
@ConditionalOnMissingBean
public Jsonb jsonb() {
return JsonbBuilder.create();
}
}
# Logging Systems
org.springframework.boot.logging.LoggingSystemFactory=
org.springframework.boot.logging.logback.LogbackLoggingSystem.Factory,
org.springframework.boot.logging.log4j2.Log4J2LoggingSystem.Factory,
org.springframework.boot.logging.java.JavaLoggingSystem.Factory
# PropertySource Loaders
org.springframework.boot.env.PropertySourceLoader=
org.springframework.boot.env.PropertiesPropertySourceLoader,
org.springframework.boot.env.YamlPropertySourceLoader
CGLIB
proxy
generation
Spring Boot runtime in AOT mode (JVM and native)
SpringApplication
AOT bytecode
Programmatic
application context
Programmatic Spring
factories
New in 0.11
public abstract class StaticSpringFactories {
public static MultiValueMap<Class, Supplier<Object>> factories = new LinkedMultiValueMap();
static {
factories.add(org.springframework.boot.logging.LoggingSystemFactory.class,
() -> new org.springframework.boot.logging.logback.LogbackLoggingSystem.Factory());
factories.add(org.springframework.boot.logging.LoggingSystemFactory.class,
() -> new org.springframework.boot.logging.log4j2.Log4J2LoggingSystem.Factory());
factories.add(org.springframework.boot.logging.LoggingSystemFactory.class,
() -> new org.springframework.boot.logging.java.JavaLoggingSystem.Factory());
factories.add(org.springframework.boot.env.PropertySourceLoader.class,
() -> new org.springframework.boot.env.PropertiesPropertySourceLoader());
}
}
public class ContextBootstrapInitializer implements ApplicationContextInitializer<GenericApplicationContext> {
@Override
public void initialize(GenericApplicationContext context) {
context.getDefaultListableBeanFactory()
.setAutowireCandidateResolver(new ContextAnnotationAutowireCandidateResolver());
BeanDefinitionRegistrar.of("commandlinerunnerApplication", CommandlinerunnerApplication.class)
.instanceSupplier(CommandlinerunnerApplication::new).register(context);
BeanDefinitionRegistrar.of("CLR", CLR.class).instanceSupplier(CLR::new).register(context);
BeanDefinitionRegistrar.of("propertySourcesPlaceholderConfigurer",
PropertySourcesPlaceholderConfigurer.class).instanceSupplier(() ->
PropertyPlaceholderAutoConfiguration.propertySourcesPlaceholderConfigurer()).register(context);
// ...
}
}
Spring AOT strategy
● Move most configuration reflection from runtime to build-time
● Reduce the amount of Spring infrastructure required at runtime
● Maven and Gradle plugins with source generation:
○ To keep good debuggability
○ Annotation processors were by-design too limited for our
needs
● At runtime, AOT mode is:
○ mandatory on native
○ optional on the JVM, enabled via
java -DspringAot=true
Data points
Build time
Details
● Build time in seconds
● Spring Boot 2.5
● GraalVM 21.1 for 0.10, GraalVM 21.2 for 0.11
● Java 11 on Linux
● Laptop, Intel Core i7 8850H @ 2.6 GHz, 32G RAM
Container image size
Details
● Container image size in Megabytes
● Spring Boot 2.5
● Liberica JDK 11.0.12 for JVM, GraalVM CE 21.1 for
0.10, GraalVM CE 21.2 for 0.11
● Java 11 on Linux
Deep dive into a minimal native container image
New in 0.11
Memory footprint
Details
● RSS memory footprint after startup in
Megabytes
● Spring Boot 2.5
● Liberica JDK 11.0.12 for JVM, GraalVM CE 21.1 for
0.10, GraalVM CE 21.2 for 0.11
● JVM application ran as an unpacked archive
● Java 11 on Mac
* Expect lower memory consumption in 0.11.0 with GraalVM 21.3 optimizations on reflection
Startup time
Details
● Startup time (including the JVM) in milliseconds
● Simple web application with Spring MVC +
Tomcat
● Spring Boot 2.5
● Liberica JDK 11.0.12 for JVM, GraalVM CE 21.1 for
0.10, GraalVM CE 21.2 for 0.11
● JVM application ran as an unpacked archive
● Java 11 on Linux
● Laptop, Intel Core i7 8850H @ 2.6 GHz, 32G
RAM
GraalVM 21.3
GraalVM 21.3 new baseline
● GraalVM 21.3
○ To be released October 19th
○ Major improvements to reflection support
○ Java 17 support
○ Removal of Java 8 support
● Spring Native 0.11.0
○ GraalVM 21.3 baseline
○ Current snapshots based on GraalVM 21.2
○ Java 11 and Java 17 support
New in 0.11
Distinguish between invoked and queried reflection
methods
● Proposal
○ Updated reflect-config.json capabilities to allow
specifying that only reflection metadata like annotations
are needed
○ Efficiency gains since it is mainly the reflective
invocation which is costly on native.
● Up to 20% measured footprint reduction with Spring
applications
● https://github.com/oracle/graal/issues/3566 for more details
New in 0.11
Reachability based native configuration
● Build-time class initialization was the main way to reduce
image size and memory footprint, but a dead-end in term of
compatibility
● Proposal
○ Add a whenTypeReachable predicate to
reflect-config.json
○ Allows to take advantage of the native image static
analysis
○ Make it possible to switch everything to runtime
initialization with low footprint
● https://github.com/oracle/graal/issues/3551 for more details
New in 0.11
Inlining of simpler reflections calls
New in 0.11
● Inlining done at build-time
when arguments are constants
and implementation simple
enough
● Avoid the new for reflection
config
● Behind a flag in GraalVM 21.2,
enabled by default in 21.3
● https://github.com/oracle/graal/
issues/2500 for more details
// Does not require reflect-config.json configuration
// because inlined at build-time
Class.forName("org.example.Foo")
.getDeclaredConstructor().newInstance();
// Same for this one!
BeanUtils.instantiateClass(Foo.class);
Roadmap
Spring Native 0.11.0
● Key features
○ AOT application context
○ GraalVM 21.3 with reflection optimizations
○ Java 11 and Java 17 support
○ Spring Boot 2.6.0
○ UPX compression for container images
● 0.11 milestones published shortly for feedback
● 0.11.0 to be released November 19th
○ Following Spring Boot 2.6.0 release
VMware Tanzu adds end-to-end native support
● VMware and Bellsoft now have a support
agreement in place that provides end-to-end
native support to VMware Tanzu customers via
Liberica Native Image Kit*
● Bellsoft Liberica NIK, based on the GraalVM
Community Edition and Liberica JDK, will be
used in native Buildpacks as of Spring Native
0.11.0
● Consistent with the JVM side where Liberica
JDK is used
● Fixes and enhancements will be contributed
upstream to https://github.com/oracle/graal
* https://bell-sw.com/pages/liberica-native-image-kit/
The future of Spring Native is
first-class native support in
Spring Boot 3.x
Spring Boot 3 AOT and native support overview
Native build tools
Native configuration
libraries
GraalVM Spring Boot 3
AOT support in
Maven and Gradle
plugins
AOT transformation
engine
Spring Framework 6
Paketo Buildpacks
Native Buildpack
Native foundational
support and key
enablers
GraalVM 22.x
Native support
Spring portfolio (Data, Security, etc.)
AOT transformations Minimal native hints
Architecture likely to change as we implement it
Roadmaps towards GA
● Spring Framework 6.0
○ 6.0 M1 in Q4 2021
○ 6.0 RC1 in Q3 2022
○ 6.0 GA in Q4 2022
● Spring Boot 3.0 GA to follow
● Migration from Spring Native
Goals
● Seamless integration in Spring Boot
● Increased native support
● Runtime efficiency via AOT
transformations for native and JVM
● Java 17 baseline
Collaboration with GraalVM team continue to increase
“We are excited about the great partnership between the Spring
and GraalVM engineering teams to support native ahead-of-time
compilation for millions of Spring Boot applications. This is a
game changer enabling low memory footprint and instant startup
for these workloads.”
Thomas Wuerthinger, GraalVM founder & project lead
Native configuration repository
● Native configuration for JVM libraries
○ Main goal remains direct inclusion in
libraries
○ This repository intends to fill the gap
● Automated testing via native build tools +
dedicated CI infrastructure
● Initially a GraalVM and Spring driven effort
● All non Spring native hints will be moved to this
repository
● Guidelines on how to craft native configuration
○ Runtime initialization by default
○ No or very limited build-time initialization
○ Reachability based native configuration
○ Mandatory native testing
We are building a framework
for the next decade
The Spring team is fully
committed to build a strong
Java native ecosystem
Use Spring Native today to
compile your Spring Boot
application to native
executable
Spring Boot 3.x AOT
optimizations and native
support will benefit to millions
of Spring Boot applications
Thank you
Contact me at @sdeleuze on Twitter
© 2021 Spring. A VMware-backed project.

Contenu connexe

Tendances

Tendances (20)

GraalVm and Quarkus
GraalVm and QuarkusGraalVm and Quarkus
GraalVm and Quarkus
 
Serverless integration with Knative and Apache Camel on Kubernetes
Serverless integration with Knative and Apache Camel on KubernetesServerless integration with Knative and Apache Camel on Kubernetes
Serverless integration with Knative and Apache Camel on Kubernetes
 
GraalVM: Run Programs Faster Everywhere
GraalVM: Run Programs Faster EverywhereGraalVM: Run Programs Faster Everywhere
GraalVM: Run Programs Faster Everywhere
 
GraalVM Native Images by Oleg Selajev @shelajev
GraalVM Native Images by Oleg Selajev @shelajevGraalVM Native Images by Oleg Selajev @shelajev
GraalVM Native Images by Oleg Selajev @shelajev
 
Microservices with Java, Spring Boot and Spring Cloud
Microservices with Java, Spring Boot and Spring CloudMicroservices with Java, Spring Boot and Spring Cloud
Microservices with Java, Spring Boot and Spring Cloud
 
AOT and Native with Spring Boot 3.0
AOT and Native with Spring Boot 3.0AOT and Native with Spring Boot 3.0
AOT and Native with Spring Boot 3.0
 
Gradle - the Enterprise Automation Tool
Gradle  - the Enterprise Automation ToolGradle  - the Enterprise Automation Tool
Gradle - the Enterprise Automation Tool
 
Native Java with GraalVM
Native Java with GraalVMNative Java with GraalVM
Native Java with GraalVM
 
Terraform
TerraformTerraform
Terraform
 
Micronaut: A new way to build microservices
Micronaut: A new way to build microservicesMicronaut: A new way to build microservices
Micronaut: A new way to build microservices
 
Understanding MicroSERVICE Architecture with Java & Spring Boot
Understanding MicroSERVICE Architecture with Java & Spring BootUnderstanding MicroSERVICE Architecture with Java & Spring Boot
Understanding MicroSERVICE Architecture with Java & Spring Boot
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Spring cloud for microservices architecture
Spring cloud for microservices architectureSpring cloud for microservices architecture
Spring cloud for microservices architecture
 
Spring Framework - Data Access
Spring Framework - Data AccessSpring Framework - Data Access
Spring Framework - Data Access
 
Best Practices for Middleware and Integration Architecture Modernization with...
Best Practices for Middleware and Integration Architecture Modernization with...Best Practices for Middleware and Integration Architecture Modernization with...
Best Practices for Middleware and Integration Architecture Modernization with...
 
Discover Quarkus and GraalVM
Discover Quarkus and GraalVMDiscover Quarkus and GraalVM
Discover Quarkus and GraalVM
 
Grafana vs Kibana
Grafana vs KibanaGrafana vs Kibana
Grafana vs Kibana
 
Cloud Native Java GraalVM 이상과 현실
Cloud Native Java GraalVM 이상과 현실Cloud Native Java GraalVM 이상과 현실
Cloud Native Java GraalVM 이상과 현실
 
Building APIs with Mule and Spring Boot
Building APIs with Mule and Spring BootBuilding APIs with Mule and Spring Boot
Building APIs with Mule and Spring Boot
 
Introduction to Apache Kafka
Introduction to Apache KafkaIntroduction to Apache Kafka
Introduction to Apache Kafka
 

Similaire à Spring Native and Spring AOT

Jenkins advance topic
Jenkins advance topicJenkins advance topic
Jenkins advance topic
Kalkey
 
Backroll: Production Grade KVM Backup Solution Integrated in CloudStack
Backroll: Production Grade KVM Backup Solution Integrated in CloudStackBackroll: Production Grade KVM Backup Solution Integrated in CloudStack
Backroll: Production Grade KVM Backup Solution Integrated in CloudStack
ShapeBlue
 

Similaire à Spring Native and Spring AOT (20)

[20200720]cloud native develoment - Nelson Lin
[20200720]cloud native develoment - Nelson Lin[20200720]cloud native develoment - Nelson Lin
[20200720]cloud native develoment - Nelson Lin
 
Java and windows azure cloud service
Java and windows azure cloud serviceJava and windows azure cloud service
Java and windows azure cloud service
 
Pivotal Platform - December Release A First Look
Pivotal Platform - December Release A First LookPivotal Platform - December Release A First Look
Pivotal Platform - December Release A First Look
 
Lean microservices through ahead of time compilation (Tobias Piper, Loveholid...
Lean microservices through ahead of time compilation (Tobias Piper, Loveholid...Lean microservices through ahead of time compilation (Tobias Piper, Loveholid...
Lean microservices through ahead of time compilation (Tobias Piper, Loveholid...
 
Exploring Next Generation Buildpacks - Anand Rao & Scott Deeg
Exploring Next Generation Buildpacks - Anand Rao & Scott DeegExploring Next Generation Buildpacks - Anand Rao & Scott Deeg
Exploring Next Generation Buildpacks - Anand Rao & Scott Deeg
 
Meet Magento Spain 2019 - Our Experience with Magento Cloud
Meet Magento Spain 2019 - Our Experience with Magento CloudMeet Magento Spain 2019 - Our Experience with Magento Cloud
Meet Magento Spain 2019 - Our Experience with Magento Cloud
 
Microservices with kubernetes @190316
Microservices with kubernetes @190316Microservices with kubernetes @190316
Microservices with kubernetes @190316
 
Going Serverless Using the Spring Framework Ecosystem
Going Serverless Using the Spring Framework EcosystemGoing Serverless Using the Spring Framework Ecosystem
Going Serverless Using the Spring Framework Ecosystem
 
SpringBoot and Spring Cloud Service for MSA
SpringBoot and Spring Cloud Service for MSASpringBoot and Spring Cloud Service for MSA
SpringBoot and Spring Cloud Service for MSA
 
Red Hat Forum Benelux 2015
Red Hat Forum Benelux 2015Red Hat Forum Benelux 2015
Red Hat Forum Benelux 2015
 
Mulesoft kochi meetup 8 custom connector
Mulesoft kochi meetup 8   custom connectorMulesoft kochi meetup 8   custom connector
Mulesoft kochi meetup 8 custom connector
 
Flutter vs Java Graphical User Interface Frameworks - text
Flutter vs Java Graphical User Interface Frameworks - textFlutter vs Java Graphical User Interface Frameworks - text
Flutter vs Java Graphical User Interface Frameworks - text
 
Code One 2018 maven
Code One 2018   mavenCode One 2018   maven
Code One 2018 maven
 
Jenkins advance topic
Jenkins advance topicJenkins advance topic
Jenkins advance topic
 
Backroll: Production Grade KVM Backup Solution Integrated in CloudStack
Backroll: Production Grade KVM Backup Solution Integrated in CloudStackBackroll: Production Grade KVM Backup Solution Integrated in CloudStack
Backroll: Production Grade KVM Backup Solution Integrated in CloudStack
 
Cloud-powered Continuous Integration and Deployment architectures - Jinesh Varia
Cloud-powered Continuous Integration and Deployment architectures - Jinesh VariaCloud-powered Continuous Integration and Deployment architectures - Jinesh Varia
Cloud-powered Continuous Integration and Deployment architectures - Jinesh Varia
 
Google Cloud Platform
Google Cloud Platform Google Cloud Platform
Google Cloud Platform
 
Windows azure overview for SharePoint Pros
Windows azure overview for SharePoint Pros Windows azure overview for SharePoint Pros
Windows azure overview for SharePoint Pros
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository world
 
Spring Boot 3 And Beyond
Spring Boot 3 And BeyondSpring Boot 3 And Beyond
Spring Boot 3 And Beyond
 

Plus de VMware Tanzu

Plus de VMware Tanzu (20)

What AI Means For Your Product Strategy And What To Do About It
What AI Means For Your Product Strategy And What To Do About ItWhat AI Means For Your Product Strategy And What To Do About It
What AI Means For Your Product Strategy And What To Do About It
 
Make the Right Thing the Obvious Thing at Cardinal Health 2023
Make the Right Thing the Obvious Thing at Cardinal Health 2023Make the Right Thing the Obvious Thing at Cardinal Health 2023
Make the Right Thing the Obvious Thing at Cardinal Health 2023
 
Enhancing DevEx and Simplifying Operations at Scale
Enhancing DevEx and Simplifying Operations at ScaleEnhancing DevEx and Simplifying Operations at Scale
Enhancing DevEx and Simplifying Operations at Scale
 
Spring Update | July 2023
Spring Update | July 2023Spring Update | July 2023
Spring Update | July 2023
 
Platforms, Platform Engineering, & Platform as a Product
Platforms, Platform Engineering, & Platform as a ProductPlatforms, Platform Engineering, & Platform as a Product
Platforms, Platform Engineering, & Platform as a Product
 
Building Cloud Ready Apps
Building Cloud Ready AppsBuilding Cloud Ready Apps
Building Cloud Ready Apps
 
Spring Cloud Gateway - SpringOne Tour 2023 Charles Schwab.pdf
Spring Cloud Gateway - SpringOne Tour 2023 Charles Schwab.pdfSpring Cloud Gateway - SpringOne Tour 2023 Charles Schwab.pdf
Spring Cloud Gateway - SpringOne Tour 2023 Charles Schwab.pdf
 
Simplify and Scale Enterprise Apps in the Cloud | Boston 2023
Simplify and Scale Enterprise Apps in the Cloud | Boston 2023Simplify and Scale Enterprise Apps in the Cloud | Boston 2023
Simplify and Scale Enterprise Apps in the Cloud | Boston 2023
 
Simplify and Scale Enterprise Apps in the Cloud | Seattle 2023
Simplify and Scale Enterprise Apps in the Cloud | Seattle 2023Simplify and Scale Enterprise Apps in the Cloud | Seattle 2023
Simplify and Scale Enterprise Apps in the Cloud | Seattle 2023
 
tanzu_developer_connect.pptx
tanzu_developer_connect.pptxtanzu_developer_connect.pptx
tanzu_developer_connect.pptx
 
Tanzu Virtual Developer Connect Workshop - French
Tanzu Virtual Developer Connect Workshop - FrenchTanzu Virtual Developer Connect Workshop - French
Tanzu Virtual Developer Connect Workshop - French
 
Tanzu Developer Connect Workshop - English
Tanzu Developer Connect Workshop - EnglishTanzu Developer Connect Workshop - English
Tanzu Developer Connect Workshop - English
 
Virtual Developer Connect Workshop - English
Virtual Developer Connect Workshop - EnglishVirtual Developer Connect Workshop - English
Virtual Developer Connect Workshop - English
 
Tanzu Developer Connect - French
Tanzu Developer Connect - FrenchTanzu Developer Connect - French
Tanzu Developer Connect - French
 
Simplify and Scale Enterprise Apps in the Cloud | Dallas 2023
Simplify and Scale Enterprise Apps in the Cloud | Dallas 2023Simplify and Scale Enterprise Apps in the Cloud | Dallas 2023
Simplify and Scale Enterprise Apps in the Cloud | Dallas 2023
 
SpringOne Tour: Deliver 15-Factor Applications on Kubernetes with Spring Boot
SpringOne Tour: Deliver 15-Factor Applications on Kubernetes with Spring BootSpringOne Tour: Deliver 15-Factor Applications on Kubernetes with Spring Boot
SpringOne Tour: Deliver 15-Factor Applications on Kubernetes with Spring Boot
 
SpringOne Tour: The Influential Software Engineer
SpringOne Tour: The Influential Software EngineerSpringOne Tour: The Influential Software Engineer
SpringOne Tour: The Influential Software Engineer
 
SpringOne Tour: Domain-Driven Design: Theory vs Practice
SpringOne Tour: Domain-Driven Design: Theory vs PracticeSpringOne Tour: Domain-Driven Design: Theory vs Practice
SpringOne Tour: Domain-Driven Design: Theory vs Practice
 
SpringOne Tour: Spring Recipes: A Collection of Common-Sense Solutions
SpringOne Tour: Spring Recipes: A Collection of Common-Sense SolutionsSpringOne Tour: Spring Recipes: A Collection of Common-Sense Solutions
SpringOne Tour: Spring Recipes: A Collection of Common-Sense Solutions
 
SpringOne Tour: Doing Progressive Delivery with your Team
SpringOne Tour: Doing Progressive Delivery with your TeamSpringOne Tour: Doing Progressive Delivery with your Team
SpringOne Tour: Doing Progressive Delivery with your Team
 

Dernier

+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 

Dernier (20)

+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verifiedSector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 

Spring Native and Spring AOT

  • 1. Sébastien Deleuze September 2021 Spring Native Copyright © 2021 VMware, Inc. or its affiliates.
  • 2. Disclaimer This presentation may contain product features or functionality that are currently under development. This overview of new technology represents no commitment from VMware to deliver these features in any generally available product. Features are subject to change, and must not be included in contracts, purchase orders, or sales agreements of any kind. Technical feasibility and market demand will affect final delivery. Pricing and packaging for any new features/functionality/technology discussed or presented, have not been determined. The information in this presentation is for informational purposes only and may not be incorporated into any contract. There is no commitment or obligation to deliver any items presented herein.
  • 3. Join the discussion ● Make sure you’ve already registered at https://springone.io/register ● Go to https://springone.slack.com ● Sign in using your springone.io credentials ● Join #session-spring-native channel ● Discuss and provide feedback during the talk ● A link to Q&A session will be posted there at the end of this talk
  • 5. In march, the Spring team announced something special
  • 8. What is Spring Native?
  • 9. What is Spring Native Spring Native provides beta support for compiling Spring Boot applications to native executables with GraalVM, providing a new way to deploy Spring Boot applications that then run extremely efficiently.
  • 10. JVM and Native offer different tradeoffs
  • 11. Typical use cases Sustainability Smaller and cheaper instances in the Cloud Serverless Instant startup Kubernetes Lighter pods, scalability & Knative Microservices Reduce the cost of splitting
  • 12. Our goal Allow developers to compile their Spring Boot applications to native executables with as few changes as possible.
  • 13. Challenges On GraalVM side ● Some JVM features are not supported ● No class lazy loading ● Configuration required for reflection, proxies, resources, etc. ● JVM libraries mostly untested on native ● Compatibility versus footprint ● Long build times On Spring side ● Runtime reflection used with the annotation based programming model ● API backward compatibility ● No major architectural change since based on Spring Boot 2.x and Spring Framework 5.x
  • 15. Your native journey starts on start.spring.io
  • 16. Or from its integration in popular IDEs
  • 17. <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <classifier>${repackage.classifier}</classifier> <image> <builder>paketobuildpacks/builder:tiny</builder> <env> <BP_NATIVE_IMAGE>true</BP_NATIVE_IMAGE> </env> </image> </configuration> </plugin> <plugin> <groupId>org.springframework.experimental</groupId> <artifactId>spring-aot-maven-plugin</artifactId> <version>${spring-native.version}</version> ... </plugin> </plugins> </build> Build configuration for native is done automatically Maven Gradle plugins { id 'org.springframework.boot' version '2.5.4' id 'io.spring.dependency-management' version '1.0.11.RELEASE' id 'java' id 'org.springframework.experimental.aot' version '0.10.3' id 'org.graalvm.buildtools.native' version '0.9.3' } group = 'com.example' version = '0.0.1-SNAPSHOT' sourceCompatibility = '11' bootBuildImage { builder = 'paketobuildpacks/builder:tiny' environment = ['BP_NATIVE_IMAGE': 'true'] }
  • 18. See generated Help.md for building native images
  • 19. Spring Native reference documentation
  • 20. 2 ways of building native executables with Spring Native Buildpacks ● Container based native builds based on Buildpacks integration in Spring Boot ● Application compilation support ● Require Docker but not GraalVM native-image compiler ● Produce a Linux container image ○ x86 is supported ○ ARM support work in progress, follow https://github.com/buildpacks/lifecycle/iss ues/435 for updates. Native Build Tools ● Started as a collaboration between Spring and GraalVM teams, and recently the Micronaut team have joined us. ● https://github.com/graalvm/native-build-tools/ ● Application compilation and testing support ● Require GraalVM native-image compiler ● Produce a native executable (no cross compilation) ○ Linux (x86, ARM) ○ MacOS (x86) ○ Windows (x86)
  • 22. Almost instant startup for any Spring application Buildpacks Native Build Tools
  • 24. Current scope of the Spring support ● Actuator ● Data Elasticsearch ● Data JDBC ● Data JPA ● Data MongoDB ● Data Neo4j ● Data R2DBC ● Data Redis ● Hateoas ● JDBC ● Integration ● Mail ● Thymeleaf ● RSocket ● Validation ● Security ● Oauth2 resource server ● Oauth2 client ● Webflux ● WebMVC ● Websocket ● Quartz ● Testing with JUnit5 ● Cloud config client ● Cloud config server ● Cloud Eureka client ● Cloud task ● Cloud function ● Cloud Sleuth ● Logback ● Wavefront
  • 25. GraalVM native configuration with reflect-config.json [ { "name": "com.example.commandlinerunner.CLR", "allDeclaredFields": true, "allDeclaredConstructors": true, "allDeclaredMethods": true, "allPublicMethods": true, "allDeclaredClasses": true }, { "name": "com.example.commandlinerunner.CommandlinerunnerApplication", "allDeclaredFields": true, "allDeclaredConstructors": true, "allDeclaredMethods": true }, { "name": "java.io.Serializable", "allDeclaredConstructors": true, "allPublicMethods": true } ]
  • 26. Native hints // native-image option or trigger for other hints -> native-image.properties @NativeHint(options = "--enable-https") // Reflection -> reflect-config.json ; *.class resources -> resource-config.json @TypeHint(types = Data.class, typeNames = "com.example.webclient.Data$SuperHero") // Additional resource to include in the native executable -> resource-config.json @ResourceHint(patterns = "custom.sql" ) // JDK dynamic proxy on interfaces -> proxy-config.json @JdkProxyHint(types = { org.springframework.context.annotation.Lazy.class, org.springframework.core.annotation.SynthesizedAnnotation.class}) // Class with serialization support -> serialization-config.json @SerializationHint(types = org.springframework.samples.petclinic.model.Person.class) // Used to configure which class should be initialized at build-time -> native-image.properties @InitializationHint(types = com.google.protobuf.Extension.class, initTime = InitializationTime.BUILD)
  • 29. Ahead-of-time proxies usable on classes // Typical security use case of a class proxy now supported on native @Service public class GreetingService { public String hello() { return "Hello!"; } @PreAuthorize("hasRole('ADMIN')") public String adminHello() { return "Goodbye!"; } } // Hint for Build-time proxy on classes -> Spring AOT plugin @AotProxyHint(targetClass = org.springframework.batch.core.launch.su pport.SimpleJobOperator.class, proxyFeatures = ProxyBits.IS_STATIC)
  • 30. Compression support in Buildpacks New in 0.11 ● Buildpacks now supports compressing native executables ● UPX allows 4x size reduction! ● Compression takes some time but native-image has already long build time ● At runtime, startup is usually faster because decompression is more than compensated by less IO! <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <image> <builder>paketobuildpacks/builder:tiny</builder> <env> <BP_NATIVE_IMAGE>true</BP_NATIVE_IMAGE> <BP_BINARY_COMPRESSION_METHOD>upx</BP_BINARY_COMPRESSION_METHOD> </env> </image> </configuration> </plugin>
  • 31. Ahead of Time transformations
  • 32. Spring AOT plugins Spring AOT Maven and Gradle plugins perform powerful build-time transformations on Spring Boot applications to improve efficiency on native, and potentially on the JVM too!
  • 33. Compiling a Spring Boot application to native native-image compiler Spring AOT plugin javac javac Spring Boot application sources Application bytecode AOT sources Native configuration AOT bytecode Native executable
  • 34. AOT application context processing Huge effort during the summer done by Stéphane Nicoll and Brian Clozel to process Spring application context beans at build-time. New in 0.11
  • 35. Spring AOT plugin deep dive Generate source code Native configuration inference AOT application context processing New in 0.11 Spring AOT plugin @Conditional filtering Classpath spring.factories Application properties @NativeHint Programmatic Spring factories AOT proxy generation javac Application bytecode Programmatic application context Bytecode with AOT proxies Native configuration
  • 36. Spring Boot regular runtime SpringApplication @Configuration spring.factories Reflection Reflection *.class resources ASM class reading Generated bytecode @Configuration(proxyBeanMethods = false) @ConditionalOnClass({Jsonb.class}) @ConditionalOnResource( resources = ...) public class JsonbAutoConfiguration { public JsonbAutoConfiguration() { } @Bean @ConditionalOnMissingBean public Jsonb jsonb() { return JsonbBuilder.create(); } } # Logging Systems org.springframework.boot.logging.LoggingSystemFactory= org.springframework.boot.logging.logback.LogbackLoggingSystem.Factory, org.springframework.boot.logging.log4j2.Log4J2LoggingSystem.Factory, org.springframework.boot.logging.java.JavaLoggingSystem.Factory # PropertySource Loaders org.springframework.boot.env.PropertySourceLoader= org.springframework.boot.env.PropertiesPropertySourceLoader, org.springframework.boot.env.YamlPropertySourceLoader CGLIB proxy generation
  • 37. Spring Boot runtime in AOT mode (JVM and native) SpringApplication AOT bytecode Programmatic application context Programmatic Spring factories New in 0.11 public abstract class StaticSpringFactories { public static MultiValueMap<Class, Supplier<Object>> factories = new LinkedMultiValueMap(); static { factories.add(org.springframework.boot.logging.LoggingSystemFactory.class, () -> new org.springframework.boot.logging.logback.LogbackLoggingSystem.Factory()); factories.add(org.springframework.boot.logging.LoggingSystemFactory.class, () -> new org.springframework.boot.logging.log4j2.Log4J2LoggingSystem.Factory()); factories.add(org.springframework.boot.logging.LoggingSystemFactory.class, () -> new org.springframework.boot.logging.java.JavaLoggingSystem.Factory()); factories.add(org.springframework.boot.env.PropertySourceLoader.class, () -> new org.springframework.boot.env.PropertiesPropertySourceLoader()); } } public class ContextBootstrapInitializer implements ApplicationContextInitializer<GenericApplicationContext> { @Override public void initialize(GenericApplicationContext context) { context.getDefaultListableBeanFactory() .setAutowireCandidateResolver(new ContextAnnotationAutowireCandidateResolver()); BeanDefinitionRegistrar.of("commandlinerunnerApplication", CommandlinerunnerApplication.class) .instanceSupplier(CommandlinerunnerApplication::new).register(context); BeanDefinitionRegistrar.of("CLR", CLR.class).instanceSupplier(CLR::new).register(context); BeanDefinitionRegistrar.of("propertySourcesPlaceholderConfigurer", PropertySourcesPlaceholderConfigurer.class).instanceSupplier(() -> PropertyPlaceholderAutoConfiguration.propertySourcesPlaceholderConfigurer()).register(context); // ... } }
  • 38. Spring AOT strategy ● Move most configuration reflection from runtime to build-time ● Reduce the amount of Spring infrastructure required at runtime ● Maven and Gradle plugins with source generation: ○ To keep good debuggability ○ Annotation processors were by-design too limited for our needs ● At runtime, AOT mode is: ○ mandatory on native ○ optional on the JVM, enabled via java -DspringAot=true
  • 40. Build time Details ● Build time in seconds ● Spring Boot 2.5 ● GraalVM 21.1 for 0.10, GraalVM 21.2 for 0.11 ● Java 11 on Linux ● Laptop, Intel Core i7 8850H @ 2.6 GHz, 32G RAM
  • 41. Container image size Details ● Container image size in Megabytes ● Spring Boot 2.5 ● Liberica JDK 11.0.12 for JVM, GraalVM CE 21.1 for 0.10, GraalVM CE 21.2 for 0.11 ● Java 11 on Linux
  • 42. Deep dive into a minimal native container image New in 0.11
  • 43. Memory footprint Details ● RSS memory footprint after startup in Megabytes ● Spring Boot 2.5 ● Liberica JDK 11.0.12 for JVM, GraalVM CE 21.1 for 0.10, GraalVM CE 21.2 for 0.11 ● JVM application ran as an unpacked archive ● Java 11 on Mac * Expect lower memory consumption in 0.11.0 with GraalVM 21.3 optimizations on reflection
  • 44. Startup time Details ● Startup time (including the JVM) in milliseconds ● Simple web application with Spring MVC + Tomcat ● Spring Boot 2.5 ● Liberica JDK 11.0.12 for JVM, GraalVM CE 21.1 for 0.10, GraalVM CE 21.2 for 0.11 ● JVM application ran as an unpacked archive ● Java 11 on Linux ● Laptop, Intel Core i7 8850H @ 2.6 GHz, 32G RAM
  • 46. GraalVM 21.3 new baseline ● GraalVM 21.3 ○ To be released October 19th ○ Major improvements to reflection support ○ Java 17 support ○ Removal of Java 8 support ● Spring Native 0.11.0 ○ GraalVM 21.3 baseline ○ Current snapshots based on GraalVM 21.2 ○ Java 11 and Java 17 support New in 0.11
  • 47. Distinguish between invoked and queried reflection methods ● Proposal ○ Updated reflect-config.json capabilities to allow specifying that only reflection metadata like annotations are needed ○ Efficiency gains since it is mainly the reflective invocation which is costly on native. ● Up to 20% measured footprint reduction with Spring applications ● https://github.com/oracle/graal/issues/3566 for more details New in 0.11
  • 48. Reachability based native configuration ● Build-time class initialization was the main way to reduce image size and memory footprint, but a dead-end in term of compatibility ● Proposal ○ Add a whenTypeReachable predicate to reflect-config.json ○ Allows to take advantage of the native image static analysis ○ Make it possible to switch everything to runtime initialization with low footprint ● https://github.com/oracle/graal/issues/3551 for more details New in 0.11
  • 49. Inlining of simpler reflections calls New in 0.11 ● Inlining done at build-time when arguments are constants and implementation simple enough ● Avoid the new for reflection config ● Behind a flag in GraalVM 21.2, enabled by default in 21.3 ● https://github.com/oracle/graal/ issues/2500 for more details // Does not require reflect-config.json configuration // because inlined at build-time Class.forName("org.example.Foo") .getDeclaredConstructor().newInstance(); // Same for this one! BeanUtils.instantiateClass(Foo.class);
  • 51. Spring Native 0.11.0 ● Key features ○ AOT application context ○ GraalVM 21.3 with reflection optimizations ○ Java 11 and Java 17 support ○ Spring Boot 2.6.0 ○ UPX compression for container images ● 0.11 milestones published shortly for feedback ● 0.11.0 to be released November 19th ○ Following Spring Boot 2.6.0 release
  • 52. VMware Tanzu adds end-to-end native support ● VMware and Bellsoft now have a support agreement in place that provides end-to-end native support to VMware Tanzu customers via Liberica Native Image Kit* ● Bellsoft Liberica NIK, based on the GraalVM Community Edition and Liberica JDK, will be used in native Buildpacks as of Spring Native 0.11.0 ● Consistent with the JVM side where Liberica JDK is used ● Fixes and enhancements will be contributed upstream to https://github.com/oracle/graal * https://bell-sw.com/pages/liberica-native-image-kit/
  • 53. The future of Spring Native is first-class native support in Spring Boot 3.x
  • 54. Spring Boot 3 AOT and native support overview Native build tools Native configuration libraries GraalVM Spring Boot 3 AOT support in Maven and Gradle plugins AOT transformation engine Spring Framework 6 Paketo Buildpacks Native Buildpack Native foundational support and key enablers GraalVM 22.x Native support Spring portfolio (Data, Security, etc.) AOT transformations Minimal native hints Architecture likely to change as we implement it Roadmaps towards GA ● Spring Framework 6.0 ○ 6.0 M1 in Q4 2021 ○ 6.0 RC1 in Q3 2022 ○ 6.0 GA in Q4 2022 ● Spring Boot 3.0 GA to follow ● Migration from Spring Native Goals ● Seamless integration in Spring Boot ● Increased native support ● Runtime efficiency via AOT transformations for native and JVM ● Java 17 baseline
  • 55. Collaboration with GraalVM team continue to increase “We are excited about the great partnership between the Spring and GraalVM engineering teams to support native ahead-of-time compilation for millions of Spring Boot applications. This is a game changer enabling low memory footprint and instant startup for these workloads.” Thomas Wuerthinger, GraalVM founder & project lead
  • 56. Native configuration repository ● Native configuration for JVM libraries ○ Main goal remains direct inclusion in libraries ○ This repository intends to fill the gap ● Automated testing via native build tools + dedicated CI infrastructure ● Initially a GraalVM and Spring driven effort ● All non Spring native hints will be moved to this repository ● Guidelines on how to craft native configuration ○ Runtime initialization by default ○ No or very limited build-time initialization ○ Reachability based native configuration ○ Mandatory native testing
  • 57. We are building a framework for the next decade
  • 58. The Spring team is fully committed to build a strong Java native ecosystem
  • 59. Use Spring Native today to compile your Spring Boot application to native executable
  • 60. Spring Boot 3.x AOT optimizations and native support will benefit to millions of Spring Boot applications
  • 61. Thank you Contact me at @sdeleuze on Twitter © 2021 Spring. A VMware-backed project.