简体   繁体   English

spring 如何在没有 jvm 的情况下原生运行

[英]how spring native run without jvm

How Spring native can run an application coded in java without JVM, fromhttps://spring.io/blog/2021/03/11/announcing-spring-native-beta : How Spring native can run an application coded in java without JVM, fromhttps://spring.io/blog/2021/03/11/announcing-spring-native-beta :

In practice, that means that in addition to the regular Java Virtual Machine supported by Spring since its inception, we are adding beta support for compiling Spring applications to native images with GraalVM in order to provide a new way to deploy Spring applications. In practice, that means that in addition to the regular Java Virtual Machine supported by Spring since its inception, we are adding beta support for compiling Spring applications to native images with GraalVM in order to provide a new way to deploy Spring applications. Java and Kotlin are supported.支持 Java 和 Kotlin。

Those native Spring applications can be deployed as a standalone executable (no JVM installation required) and offer interesting characteristics including almost instant startup (typically < 100ms), instant peak performance and lower memory consumption at the cost of longer build times and fewer runtime optimizations than the JVM.这些本机 Spring 应用程序可以部署为独立的可执行文件(无需安装 JVM)并提供有趣的特性,包括几乎即时启动(通常小于 100 毫秒)、即时峰值性能以及比运行时更少的 ZCD69B4957F06CD8D69B4957F06CD88D818D7BF3D 和 218D7BF3D61908 更长的构建时间消耗更少的优化消耗JVM。

What means by "at the cost of longer build times and fewer runtime optimizations than the JVM" “以比 JVM 更长的构建时间和更少的运行时优化为代价”是什么意思

What means by "at the cost of longer build times and fewer runtime optimizations than the JVM"[?] “以比 JVM 更长的构建时间和更少的运行时优化为代价”[?]

Two things两件事情

  1. Creating a native image takes considerably longer than compiling into class files.创建本机映像比编译成 class 文件花费的时间要长得多。 I didn't measure it exactly, but I'd say something that needs a few seconds to compile into a class files takes ~5 min to compile into a native image.我没有准确测量它,但我想说一些需要几秒钟才能编译成 class 文件的东西需要大约 5 分钟才能编译成本机映像。

  2. Optimisations happen at compile time.优化发生在编译时。 They therefore cannot take into account dynamic behaviour.因此,它们不能考虑动态行为。 A normal JVM looks at the actual execution of code, tries optimisations and actually measures if they are effective.一个普通的 JVM 查看代码的实际执行,尝试优化并实际测量它们是否有效。 This can't be done at compile time and isn't done at run time.这不能在编译时完成,也不能在运行时完成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM