You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by li...@apache.org on 2013/07/22 06:59:31 UTC
svn commit: r1505598 - in
/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase:
HConstants.java regionserver/MemStore.java
Author: liyin
Date: Mon Jul 22 04:59:31 2013
New Revision: 1505598
URL: http://svn.apache.org/r1505598
Log:
[HBASE-3855] Linear reseek fix.
Author: shaneh
Summary:
This fixes the linear reseek by setting a config limit
on how many KVs to search through before falling back to seek.
For details on the issue being address see HBASE-4195, HBASE-3855,
& HBASE-6591.
Test Plan: Bake in shadow
Reviewers: aaiyer, liyintang
Reviewed By: aaiyer
CC: hbase-eng@
Differential Revision: https://phabricator.fb.com/D891527
Task ID: 2491819
Modified:
hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/HConstants.java
hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/MemStore.java
Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/HConstants.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/HConstants.java?rev=1505598&r1=1505597&r2=1505598&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/HConstants.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/HConstants.java Mon Jul 22 04:59:31 2013
@@ -810,6 +810,13 @@ public final class HConstants {
public final static float MSLAB_PCT_LOWER_LIMIT = 0.0f;
public final static float MSLAB_PCT_UPPER_LIMIT = 2.0f;
+
+ /*
+ * Memstore Linear search limit
+ */
+ public final static String MEMSTORE_RESEEK_LINEAR_SEARCH_LIMIT_KEY = "hbase.hregion.memstore.linear.search.limit";
+ public final static int MEMSTORE_RESEEK_LINEAR_SEARCH_LIMIT_DEFAULT = 20;
+
private HConstants() {
// Can't be instantiated with this constructor.
}
Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/MemStore.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/MemStore.java?rev=1505598&r1=1505597&r2=1505598&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/MemStore.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/MemStore.java Mon Jul 22 04:59:31 2013
@@ -581,6 +581,10 @@ public class MemStore implements HeapSiz
volatile MemStoreLAB allocatorAtCreation;
volatile MemStoreLAB snapshotAllocatorAtCreation;
+ // The maximum number of kvs to search linearly before doing a seek
+ private int maxLinearReseeks = conf.getInt(HConstants.MEMSTORE_RESEEK_LINEAR_SEARCH_LIMIT_KEY,
+ HConstants.MEMSTORE_RESEEK_LINEAR_SEARCH_LIMIT_DEFAULT);
+
/*
Some notes...
@@ -614,13 +618,11 @@ public class MemStore implements HeapSiz
this.snapshotAllocatorAtCreation.incScannerCount();
}
- //DebugPrint.println(" MS new@" + hashCode());
}
protected KeyValue getNext(Iterator<KeyValue> it) {
KeyValue ret = null;
long readPoint = MultiVersionConsistencyControl.getThreadReadPoint();
- //DebugPrint.println( " MS@" + hashCode() + ": threadpoint = " + readPoint);
while (ret == null && it.hasNext()) {
KeyValue v = it.next();
@@ -649,14 +651,6 @@ public class MemStore implements HeapSiz
kvsetNextRow = getNext(kvsetIt);
snapshotNextRow = getNext(snapshotIt);
-
- //long readPoint = MultiVersionConsistencyControl.getThreadReadPoint();
- //DebugPrint.println( " MS@" + hashCode() + " kvset seek: " + kvsetNextRow + " with size = " +
- // kvset.size() + " threadread = " + readPoint);
- //DebugPrint.println( " MS@" + hashCode() + " snapshot seek: " + snapshotNextRow + " with size = " +
- // snapshot.size() + " threadread = " + readPoint);
-
-
KeyValue lowest = getLowest();
// has data := (lowest != null)
@@ -664,13 +658,32 @@ public class MemStore implements HeapSiz
}
@Override
- public boolean reseek(KeyValue key) {
- //shaneh Jul-17-2013: Temporary fix while a more efficient reseek is worked on.
- return seek(key);
+ public synchronized boolean reseek(KeyValue key) {
+
+ //Limit the number of kvs to search linearly before triggering a seek.
+ int seeked = 0;
+
+ while (kvsetNextRow != null &&
+ comparator.compare(kvsetNextRow, key) < 0 &&
+ seeked++ < this.maxLinearReseeks) {
+ kvsetNextRow = getNext(kvsetIt);
+ }
+
+ while (snapshotNextRow != null &&
+ comparator.compare(snapshotNextRow, key) < 0 &&
+ seeked++ < this.maxLinearReseeks) {
+ snapshotNextRow = getNext(snapshotIt);
+ }
+
+ // The linear reseek took more than the maximum allowed by config.
+ if (seeked >= this.maxLinearReseeks) {
+ return seek(key);
+ }
+
+ return (kvsetNextRow != null || snapshotNextRow != null);
}
public synchronized KeyValue peek() {
- //DebugPrint.println(" MS@" + hashCode() + " peek = " + getLowest());
return getLowest();
}
@@ -689,9 +702,6 @@ public class MemStore implements HeapSiz
snapshotNextRow = getNext(snapshotIt);
}
- //long readpoint = MultiVersionConsistencyControl.getThreadReadPoint();
- //DebugPrint.println(" MS@" + hashCode() + " next: " + theNext + " next_next: " +
- // getLowest() + " threadpoint=" + readpoint);
return theNext;
}