HBASE-16194 Should count in MSLAB chunk allocation into heap size change when adding duplicate cells, addendum

This commit is contained in:
Yu Li 2016-07-11 22:43:26 +08:00
parent 0875c35781
commit 356c130702
4 changed files with 16 additions and 16 deletions

View File

@ -109,8 +109,8 @@ public abstract class AbstractMemStore implements MemStore {
@Override
public long add(Cell cell) {
Cell toAdd = maybeCloneWithAllocator(cell);
boolean useMSLAB = (toAdd != cell);
return internalAdd(toAdd, useMSLAB);
boolean mslabUsed = (toAdd != cell);
return internalAdd(toAdd, mslabUsed);
}
/**
@ -157,8 +157,8 @@ public abstract class AbstractMemStore implements MemStore {
@Override
public long delete(Cell deleteCell) {
Cell toAdd = maybeCloneWithAllocator(deleteCell);
boolean useMSLAB = (toAdd != deleteCell);
long s = internalAdd(toAdd, useMSLAB);
boolean mslabUsed = (toAdd != deleteCell);
long s = internalAdd(toAdd, mslabUsed);
return s;
}
@ -390,11 +390,11 @@ public abstract class AbstractMemStore implements MemStore {
*
* Callers should ensure they already have the read lock taken
* @param toAdd the cell to add
* @param useMSLAB whether using MSLAB
* @param mslabUsed whether using MSLAB
* @return the heap size change in bytes
*/
private long internalAdd(final Cell toAdd, final boolean useMSLAB) {
long s = active.add(toAdd, useMSLAB);
private long internalAdd(final Cell toAdd, final boolean mslabUsed) {
long s = active.add(toAdd, mslabUsed);
setOldestEditTimeToNow();
checkActiveSize();
return s;

View File

@ -197,8 +197,8 @@ class MemStoreCompactor {
// The scanner is doing all the elimination logic
// now we just copy it to the new segment
Cell newKV = result.maybeCloneWithAllocator(c);
boolean useMSLAB = (newKV != c);
result.internalAdd(newKV, useMSLAB);
boolean mslabUsed = (newKV != c);
result.internalAdd(newKV, mslabUsed);
}
kvs.clear();

View File

@ -36,11 +36,11 @@ public class MutableSegment extends Segment {
/**
* Adds the given cell into the segment
* @param cell the cell to add
* @param useMSLAB whether using MSLAB
* @param mslabUsed whether using MSLAB
* @return the change in the heap size
*/
public long add(Cell cell, boolean useMSLAB) {
return internalAdd(cell, useMSLAB);
public long add(Cell cell, boolean mslabUsed) {
return internalAdd(cell, mslabUsed);
}
/**
@ -91,4 +91,4 @@ public class MutableSegment extends Segment {
tagsPresent = true;
}
}
}
}

View File

@ -250,13 +250,13 @@ public abstract class Segment {
return comparator;
}
protected long internalAdd(Cell cell, boolean useMSLAB) {
protected long internalAdd(Cell cell, boolean mslabUsed) {
boolean succ = getCellSet().add(cell);
long s = AbstractMemStore.heapSizeChange(cell, succ);
// If there's already a same cell in the CellSet and we are using MSLAB, we must count in the
// MSLAB allocation size as well, or else there will be memory leak (occupied heap size larger
// than the counted number)
if (!succ && useMSLAB) {
if (!succ && mslabUsed) {
s += getCellLength(cell);
}
updateMetaInfo(cell, s);
@ -309,4 +309,4 @@ public abstract class Segment {
res += "Min ts "+getMinTimestamp()+"; ";
return res;
}
}
}