-
Enhancement
-
Resolution: Fixed
-
P4
-
8, 9
-
b04
-
x86
-
linux
A DESCRIPTION OF THE REQUEST :
We have a load test for digital signature, we found that the CPU can not be fully utilized. After reviewing the thread dump we found that when you create a String with the constructor "String(bytes[])", it will try to decode the string with CoderResult, then CoderResult.Cache.get() will often block threads. Can we replace this with a lock-free cache? Another problem is that since CoderResult is very small, I don't think we really need a WeakReference to wrap it.
Below is the stack dump:
"catalina-exec-325" #26395 daemon prio=5 os_prio=0 tid=0x00007f56a012a000 nid=0x2347 waiting for monitor entry [0x00007f53dbc7a000]
java.lang.Thread.State: BLOCKED (on object monitor)
at java.nio.charset.CoderResult$Cache.get(CoderResult.java:201)
- waiting to lock <0x00000005c0e89b58> (a java.nio.charset.CoderResult$1)
at java.nio.charset.CoderResult$Cache.access$200(CoderResult.java:194)
at java.nio.charset.CoderResult.malformedForLength(CoderResult.java:236)
at sun.nio.cs.UTF_8$Decoder.malformedN(UTF_8.java:147)
at sun.nio.cs.UTF_8$Decoder.decode(UTF_8.java:473)
at java.lang.StringCoding$StringDecoder.decode(StringCoding.java:153)
at java.lang.StringCoding.decode(StringCoding.java:193)
at java.lang.StringCoding.decode(StringCoding.java:254)
at java.lang.String.<init>(String.java:546)
at java.lang.String.<init>(String.java:566)
JUSTIFICATION :
In web servers or string processing applications, you will often create a lot of Strings from bytes, the synchronized block has become a bottleneck in our benchmark. Optimizing this part of code can benefit a lot of applications with bytes/string processing.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Replace the synchronized cache method with a better cache implementation.
We have a load test for digital signature, we found that the CPU can not be fully utilized. After reviewing the thread dump we found that when you create a String with the constructor "String(bytes[])", it will try to decode the string with CoderResult, then CoderResult.Cache.get() will often block threads. Can we replace this with a lock-free cache? Another problem is that since CoderResult is very small, I don't think we really need a WeakReference to wrap it.
Below is the stack dump:
"catalina-exec-325" #26395 daemon prio=5 os_prio=0 tid=0x00007f56a012a000 nid=0x2347 waiting for monitor entry [0x00007f53dbc7a000]
java.lang.Thread.State: BLOCKED (on object monitor)
at java.nio.charset.CoderResult$Cache.get(CoderResult.java:201)
- waiting to lock <0x00000005c0e89b58> (a java.nio.charset.CoderResult$1)
at java.nio.charset.CoderResult$Cache.access$200(CoderResult.java:194)
at java.nio.charset.CoderResult.malformedForLength(CoderResult.java:236)
at sun.nio.cs.UTF_8$Decoder.malformedN(UTF_8.java:147)
at sun.nio.cs.UTF_8$Decoder.decode(UTF_8.java:473)
at java.lang.StringCoding$StringDecoder.decode(StringCoding.java:153)
at java.lang.StringCoding.decode(StringCoding.java:193)
at java.lang.StringCoding.decode(StringCoding.java:254)
at java.lang.String.<init>(String.java:546)
at java.lang.String.<init>(String.java:566)
JUSTIFICATION :
In web servers or string processing applications, you will often create a lot of Strings from bytes, the synchronized block has become a bottleneck in our benchmark. Optimizing this part of code can benefit a lot of applications with bytes/string processing.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Replace the synchronized cache method with a better cache implementation.
- duplicates
-
JDK-8198273 java fails to start with EUC_JP locale
-
- Closed
-
- relates to
-
JDK-8198966 To make CoderResult.Cache.cache final and allocate it eagerly.
-
- Resolved
-
-
JDK-6795533 Simplfy CoderResult cache
-
- Open
-