lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rm...@apache.org
Subject svn commit: r1045012 - in /lucene/dev/trunk/lucene/src/java/org/apache/lucene/util: ByteBlockPool.java RecyclingByteBlockAllocator.java automaton/Automaton.java automaton/BasicOperations.java automaton/State.java automaton/UTF32ToUTF8.java
Date Mon, 13 Dec 2010 03:32:10 GMT
Author: rmuir
Date: Mon Dec 13 03:32:09 2010
New Revision: 1045012

URL: http://svn.apache.org/viewvc?rev=1045012&view=rev
Log:
LUCENE-2792: revert slowdowns on -client vms that are unrelated to this issue

Modified:
    lucene/dev/trunk/lucene/src/java/org/apache/lucene/util/ByteBlockPool.java
    lucene/dev/trunk/lucene/src/java/org/apache/lucene/util/RecyclingByteBlockAllocator.java
    lucene/dev/trunk/lucene/src/java/org/apache/lucene/util/automaton/Automaton.java
    lucene/dev/trunk/lucene/src/java/org/apache/lucene/util/automaton/BasicOperations.java
    lucene/dev/trunk/lucene/src/java/org/apache/lucene/util/automaton/State.java
    lucene/dev/trunk/lucene/src/java/org/apache/lucene/util/automaton/UTF32ToUTF8.java

Modified: lucene/dev/trunk/lucene/src/java/org/apache/lucene/util/ByteBlockPool.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/java/org/apache/lucene/util/ByteBlockPool.java?rev=1045012&r1=1045011&r2=1045012&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/util/ByteBlockPool.java (original)
+++ lucene/dev/trunk/lucene/src/java/org/apache/lucene/util/ByteBlockPool.java Mon Dec 13
03:32:09 2010
@@ -18,6 +18,7 @@ package org.apache.lucene.util;
  */
 import java.util.Arrays;
 import java.util.List;
