db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r1327682 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/sql/catalog/SequenceRange.java testing/org/apache/derbyTesting/functionTests/tests/lang/SequenceGeneratorTest.java
Date Wed, 18 Apr 2012 21:06:04 GMT
Author: rhillegas
Date: Wed Apr 18 21:06:04 2012
New Revision: 1327682

URL: http://svn.apache.org/viewvc?rev=1327682&view=rev
Log:
DERBY-5493: Boost the size of preallocated sequence ranges from 20 to 100 in order to boost
concurrency.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/SequenceRange.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/SequenceGeneratorTest.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/SequenceRange.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/SequenceRange.java?rev=1327682&r1=1327681&r2=1327682&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/SequenceRange.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/SequenceRange.java Wed
Apr 18 21:06:04 2012
@@ -38,10 +38,11 @@ public  class   SequenceRange   implemen
     ///////////////////////////////////////////////////////////////////////////////////
 
     /**
-     * Default number of values to pre-allocate. This is the size of the preallocation range
-     * used by other databases. See DERBY-4437.
+     * Default number of values to pre-allocate. Other databases use a preallocation size
+     * of 20 (see DERBY-4437). We boosted this to 100 in order to get better concurrency,
+     * after fixing correctness problems in pre-allocation (see DERBY-5493).
      */
-    private static final int DEFAULT_PREALLOCATION_COUNT = 20;
+    private static final int DEFAULT_PREALLOCATION_COUNT = 100;
 
     ///////////////////////////////////////////////////////////////////////////////////
     //

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/SequenceGeneratorTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/SequenceGeneratorTest.java?rev=1327682&r1=1327681&r2=1327682&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/SequenceGeneratorTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/SequenceGeneratorTest.java
Wed Apr 18 21:06:04 2012
@@ -61,7 +61,7 @@ public class SequenceGeneratorTest  exte
     ///////////////////////////////////////////////////////////////////////////////////
 
     // number of pre-allocated values in a sequence generator
-    private static final long ALLOCATION_COUNT = 20L;
+    private static final long ALLOCATION_COUNT = 100L;
     private static final int TWEAKED_ALLOCATION_COUNT = 7;
 
     private static  final   String      TEST_DBO = "TEST_DBO";
@@ -217,13 +217,20 @@ public class SequenceGeneratorTest  exte
          )
         throws Exception
     {
-        long biggestStep = 2 * ALLOCATION_COUNT;
-        
-        for ( long i = 1L; i <= biggestStep; i++ )
-        {
-            vetUpperBoundary( maxValue, minValue, i );
-            vetLowerBoundary( maxValue, minValue, i );
-        }
+        vetBoundaries( maxValue, minValue, 1L );
+        vetBoundaries( maxValue, minValue, ALLOCATION_COUNT );
+        vetBoundaries( maxValue, minValue, 2 * ALLOCATION_COUNT );
+    }
+    private void vetBoundaries
+        (
+         long maxValue,
+         long minValue,
+         long stepSize
+         )
+        throws Exception
+    {
+        vetUpperBoundary( maxValue, minValue, stepSize );
+        vetLowerBoundary( maxValue, minValue, stepSize );
     }
     private void vetUpperBoundary
         (
@@ -237,12 +244,12 @@ public class SequenceGeneratorTest  exte
         long firstValue;
 
         long initValue = maxValue - (ALLOCATION_COUNT * stepSize);
+        long finalValue = maxValue;
+        long midpoint = (finalValue - initValue) / 2;
 
-        for ( long i = initValue; (i > 0) && (i <= maxValue); i++ )
-        {
-            firstValue = i;
-            vetBoundaries( maxValue, minValue, stepSize, firstValue, restartValue );
-        }
+        if ( initValue > 0 ) { vetBoundaries( maxValue, minValue, stepSize, initValue,
restartValue ); }
+        if ( midpoint > 0 ) { vetBoundaries( maxValue, minValue, stepSize, midpoint, restartValue
); }
+        if ( finalValue > 0 ) { vetBoundaries( maxValue, minValue, stepSize, finalValue,
restartValue ); }
     }
     private void vetLowerBoundary
         (
@@ -256,12 +263,12 @@ public class SequenceGeneratorTest  exte
         long firstValue;
 
         long initValue = minValue + (ALLOCATION_COUNT * stepSize);
+        long finalValue = minValue;
+        long midpoint = (finalValue - initValue) / 2;
 
-        for ( long i = initValue; (i < 0) && (i >= minValue); i-- )
-        {
-            firstValue = i;
-            vetBoundaries( maxValue, minValue, -stepSize, firstValue, restartValue );
-        }
+        if ( initValue < 0 ) { vetBoundaries( maxValue, minValue, -stepSize, initValue,
restartValue ); }
+        if ( midpoint < 0 ) { vetBoundaries( maxValue, minValue, -stepSize, midpoint,
restartValue ); }
+        if ( finalValue < 0 ) { vetBoundaries( maxValue, minValue, -stepSize, finalValue,
restartValue ); }
     }
     private void vetBoundaries
         (



Mime
View raw message