TransactionReaper synchronization is a performance bottleneck
-------------------------------------------------------------
Key: JBTM-688
URL:
https://jira.jboss.org/jira/browse/JBTM-688
Project: JBoss Transaction Manager
Issue Type: Patch
Security Level: Public (Everyone can see)
Components: JTS
Affects Versions: 4.6.1.CP04
Environment: Linux 32-bit, Sun JDK 6
Reporter: Oleg Nitz
During stress testing I found that threads often massively block on synchronization on
TransactionReaper.class, due to synchronized static methods create() and
transactionReaper() in the TransactionReaper class.
I propose to use "double-checked locking idiom" (see
http://en.wikipedia.org/wiki/Double-checked_locking ) to avoid unnecesary
synchronizations.
My patch follows.
--- TransactionReaper.java.orig 2010-01-04 16:27:21.000000000 +0200
+++ TransactionReaper.java 2010-01-11 17:19:55.000000000 +0200
@@ -1059,7 +1059,7 @@
* Could get priority from environment.
*/
- public static synchronized TransactionReaper create(long checkPeriod)
+ public static TransactionReaper create(long checkPeriod)
{
if (tsLogger.arjLogger.debugAllowed())
{
@@ -1070,6 +1070,10 @@
if (TransactionReaper._theReaper == null)
{
+ synchronized (TransactionReaper.class) {
+ if (TransactionReaper._theReaper == null)
+ {
+
// default to dynamic mode
TransactionReaper._dynamic = true;
@@ -1215,6 +1219,8 @@
_reaperWorkerThread.start();
}
+ }
+ }
return TransactionReaper._theReaper;
}
@@ -1233,7 +1239,7 @@
* If parameter is true then do a create.
*/
- public static synchronized TransactionReaper transactionReaper(
+ public static TransactionReaper transactionReaper(
boolean createReaper)
{
if (createReaper)
@@ -1315,7 +1321,7 @@
*/
private int _zombieMax = 0;
- private static TransactionReaper _theReaper = null;
+ private static volatile TransactionReaper _theReaper = null;
private static ReaperThread _reaperThread = null;
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira