HBASE-3680 Publish more metrics about mslab; REVERTED

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1196236 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2011-11-01 19:39:20 +00:00
parent 0b9a8701d2
commit d8516489ff
6 changed files with 6 additions and 66 deletions

View File

@ -705,7 +705,6 @@ Release 0.92.0 - Unreleased
HBASE-4603 Uneeded sleep time for tests in
hbase.master.ServerManager#waitForRegionServers (nkeywal)
HBASE-4703 Improvements in tests (nkeywal)
HBASE-3680 Publish more metrics about mslab
TASKS
HBASE-3559 Move report of split to master OFF the heartbeat channel

View File

@ -1289,14 +1289,12 @@ public class HRegionServer implements HRegionInterface, HBaseRPCErrorHandler,
new HDFSBlocksDistribution();
long totalStaticIndexSize = 0;
long totalStaticBloomSize = 0;
long totalMslabWaste = 0;
long tmpfiles;
long tmpindex;
long tmpfilesize;
long tmpbloomsize;
long tmpstaticsize;
long tmpMslabWaste;
String cfname;
// Note that this is a map of Doubles instead of Longs. This is because we
@ -1320,7 +1318,6 @@ public class HRegionServer implements HRegionInterface, HBaseRPCErrorHandler,
tmpfilesize = store.getStorefilesSize();
tmpbloomsize = store.getTotalStaticBloomSize();
tmpstaticsize = store.getTotalStaticIndexSize();
tmpMslabWaste = store.memstore.getMslabWaste();
// Note that there is only one store per CF so setting is safe
cfname = "cf." + store.toString();
@ -1335,14 +1332,11 @@ public class HRegionServer implements HRegionInterface, HBaseRPCErrorHandler,
(store.getMemStoreSize() / (1024.0 * 1024)));
this.incrMap(tempVals, cfname + ".staticIndexSizeKB",
tmpstaticsize / 1024.0);
this.incrMap(tempVals, cfname + ".mslabWasteKB",
tmpMslabWaste / 1024.0);
storefiles += tmpfiles;
storefileIndexSize += tmpindex;
totalStaticIndexSize += tmpstaticsize;
totalStaticBloomSize += tmpbloomsize;
totalMslabWaste += tmpMslabWaste;
}
}
@ -1362,8 +1356,6 @@ public class HRegionServer implements HRegionInterface, HBaseRPCErrorHandler,
(int) (totalStaticIndexSize / 1024));
this.metrics.totalStaticBloomSizeKB.set(
(int) (totalStaticBloomSize / 1024));
this.metrics.totalMslabWasteKB.set(
(int) (totalMslabWaste / 1024));
this.metrics.readRequestsCount.set(readRequestsCount);
this.metrics.writeRequestsCount.set(writeRequestsCount);

View File

@ -136,18 +136,6 @@ public class MemStore implements HeapSize {
}
}
/**
* @return the number of bytes "wasted" by external fragmentation
* in the MSLAB, if configured.
*/
long getMslabWaste() {
if (allocator != null) {
return allocator.getWastedBytes();
} else {
return 0;
}
}
void dump() {
for (KeyValue kv: this.kvset) {
LOG.info(kv);

View File

@ -20,7 +20,6 @@
package org.apache.hadoop.hbase.regionserver;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
import org.apache.hadoop.conf.Configuration;
@ -57,9 +56,7 @@ public class MemStoreLAB {
final static String MAX_ALLOC_KEY = "hbase.hregion.memstore.mslab.max.allocation";
final static int MAX_ALLOC_DEFAULT = 256 * 1024; // allocs bigger than this don't go through allocator
final int maxAlloc;
private final AtomicLong wastedSpace = new AtomicLong();
public MemStoreLAB() {
this(new Configuration());
}
@ -106,35 +103,22 @@ public class MemStoreLAB {
}
}
public long getWastedBytes() {
Chunk cur = curChunk.get();
long ret = wastedSpace.get();
if (cur != null) {
ret += cur.getFreeSpace();
}
return ret;
}
/**
* Try to retire the current chunk if it is still
* <code>c</code>. Postcondition is that curChunk.get()
* != c
*/
private void tryRetireChunk(Chunk c) {
@SuppressWarnings("unused")
boolean weRetiredIt = curChunk.compareAndSet(c, null);
// If the CAS succeeds, that means that we won the race
// to retire the chunk.
// to retire the chunk. We could use this opportunity to
// update metrics on external fragmentation.
//
// If the CAS fails, that means that someone else already
// retired the chunk for us.
if (weRetiredIt) {
// This isn't quite right, since another thread may
// have a small allocation concurrently with our retiring
// the chunk. But it should be very close to right,
// and this is just for metrics.
wastedSpace.addAndGet(c.getFreeSpace());
}
}
/**
* Get the current chunk, or, if there is no current chunk,
* allocate a new one from the JVM.
@ -255,15 +239,6 @@ public class MemStoreLAB {
" allocs=" + allocCount.get() + "waste=" +
(data.length - nextFreeOffset.get());
}
private int getFreeSpace() {
int off = nextFreeOffset.get();
if (off >= 0) {
return data.length - off;
} else {
return 0;
}
}
}
/**

View File

@ -155,9 +155,6 @@ public class RegionServerMetrics implements Updater {
public final MetricsIntValue totalStaticBloomSizeKB =
new MetricsIntValue("totalStaticBloomSizeKB", registry);
/** Total amount of memory wasted by external fragmentation in MSLABs */
public final MetricsIntValue totalMslabWasteKB =
new MetricsIntValue("totalMslabWasteKB", registry);
/**
* HDFS blocks locality index
*/

View File

@ -46,9 +46,7 @@ public class TestMemStoreLAB {
public void testLABRandomAllocation() {
Random rand = new Random();
MemStoreLAB mslab = new MemStoreLAB();
assertEquals(0, mslab.getWastedBytes());
int expectedOff = 0;
int slabsUsed = 0;
byte[] lastBuffer = null;
// 100K iterations by 0-1K alloc -> 50MB expected
// should be reasonable for unit test and also cover wraparound
@ -60,21 +58,12 @@ public class TestMemStoreLAB {
if (alloc.getData() != lastBuffer) {
expectedOff = 0;
lastBuffer = alloc.getData();
slabsUsed++;
}
assertEquals(expectedOff, alloc.getOffset());
assertTrue("Allocation " + alloc + " overruns buffer",
alloc.getOffset() + size <= alloc.getData().length);
expectedOff += size;
}
// maximum waste is 1KB per slab plus
// whatever's left in current slab
long expectedWaste = slabsUsed * 1000 +
(lastBuffer.length - expectedOff);
long waste = mslab.getWastedBytes();
assertTrue("waste should be less than " + expectedWaste +
" but was: " + waste, waste < expectedWaste);
}
@Test