[jboss-svn-commits] JBL Code SVN: r29067 - in labs/jbosstm/branches/JBOSSTS_4_2_3_GA_SP/ArjunaCore/arjuna/classes/com/arjuna/ats: internal/arjuna/coordinator and 1 other directory.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Aug 26 09:20:46 EDT 2009
Author: adinn
Date: 2009-08-26 09:20:46 -0400 (Wed, 26 Aug 2009)
New Revision: 29067
Modified:
labs/jbosstm/branches/JBOSSTS_4_2_3_GA_SP/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/TransactionReaper.java
labs/jbosstm/branches/JBOSSTS_4_2_3_GA_SP/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/coordinator/ReaperElement.java
Log:
backported performance fixes to reaper code fixes for JBTM-614
Modified: labs/jbosstm/branches/JBOSSTS_4_2_3_GA_SP/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/TransactionReaper.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_2_3_GA_SP/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/TransactionReaper.java 2009-08-26 12:56:14 UTC (rev 29066)
+++ labs/jbosstm/branches/JBOSSTS_4_2_3_GA_SP/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/TransactionReaper.java 2009-08-26 13:20:46 UTC (rev 29067)
@@ -349,7 +349,8 @@
_timeouts.put(control, e);
boolean rtn = _transactions.add(e);
- if(_dynamic)
+ // only wake reaper if new element inserted at head
+ if(_dynamic && _transactions.first() == e)
{
notify(); // force recalc of next wakeup time, taking into account the newly inserted element
}
Modified: labs/jbosstm/branches/JBOSSTS_4_2_3_GA_SP/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/coordinator/ReaperElement.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_2_3_GA_SP/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/coordinator/ReaperElement.java 2009-08-26 12:56:14 UTC (rev 29066)
+++ labs/jbosstm/branches/JBOSSTS_4_2_3_GA_SP/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/coordinator/ReaperElement.java 2009-08-26 13:20:46 UTC (rev 29067)
@@ -65,6 +65,9 @@
*/
_absoluteTimeout = timeout * 1000 + System.currentTimeMillis();
+
+ // add additional variation to distinguish instances created in the same millisecond.
+ _bias = getBias();
}
public void finalize()
@@ -92,13 +95,17 @@
ReaperElement other = (ReaperElement)o;
if(_absoluteTimeout == other._absoluteTimeout) {
- if(_control.get_uid().equals(other._control.get_uid())) {
- return 0;
+ if (_bias == other._bias) {
+ if(_control.get_uid().equals(other._control.get_uid())) {
+ return 0;
} else if (_control.get_uid().greaterThan(other._control.get_uid())) {
- return 1;
- } else {
- return -1;
- }
+ return 1;
+ } else {
+ return -1;
+ }
+ } else {
+ return (_bias > other._bias) ? 1 : -1;
+ }
} else {
return (_absoluteTimeout > other._absoluteTimeout) ? 1 : -1;
}
@@ -107,6 +114,23 @@
public Reapable _control;
public long _absoluteTimeout;
+ private int _bias;
+ // bias is used to distinguish/sort instances with the same
+ // _absoluteTimeoutMills as using Uid for this purpose is
+ // expensive. JBTM-611
+
+ private static int biasCounter = 0;
+
+ public static synchronized int getBias()
+ {
+ if(biasCounter >= 1000000-1) {
+ biasCounter = 0;
+ } else {
+ biasCounter++;
+ }
+ return biasCounter;
+ }
+
public int _timeout;
}
More information about the jboss-svn-commits
mailing list