[jbossts-issues] [JBoss JIRA] Reopened: (JBTM-688) TransactionReaper synchronization is a performance bottleneck

Andrew Dinn (JIRA) jira-events at lists.jboss.org
Tue Jan 19 11:14:48 EST 2010


     [ https://jira.jboss.org/jira/browse/JBTM-688?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andrew Dinn reopened JBTM-688:
------------------------------



Should have been closed rejected

> 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
>            Assignee: Andrew Dinn
>
> 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

        


More information about the jbossts-issues mailing list