tomcat icon indicating copy to clipboard operation
tomcat copied to clipboard

Issue 66195 observe mr jar system property

Open nobeh opened this issue 3 years ago • 4 comments

Observe if system property for MR JAR is available

- Check if the JVM system property for MR-JAR is set
- If set, parse the value as a boolean
- If set, and when `#isMultiRelease()` is invoked, return the configured
  value

Refs #66195

nobeh avatar Aug 02 '22 10:08 nobeh

https://bz.apache.org/bugzilla/show_bug.cgi?id=66195

nobeh avatar Aug 02 '22 10:08 nobeh

Hi @nobeh ,

The JarFile#isMultiRelease method itself already implements the relevant logic, so we don't need to do anything extra with this property. In addition, we know from the documentation that the value of the jdk.util.jar.enableMultiRelease property is not just of the boolean type, but may also be force. So your implementation is also faulty.

aooohan avatar Aug 02 '22 14:08 aooohan

already implements the relevant logic, so we don't need to do anything extra with this property

Yes, that's correct. However, Tomcat uses a "MethodHandle" invocation to call that method. When a system is under load, through profiling, we've observed that invoking the method handle to evaluate to false could actually be an expensive operation. This is one of the main motivations for this change.

but may also be force

Yes. Thanks for the catch. I will update this.

nobeh avatar Aug 03 '22 10:08 nobeh

to evaluate to false could actually be an expensive operation. This is one of the main motivations for this change.

And the root cause for that is because of a synchronized block:

https://github.com/openjdk/jdk/blob/jdk-11%2B28/src/java.base/share/classes/java/util/jar/JarFile.java#L999

nobeh avatar Aug 03 '22 10:08 nobeh

The sync block won't be reached: https://github.com/openjdk/jdk/blob/jdk-11%2B28/src/java.base/share/classes/java/util/jar/JarFile.java#L382

The case hasn't been made that this change is necessary nor has any evidence been provided of a genuine performance improvement.

markt-asf avatar Aug 15 '22 10:08 markt-asf