What does the jlink compress option do? the oracle documentation isn't very elaborated about this:
Enable compression of resources:
0: No compression
1: Constant string sharing
2: ZIP
What are the resources which getting compressed? Is there any disadvantage to --compress=2
?
Is there any disadvantage to --compress=2
I don't know how compress=2
internally compress modules or exactly which modules are going to compress pin pointedly, But i found this bug related to performance
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.
This is purely based on observation. I’d love to see a more authoritative answer.
It appears the lib/modules
file in the resulting image, which is some binary amalgamation of the application’s modules, is what gets compressed. I don’t know what the format of that file actually is.
I have never observed any problems with using --compress=2
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With