java - jlink 选项 compress 有什么作用?

标签 java java-9 jlink

jlink 压缩选项有什么作用? oracle 文档对此没有详细说明:

Enable compression of resources:

0: No compression
1: Constant string sharing
2: ZIP

压缩的资源是什么? --compress=2 有什么缺点吗?

最佳答案

--compress=2 有什么缺点吗

我不知道 compress=2 是如何在内部压缩模块的,也不知道哪些模块将有针对性地压缩 pin,但我发现了这个与性能相关的错误

Performance data/impact for users to determine what jlink optimization should be selected

--strip-debug is enabled by default in the build for JRE images, and reduces size of the runtime image (lib/modules) by ~20% (130M -> 106M) with no effect on startup

--compress=0 drops the size of lib/modules by ~30% (106M -> 69.5M), and actually seems to benefit startup in simple tests (~8 ms improvement on Hello World).

--compress=1 drops the size of lib/modules by ~54% (106M -> 49M), but comes with a penalty to startup (~8ms slowdown on Hello World)

--compress=2 drops the size of lib/modules by ~53% (106M -> 49.5M), but comes with an even greater penalty to startup (~13ms slowdown on Hello World)

In my opinion the numeric level argument to --compress is counter-intuitive and should perhaps be called out explicitly instead (--compress=strings, --compress=zip). Since it appears the two different compression strategies are working against each other it seems that perhaps they should even be mutually exclusive (remove --compress=2).

--compress=0 strikes a balance between improving startup and static footprint, --compress=1 minimizes static footprint at a small penalty to startup time.

关于java - jlink 选项 compress 有什么作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55715624/

相关文章:

java - RGBImageFilter 不影响我的图像

java - spring mvc 与 jpa 中的 Multi-Tenancy 架构

java - 控制已经存在的 ImageJ 实例

java - 如何将额外的文件与 jlink 图像捆绑在一起

Java - Servlet 的默认 contentType

java - 如何将 List 包装为 Jackson 生成的 JSON 中的顶级元素

java - 如何退出 JShell 并返回命令行?

Eclipse/Java9 : how to access internal javafx packages?

Java 9 Eclipse 4.7 可移植导出错误 "resource not found", "Could not find main method from given launch configuration."

java-9 - 如何使用 JLink 命令为 JDK9 应用程序创建跨平台可执行文件