Author: stack Date: Thu Apr 15 04:16:21 2010 New Revision: 934285 URL: http://svn.apache.org/viewvc?rev=934285&view=rev Log: HBASE-1892 [performance] make hbase splits run faster
Modified: hadoop/hbase/trunk/CHANGES.txt hadoop/hbase/trunk/core/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java hadoop/hbase/trunk/core/src/main/resources/hbase-default.xml Modified: hadoop/hbase/trunk/CHANGES.txt URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/CHANGES.txt?rev=934285&r1=934284&r2=934285&view=diff ============================================================================== --- hadoop/hbase/trunk/CHANGES.txt (original) +++ hadoop/hbase/trunk/CHANGES.txt Thu Apr 15 04:16:21 2010 @@ -506,6 +506,7 @@ Release 0.21.0 - Unreleased HBASE-2440 Master UI should check against known bad JDK versions and warn the user (Todd Lipcon via Stack) HBASE-2430 Disable frag display in trunk, let HBASE-2165 replace it + HBASE-1892 [performance] make hbase splits run faster NEW FEATURES HBASE-1961 HBase EC2 scripts Modified: hadoop/hbase/trunk/core/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/core/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java?rev=934285&r1=934284&r2=934285&view=diff ============================================================================== --- hadoop/hbase/trunk/core/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java (original) +++ hadoop/hbase/trunk/core/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java Thu Apr 15 04:16:21 2010 @@ -468,13 +468,14 @@ public class HRegion implements HConstan LOG.warn("region " + this + " already closed"); return null; } - this.closing.set(true); synchronized (splitLock) { + boolean wasFlushing = false; synchronized (writestate) { // Disable compacting and flushing by background threads for this // region. writestate.writesEnabled = false; - LOG.debug("Closing " + this + ": compactions & flushes disabled "); + wasFlushing = writestate.flushing; + LOG.debug("Closing " + this + ": disabling compactions & flushes"); while (writestate.compacting || writestate.flushing) { LOG.debug("waiting for" + (writestate.compacting ? " compaction" : "") + @@ -488,7 +489,15 @@ public class HRegion implements HConstan } } } + // If we were not just flushing, is it worth doing a preflush...one + // that will clear out of the bulk of the memstore before we put up + // the close flag? + if (!abort && !wasFlushing && worthPreFlushing()) { + LOG.info("Running close preflush of " + this.getRegionNameAsString()); + internalFlushcache(); + } newScannerLock.writeLock().lock(); + this.closing.set(true); try { splitsAndClosesLock.writeLock().lock(); LOG.debug("Updates disabled for region, no outstanding scanners on " + @@ -521,6 +530,14 @@ public class HRegion implements HConstan } } + /** + * @return True if its worth doing a flush before we put up the close flag. + */ + private boolean worthPreFlushing() { + return this.memstoreSize.get() > + this.conf.getLong("hbase.hregion.preclose.flush.size", 1024 * 1024 * 5); + } + ////////////////////////////////////////////////////////////////////////////// // HRegion accessors ////////////////////////////////////////////////////////////////////////////// Modified: hadoop/hbase/trunk/core/src/main/resources/hbase-default.xml URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/core/src/main/resources/hbase-default.xml?rev=934285&r1=934284&r2=934285&view=diff ============================================================================== --- hadoop/hbase/trunk/core/src/main/resources/hbase-default.xml (original) +++ hadoop/hbase/trunk/core/src/main/resources/hbase-default.xml Thu Apr 15 04:16:21 2010 @@ -313,6 +313,21 @@ </description> </property> <property> + <name>hbase.hregion.preclose.flush.size</name> + <value>5242880</value> + <description> + If the memstores in a region are this size or larger when we go + to close, run a "pre-flush" to clear out memstores before we put up + the region closed flag and take the region offline. On close, + a flush is run under the close flag up to empty memory. During + this time the region is offline and we are not taking on any writes. + If the memstore content large, this flush could take a long time to + complete. The preflush is meant to clean out the bulk of the memstore + before putting up the close flag and taking the region offline so the + flush that runs under the close flag has little to do. + </description> + </property> + <property> <name>hbase.hregion.memstore.block.multiplier</name> <value>2</value> <description>