+import static org.apache.lucene.util.RamUsageEstimator.NUM_BYTES_OBJECT_REF;
 
 /** 
  * Class that Posting and PostingVector use to write byte
@@ -116,7 +117,12 @@ public final class ByteBlockPool {
   }
 
   public void nextBuffer() {
-    buffers = ArrayUtil.grow(buffers, 2+bufferUpto);
+    if (1+bufferUpto == buffers.length) {
+      byte[][] newBuffers = new byte[ArrayUtil.oversize(buffers.length+1,
+                                                        NUM_BYTES_OBJECT_REF)][];
+      System.arraycopy(buffers, 0, newBuffers, 0, buffers.length);
+      buffers = newBuffers;
+    }
     buffer = buffers[1+bufferUpto] = allocator.getByteBlock();
     bufferUpto++;
 

Modified: lucene/dev/trunk/lucene/src/java/org/apache/lucene/util/RecyclingByteBlockAllocator.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/java/org/apache/lucene/util/RecyclingByteBlockAllocator.java?rev=1045012&r1=1045011&r2=1045012&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/util/RecyclingByteBlockAllocator.java
(original)
+++ lucene/dev/trunk/lucene/src/java/org/apache/lucene/util/RecyclingByteBlockAllocator.java
Mon Dec 13 03:32:09 2010
@@ -93,7 +93,13 @@ public final class RecyclingByteBlockAll
   @Override
   public synchronized void recycleByteBlocks(byte[][] blocks, int start, int end) {
     final int numBlocks = Math.min(maxBufferedBlocks - freeBlocks, end - start);
-    freeByteBlocks = ArrayUtil.grow(freeByteBlocks, freeBlocks + numBlocks);
+    final int size = freeBlocks + numBlocks;
+    if (size >= freeByteBlocks.length) {
+      final byte[][] newBlocks = new byte[ArrayUtil.oversize(size,
+          RamUsageEstimator.NUM_BYTES_OBJECT_REF)][];
+      System.arraycopy(freeByteBlocks, 0, newBlocks, 0, freeBlocks);
+      freeByteBlocks = newBlocks;
+    }
     final int stop = start + numBlocks;
     for (int i = start; i < stop; i++) {
       freeByteBlocks[freeBlocks++] = blocks[i];

Modified: lucene/dev/trunk/lucene/src/java/org/apache/lucene/util/automaton/Automaton.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/java/org/apache/lucene/util/automaton/Automaton.java?rev=1045012&r1=1045011&r2=1045012&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/util/automaton/Automaton.java (original)
+++ lucene/dev/trunk/lucene/src/java/org/apache/lucene/util/automaton/Automaton.java Mon Dec
13 03:32:09 2010
@@ -40,6 +40,7 @@ import java.util.List;
 import java.util.Set;
 
 import org.apache.lucene.util.ArrayUtil;
+import org.apache.lucene.util.RamUsageEstimator;
 
 /**
  * Finite-state automaton with regular expression operations.
@@ -280,7 +281,9 @@ public class Automaton implements Serial
             worklist.add(t.to);
             t.to.number = upto;
             if (upto == numberedStates.length) {
-              numberedStates = ArrayUtil.grow(numberedStates);
+              final State[] newArray = new State[ArrayUtil.oversize(1+upto, RamUsageEstimator.NUM_BYTES_OBJECT_REF)];
+              System.arraycopy(numberedStates, 0, newArray, 0, upto);
+              numberedStates = newArray;
             }
             numberedStates[upto] = t.to;
             upto++;

Modified: lucene/dev/trunk/lucene/src/java/org/apache/lucene/util/automaton/BasicOperations.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/java/org/apache/lucene/util/automaton/BasicOperations.java?rev=1045012&r1=1045011&r2=1045012&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/util/automaton/BasicOperations.java
(original)
+++ lucene/dev/trunk/lucene/src/java/org/apache/lucene/util/automaton/BasicOperations.java
Mon Dec 13 03:32:09 2010
@@ -30,6 +30,7 @@
 package org.apache.lucene.util.automaton;
 
 import org.apache.lucene.util.ArrayUtil;
+import org.apache.lucene.util.RamUsageEstimator;
 
 import java.util.ArrayList;
 import java.util.BitSet;
@@ -458,7 +459,9 @@ final public class BasicOperations {
 
     public void add(Transition t) {
       if (transitions.length == count) {
-        transitions = ArrayUtil.grow(transitions);
+        Transition[] newArray = new Transition[ArrayUtil.oversize(1+count, RamUsageEstimator.NUM_BYTES_OBJECT_REF)];
+        System.arraycopy(transitions, 0, newArray, 0, count);
+        transitions = newArray;
       }
       transitions[count++] = t;
     }
@@ -500,7 +503,9 @@ final public class BasicOperations {
     private PointTransitions next(int point) {
       // 1st time we are seeing this point
       if (count == points.length) {
-        points = ArrayUtil.grow(points);
+        final PointTransitions[] newArray = new PointTransitions[ArrayUtil.oversize(1+count,
RamUsageEstimator.NUM_BYTES_OBJECT_REF)];
+        System.arraycopy(points, 0, newArray, 0, count);
+        points = newArray;
       }
       PointTransitions points0 = points[count];
       if (points0 == null) {
@@ -645,7 +650,9 @@ final public class BasicOperations {
             final SortedIntSet.FrozenIntSet p = statesSet.freeze(q);
             worklist.add(p);
             if (newStateUpto == newStatesArray.length) {
-              newStatesArray = ArrayUtil.grow(newStatesArray);
+              final State[] newArray = new State[ArrayUtil.oversize(1+newStateUpto, RamUsageEstimator.NUM_BYTES_OBJECT_REF)];
+              System.arraycopy(newStatesArray, 0, newArray, 0, newStateUpto);
+              newStatesArray = newArray;
             }
             newStatesArray[newStateUpto] = q;
             q.number = newStateUpto;

Modified: lucene/dev/trunk/lucene/src/java/org/apache/lucene/util/automaton/State.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/java/org/apache/lucene/util/automaton/State.java?rev=1045012&r1=1045011&r2=1045012&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/util/automaton/State.java (original)
+++ lucene/dev/trunk/lucene/src/java/org/apache/lucene/util/automaton/State.java Mon Dec 13
03:32:09 2010
@@ -29,6 +29,7 @@
 
 package org.apache.lucene.util.automaton;
 import org.apache.lucene.util.ArrayUtil;
+import org.apache.lucene.util.RamUsageEstimator;
 
 import java.io.Serializable;
 import java.util.Collection;
@@ -110,7 +111,9 @@ public class State implements Serializab
    */
   public void addTransition(Transition t) {
     if (numTransitions == transitionsArray.length) {
-      transitionsArray = ArrayUtil.grow(transitionsArray);
+      final Transition[] newArray = new Transition[ArrayUtil.oversize(1+numTransitions, RamUsageEstimator.NUM_BYTES_OBJECT_REF)];
+      System.arraycopy(transitionsArray, 0, newArray, 0, numTransitions);
+      transitionsArray = newArray;
     }
     transitionsArray[numTransitions++] = t;
   }

Modified: lucene/dev/trunk/lucene/src/java/org/apache/lucene/util/automaton/UTF32ToUTF8.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/java/org/apache/lucene/util/automaton/UTF32ToUTF8.java?rev=1045012&r1=1045011&r2=1045012&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/util/automaton/UTF32ToUTF8.java (original)
+++ lucene/dev/trunk/lucene/src/java/org/apache/lucene/util/automaton/UTF32ToUTF8.java Mon
Dec 13 03:32:09 2010
@@ -17,6 +17,7 @@ package org.apache.lucene.util.automaton
  * limitations under the License.
  */
 
+import org.apache.lucene.util.RamUsageEstimator;
 import org.apache.lucene.util.ArrayUtil;
 
 import java.util.List;
@@ -298,7 +299,9 @@ final class UTF32ToUTF8 {
   private State newUTF8State() {
     State s = new State();
     if (utf8StateCount == utf8States.length) {
-      utf8States = ArrayUtil.grow(utf8States);
+      final State[] newArray = new State[ArrayUtil.oversize(1+utf8StateCount, RamUsageEstimator.NUM_BYTES_OBJECT_REF)];
+      System.arraycopy(utf8States, 0, newArray, 0, utf8StateCount);
+      utf8States = newArray;
     }
     utf8States[utf8StateCount] = s;
     s.number = utf8StateCount;



Mime
View raw message