HBASE-3982. Improvements to TestHFileSeek.

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1135709 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Todd Lipcon 2011-06-14 17:17:00 +00:00
parent d8f5be74d7
commit 93038d06aa
2 changed files with 42 additions and 6 deletions

View File

@ -260,6 +260,7 @@ Release 0.91.0 - Unreleased
(Jolly Chen) (Jolly Chen)
HBASE-3961 Add Delete.setWriteToWAL functionality (Bruno Dumon) HBASE-3961 Add Delete.setWriteToWAL functionality (Bruno Dumon)
HBASE-3928 Some potential performance improvements to Bytes/KeyValue HBASE-3928 Some potential performance improvements to Bytes/KeyValue
HBASE-3982 Improvements to TestHFileSeek
TASKS TASKS
HBASE-3559 Move report of split to master OFF the heartbeat channel HBASE-3559 Move report of split to master OFF the heartbeat channel

View File

@ -37,10 +37,12 @@ import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.fs.FSDataOutputStream; import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.RawLocalFileSystem;
import org.apache.hadoop.hbase.HBaseTestingUtility; import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.io.hfile.HFile.Reader; import org.apache.hadoop.hbase.io.hfile.HFile.Reader;
import org.apache.hadoop.hbase.io.hfile.HFile.Writer; import org.apache.hadoop.hbase.io.hfile.HFile.Writer;
import org.apache.hadoop.io.BytesWritable; import org.apache.hadoop.io.BytesWritable;
import org.mortbay.log.Log;
/** /**
* test the performance for seek. * test the performance for seek.
@ -51,6 +53,7 @@ import org.apache.hadoop.io.BytesWritable;
* instead.</p> * instead.</p>
*/ */
public class TestHFileSeek extends TestCase { public class TestHFileSeek extends TestCase {
private static final boolean USE_PREAD = true;
private MyOptions options; private MyOptions options;
private Configuration conf; private Configuration conf;
private Path path; private Path path;
@ -67,6 +70,11 @@ public class TestHFileSeek extends TestCase {
} }
conf = new Configuration(); conf = new Configuration();
if (options.useRawFs) {
conf.setClass("fs.file.impl", RawLocalFileSystem.class, FileSystem.class);
}
conf.setInt("tfile.fs.input.buffer.size", options.fsInputBufferSize); conf.setInt("tfile.fs.input.buffer.size", options.fsInputBufferSize);
conf.setInt("tfile.fs.output.buffer.size", options.fsOutputBufferSize); conf.setInt("tfile.fs.output.buffer.size", options.fsOutputBufferSize);
path = new Path(new Path(options.rootDir), options.file); path = new Path(new Path(options.rootDir), options.file);
@ -161,7 +169,7 @@ public class TestHFileSeek extends TestCase {
KeySampler kSampler = KeySampler kSampler =
new KeySampler(rng, reader.getFirstKey(), reader.getLastKey(), new KeySampler(rng, reader.getFirstKey(), reader.getLastKey(),
keyLenGen); keyLenGen);
HFileScanner scanner = reader.getScanner(false, false); HFileScanner scanner = reader.getScanner(false, USE_PREAD);
BytesWritable key = new BytesWritable(); BytesWritable key = new BytesWritable();
timer.reset(); timer.reset();
timer.start(); timer.start();
@ -250,7 +258,9 @@ public class TestHFileSeek extends TestCase {
// Default writing 10MB. // Default writing 10MB.
long fileSize = 10 * 1024 * 1024; long fileSize = 10 * 1024 * 1024;
long seekCount = 1000; long seekCount = 1000;
long trialCount = 1;
long seed; long seed;
boolean useRawFs = false;
static final int OP_CREATE = 1; static final int OP_CREATE = 1;
static final int OP_READ = 2; static final int OP_READ = 2;
@ -348,15 +358,31 @@ public class TestHFileSeek extends TestCase {
.withDescription( .withDescription(
"specify how many seek operations we perform (requires -x r or -x rw.") "specify how many seek operations we perform (requires -x r or -x rw.")
.create('n'); .create('n');
Option trialCount =
OptionBuilder
.withLongOpt("trials")
.withArgName("n")
.hasArg()
.withDescription(
"specify how many times to run the whole benchmark")
.create('t');
Option useRawFs =
OptionBuilder
.withLongOpt("rawfs")
.withDescription("use raw instead of checksummed file system")
.create();
Option help = Option help =
OptionBuilder.withLongOpt("help").hasArg(false).withDescription( OptionBuilder.withLongOpt("help").hasArg(false).withDescription(
"show this screen").create("h"); "show this screen").create("h");
return new Options().addOption(compress).addOption(fileSize).addOption( return new Options().addOption(compress).addOption(fileSize).addOption(
fsInputBufferSz).addOption(fsOutputBufferSize).addOption(keyLen) fsInputBufferSz).addOption(fsOutputBufferSize).addOption(keyLen)
.addOption(blockSz).addOption(rootDir).addOption(valueLen).addOption( .addOption(blockSz).addOption(rootDir).addOption(valueLen)
operation).addOption(seekCount).addOption(file).addOption(help); .addOption(operation).addOption(seekCount).addOption(file)
.addOption(trialCount).addOption(useRawFs).addOption(help);
} }
@ -396,6 +422,10 @@ public class TestHFileSeek extends TestCase {
if (line.hasOption('n')) { if (line.hasOption('n')) {
seekCount = Integer.parseInt(line.getOptionValue('n')); seekCount = Integer.parseInt(line.getOptionValue('n'));
} }
if (line.hasOption('t')) {
trialCount = Integer.parseInt(line.getOptionValue('t'));
}
if (line.hasOption('k')) { if (line.hasOption('k')) {
IntegerRange ir = IntegerRange.parse(line.getOptionValue('k')); IntegerRange ir = IntegerRange.parse(line.getOptionValue('k'));
@ -440,6 +470,8 @@ public class TestHFileSeek extends TestCase {
throw new ParseException("Unknown action specifier: " + strOp); throw new ParseException("Unknown action specifier: " + strOp);
} }
} }
useRawFs = line.hasOption("rawfs");
proceed = true; proceed = true;
} }
@ -489,8 +521,11 @@ public class TestHFileSeek extends TestCase {
} }
testCase.options = options; testCase.options = options;
testCase.setUp(); for (int i = 0; i < options.trialCount; i++) {
testCase.testSeeks(); Log.info("Beginning trial " + (i+1));
testCase.tearDown(); testCase.setUp();
testCase.testSeeks();
testCase.tearDown();
}
} }
} }