英文:
Do some JVMs cache static initializer results, for commonly used library classes
问题
由于JVM启动时间似乎是一个关注点,是否有必要缓存一些更复杂的静态初始化器的结果,比如java.lang.invoke.MethodType
(以及其他具有复杂初始化逻辑的java.lang
类)。JVM在运行一次后,将能够更快地启动。此外,我认为静态初始化器从不包含某些JIT优化,因此某些静态初始化器可能会相当慢。我想缓存只会在纯静态初始化器上起作用,所以任何缓存可能都必须局限于标准库。是否有带有某种静态初始化类缓存的JVM实现?
英文:
Since JVM startup time seems to be a point of concern would it make sense to cache the results of some more complex static initializers, such as java.lang.invoke.MethodType
(and other java.lang
classes which have complex initialization logic). The JVM would then be able to start up more quickly after having run once. Additionally I believe that static initializers never contain certain JIT optimizations, so some static initializers could be quite slow. I imagine caching would only work on pure static initializers, so any caching would probably have to be restricted to the standard library. Are there any JVM implementations with some kind of caching of statically initialized classes?
答案1
得分: 2
可以。例如,GraalVM Native Image 可以在构建时仅初始化特定的类。请参阅 --initialize-at-build-time=
选项。
英文:
Yes. For example, GraalVM Native Image can initialize certain classes just once at build time.
See --initialize-at-build-time=
option.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论