LUCENE-2792: revert slowdowns on -client vms that are unrelated to this issue

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1045012 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2010-12-13 03:32:09 +00:00
parent 8c3300e5d5
commit b6a05b1a23
6 changed files with 36 additions and 8 deletions

View File

@ -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++;

View File

@ -93,7 +93,13 @@ public final class RecyclingByteBlockAllocator extends ByteBlockPool.Allocator {
@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];

View File

@ -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 Serializable, Cloneable {
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++;

View File

@ -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;

View File

@ -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 Serializable, Comparable<State> {
*/
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;
}

View File

@ -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;