mirror of https://github.com/apache/lucene.git
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:
parent
8c3300e5d5
commit
b6a05b1a23
lucene/src/java/org/apache/lucene/util
|
@ -18,6 +18,7 @@ package org.apache.lucene.util;
|
||||||
*/
|
*/
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import static org.apache.lucene.util.RamUsageEstimator.NUM_BYTES_OBJECT_REF;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class that Posting and PostingVector use to write byte
|
* Class that Posting and PostingVector use to write byte
|
||||||
|
@ -116,7 +117,12 @@ public final class ByteBlockPool {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void nextBuffer() {
|
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();
|
buffer = buffers[1+bufferUpto] = allocator.getByteBlock();
|
||||||
bufferUpto++;
|
bufferUpto++;
|
||||||
|
|
||||||
|
|
|
@ -93,7 +93,13 @@ public final class RecyclingByteBlockAllocator extends ByteBlockPool.Allocator {
|
||||||
@Override
|
@Override
|
||||||
public synchronized void recycleByteBlocks(byte[][] blocks, int start, int end) {
|
public synchronized void recycleByteBlocks(byte[][] blocks, int start, int end) {
|
||||||
final int numBlocks = Math.min(maxBufferedBlocks - freeBlocks, end - start);
|
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;
|
final int stop = start + numBlocks;
|
||||||
for (int i = start; i < stop; i++) {
|
for (int i = start; i < stop; i++) {
|
||||||
freeByteBlocks[freeBlocks++] = blocks[i];
|
freeByteBlocks[freeBlocks++] = blocks[i];
|
||||||
|
|
|
@ -40,6 +40,7 @@ import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.lucene.util.ArrayUtil;
|
import org.apache.lucene.util.ArrayUtil;
|
||||||
|
import org.apache.lucene.util.RamUsageEstimator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finite-state automaton with regular expression operations.
|
* Finite-state automaton with regular expression operations.
|
||||||
|
@ -280,7 +281,9 @@ public class Automaton implements Serializable, Cloneable {
|
||||||
worklist.add(t.to);
|
worklist.add(t.to);
|
||||||
t.to.number = upto;
|
t.to.number = upto;
|
||||||
if (upto == numberedStates.length) {
|
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;
|
numberedStates[upto] = t.to;
|
||||||
upto++;
|
upto++;
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
package org.apache.lucene.util.automaton;
|
package org.apache.lucene.util.automaton;
|
||||||
|
|
||||||
import org.apache.lucene.util.ArrayUtil;
|
import org.apache.lucene.util.ArrayUtil;
|
||||||
|
import org.apache.lucene.util.RamUsageEstimator;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.BitSet;
|
import java.util.BitSet;
|
||||||
|
@ -458,7 +459,9 @@ final public class BasicOperations {
|
||||||
|
|
||||||
public void add(Transition t) {
|
public void add(Transition t) {
|
||||||
if (transitions.length == count) {
|
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;
|
transitions[count++] = t;
|
||||||
}
|
}
|
||||||
|
@ -500,7 +503,9 @@ final public class BasicOperations {
|
||||||
private PointTransitions next(int point) {
|
private PointTransitions next(int point) {
|
||||||
// 1st time we are seeing this point
|
// 1st time we are seeing this point
|
||||||
if (count == points.length) {
|
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];
|
PointTransitions points0 = points[count];
|
||||||
if (points0 == null) {
|
if (points0 == null) {
|
||||||
|
@ -645,7 +650,9 @@ final public class BasicOperations {
|
||||||
final SortedIntSet.FrozenIntSet p = statesSet.freeze(q);
|
final SortedIntSet.FrozenIntSet p = statesSet.freeze(q);
|
||||||
worklist.add(p);
|
worklist.add(p);
|
||||||
if (newStateUpto == newStatesArray.length) {
|
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;
|
newStatesArray[newStateUpto] = q;
|
||||||
q.number = newStateUpto;
|
q.number = newStateUpto;
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
|
|
||||||
package org.apache.lucene.util.automaton;
|
package org.apache.lucene.util.automaton;
|
||||||
import org.apache.lucene.util.ArrayUtil;
|
import org.apache.lucene.util.ArrayUtil;
|
||||||
|
import org.apache.lucene.util.RamUsageEstimator;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -110,7 +111,9 @@ public class State implements Serializable, Comparable<State> {
|
||||||
*/
|
*/
|
||||||
public void addTransition(Transition t) {
|
public void addTransition(Transition t) {
|
||||||
if (numTransitions == transitionsArray.length) {
|
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;
|
transitionsArray[numTransitions++] = t;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ package org.apache.lucene.util.automaton;
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import org.apache.lucene.util.RamUsageEstimator;
|
||||||
import org.apache.lucene.util.ArrayUtil;
|
import org.apache.lucene.util.ArrayUtil;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -298,7 +299,9 @@ final class UTF32ToUTF8 {
|
||||||
private State newUTF8State() {
|
private State newUTF8State() {
|
||||||
State s = new State();
|
State s = new State();
|
||||||
if (utf8StateCount == utf8States.length) {
|
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;
|
utf8States[utf8StateCount] = s;
|
||||||
s.number = utf8StateCount;
|
s.number = utf8StateCount;
|
||||||
|
|
Loading…
Reference in New Issue