[11u] RFR 8224202: Speed up Properties.load
Aleksey Shipilev
shade at redhat.com
Wed Aug 7 15:03:07 UTC 2019
Original RFE:
https://bugs.openjdk.java.net/browse/JDK-8224202
http://hg.openjdk.java.net/jdk/jdk/rev/cdb107ca16e6
Patch applies cleanly to 11u, but does not compile, because there is no ArraysSupport.newLength
(introduced in 13 with JDK-8223593). So, I had to rewrite that block with:
diff -r 436f75b57855 src/java.base/share/classes/java/util/Properties.java
--- a/src/java.base/share/classes/java/util/Properties.java Thu May 23 18:43:47 2019 +0200
+++ b/src/java.base/share/classes/java/util/Properties.java Wed Aug 07 16:09:07 2019 +0200
@@ -49,5 +49,4 @@
import jdk.internal.misc.SharedSecrets;
import jdk.internal.misc.Unsafe;
-import jdk.internal.util.ArraysSupport;
import jdk.internal.util.xml.PropertiesDefaultHandler;
@@ -568,5 +567,13 @@
lineBuf[len++] = c;
if (len == lineBuf.length) {
- lineBuf = new char[ArraysSupport.newLength(len, 1, len)];
+ int maxLen = Integer.MAX_VALUE - 8; // VM allocation limit
+ int newLen = len*2;
+ if (newLen < 0) { // overflow?
+ newLen = maxLen;
+ }
+ if (newLen > maxLen) { // over VM limit?
+ newLen = maxLen;
+ }
+ lineBuf = new char[newLen];
System.arraycopy(this.lineBuf, 0, lineBuf, 0, len);
this.lineBuf = lineBuf;
It is similar to what we had before, but with VM allocation limit treatment that
ArraysSupport.newLength would give us.
Full 11u webrev:
http://cr.openjdk.java.net/~shade/8224202/webrev.11u.01/
Testing: tier1
--
Thanks,
-Aleksey
More information about the jdk-updates-dev
mailing list