有些JVM会缓存静态初始化程序的结果,用于常用的库类。

huangapple go评论79阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2020年4月7日 06:59:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/61070262.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定