-
Bug
-
Resolution: Fixed
-
P4
-
7
-
b32
-
x86
-
linux
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8072305 | 7u85 | Naoto Sato | P4 | Resolved | Fixed | b01 |
JDK-8058949 | 7u80 | Robert Mckenna | P4 | Resolved | Fixed | b03 |
FULL PRODUCT VERSION :
java version "1.7.0_01"
Java(TM) SE Runtime Environment (build 1.7.0_01-b08)
Java HotSpot(TM) 64-Bit Server VM (build 21.1-b02, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux 2.6.18-274.3.1.e15 x86_64
EXTRA RELEVANT SYSTEM CONFIGURATION :
multi-threaded (~50 thead) process with high throughput
A DESCRIPTION OF THE PROBLEM :
When you call String.format("%s.%s", s1, s2), where s1 and s2 are any string, this ends up entering a synchronized block on a static object (instances) in java.util.Currency and can block all threads in the system doing the same thing. This somewhat antisocial thread policy is not documented.
REGRESSION. Last worked in version 6u29
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Just set up lots of threads doing a String.format() and watch it using jvisualvm on the Threads tab
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I do not expect String.format() to ever need to block, as there is no indication that there is any requirement for it to have any state.
ACTUAL -
JVM-wide monitor locks,severely limiting throughput.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package bnpp.xiphias.lvc;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
public class Locker {
public static void main(String... args) {
Locker locker = new Locker();
locker.execute();
}
private void execute() {
final ScheduledExecutorService executor = Executors.newScheduledThreadPool(10);
executor.execute(new Runnable() {
public void run() {
while (true) {
executor.submit(newTask());
}
}
});
try {
Thread.sleep(120000);
} catch(InterruptedException ie) {
} finally {
executor.shutdown();
}
}
private Runnable newTask() {
return new Runnable() {
@Override
public void run() {
String.format("%s.%s", "a", "b");
}
};
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Do not use String.format(), which is not exactly an easy thing to achieve with a vast existing code-base
java version "1.7.0_01"
Java(TM) SE Runtime Environment (build 1.7.0_01-b08)
Java HotSpot(TM) 64-Bit Server VM (build 21.1-b02, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux 2.6.18-274.3.1.e15 x86_64
EXTRA RELEVANT SYSTEM CONFIGURATION :
multi-threaded (~50 thead) process with high throughput
A DESCRIPTION OF THE PROBLEM :
When you call String.format("%s.%s", s1, s2), where s1 and s2 are any string, this ends up entering a synchronized block on a static object (instances) in java.util.Currency and can block all threads in the system doing the same thing. This somewhat antisocial thread policy is not documented.
REGRESSION. Last worked in version 6u29
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Just set up lots of threads doing a String.format() and watch it using jvisualvm on the Threads tab
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I do not expect String.format() to ever need to block, as there is no indication that there is any requirement for it to have any state.
ACTUAL -
JVM-wide monitor locks,severely limiting throughput.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package bnpp.xiphias.lvc;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
public class Locker {
public static void main(String... args) {
Locker locker = new Locker();
locker.execute();
}
private void execute() {
final ScheduledExecutorService executor = Executors.newScheduledThreadPool(10);
executor.execute(new Runnable() {
public void run() {
while (true) {
executor.submit(newTask());
}
}
});
try {
Thread.sleep(120000);
} catch(InterruptedException ie) {
} finally {
executor.shutdown();
}
}
private Runnable newTask() {
return new Runnable() {
@Override
public void run() {
String.format("%s.%s", "a", "b");
}
};
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Do not use String.format(), which is not exactly an easy thing to achieve with a vast existing code-base
- backported by
-
JDK-8058949 JVM wide monitor lock in Currency.getInstance(String)
-
- Resolved
-
-
JDK-8072305 JVM wide monitor lock in Currency.getInstance(String)
-
- Resolved
-
- duplicates
-
JDK-7011025 java.util.Currency.getInstance(String currencyCode) could perform much better
-
- Closed
-
- relates to
-
JDK-7156459 Remove unnecessary get() from Currency.getInstance()
-
- Resolved
-