Fix table_reader_bench and add it to "make"

Summary: Fix table_reader_bench after some interface changes. Add it to make to avoid future breaking

Test Plan: make table_reader_bench and run it with different options.

Reviewers: kailiu, haobo

Reviewed By: haobo

CC: igor, leveldb

Differential Revision: https://reviews.facebook.net/D16107
main
sdong 11 years ago
parent f3ae3d07cc
commit b5140a0361
  1. 2
      Makefile
  2. 18
      table/table_reader_bench.cc

@ -96,7 +96,7 @@ TOOLS = \
blob_store_bench blob_store_bench
PROGRAMS = db_bench signal_test $(TESTS) $(TOOLS) PROGRAMS = db_bench signal_test table_reader_bench $(TESTS) $(TOOLS)
BENCHMARKS = db_bench_sqlite3 db_bench_tree_db table_reader_bench BENCHMARKS = db_bench_sqlite3 db_bench_tree_db table_reader_bench
# The library name is configurable since we are maintaining libraries of both # The library name is configurable since we are maintaining libraries of both

@ -13,6 +13,7 @@
#include "port/atomic_pointer.h" #include "port/atomic_pointer.h"
#include "table/block_based_table_factory.h" #include "table/block_based_table_factory.h"
#include "table/plain_table_factory.h" #include "table/plain_table_factory.h"
#include "table/table_builder.h"
#include "util/histogram.h" #include "util/histogram.h"
#include "util/testharness.h" #include "util/testharness.h"
#include "util/testutil.h" #include "util/testutil.h"
@ -57,12 +58,13 @@ void TableReaderBenchmark(Options& opts, EnvOptions& env_options,
int num_keys2, int num_iter, int prefix_len, int num_keys2, int num_iter, int prefix_len,
bool if_query_empty_keys, bool for_iterator, bool if_query_empty_keys, bool for_iterator,
bool through_db) { bool through_db) {
rocksdb::InternalKeyComparator ikc(opts.comparator);
Slice prefix = Slice(); Slice prefix = Slice();
std::string file_name = test::TmpDir() std::string file_name = test::TmpDir()
+ "/rocksdb_table_reader_benchmark"; + "/rocksdb_table_reader_benchmark";
std::string dbname = test::TmpDir() + "/rocksdb_table_reader_bench_db"; std::string dbname = test::TmpDir() + "/rocksdb_table_reader_bench_db";
ReadOptions ro;
WriteOptions wo; WriteOptions wo;
unique_ptr<WritableFile> file; unique_ptr<WritableFile> file;
Env* env = Env::Default(); Env* env = Env::Default();
@ -71,7 +73,7 @@ void TableReaderBenchmark(Options& opts, EnvOptions& env_options,
Status s; Status s;
if (!through_db) { if (!through_db) {
env->NewWritableFile(file_name, &file, env_options); env->NewWritableFile(file_name, &file, env_options);
tb = opts.table_factory->NewTableBuilder(opts, file.get(), tb = opts.table_factory->NewTableBuilder(opts, ikc, file.get(),
CompressionType::kNoCompression); CompressionType::kNoCompression);
} else { } else {
s = DB::Open(opts, dbname, &db); s = DB::Open(opts, dbname, &db);
@ -102,8 +104,8 @@ void TableReaderBenchmark(Options& opts, EnvOptions& env_options,
Status s = env->NewRandomAccessFile(file_name, &raf, env_options); Status s = env->NewRandomAccessFile(file_name, &raf, env_options);
uint64_t file_size; uint64_t file_size;
env->GetFileSize(file_name, &file_size); env->GetFileSize(file_name, &file_size);
s = opts.table_factory->NewTableReader(opts, env_options, std::move(raf), s = opts.table_factory->NewTableReader(
file_size, &table_reader); opts, env_options, ikc, std::move(raf), file_size, &table_reader);
} }
Random rnd(301); Random rnd(301);
@ -127,9 +129,10 @@ void TableReaderBenchmark(Options& opts, EnvOptions& env_options,
uint64_t start_micros = env->NowMicros(); uint64_t start_micros = env->NowMicros();
port::MemoryBarrier(); port::MemoryBarrier();
if (!through_db) { if (!through_db) {
s = table_reader->Get(ro, key, arg, DummySaveValue, nullptr); s = table_reader->Get(read_options, key, arg, DummySaveValue,
nullptr);
} else { } else {
s = db->Get(ro, key, &result); s = db->Get(read_options, key, &result);
} }
port::MemoryBarrier(); port::MemoryBarrier();
hist.Add(env->NowMicros() - start_micros); hist.Add(env->NowMicros() - start_micros);
@ -237,10 +240,9 @@ int main(int argc, char** argv) {
rocksdb::EnvOptions env_options; rocksdb::EnvOptions env_options;
options.create_if_missing = true; options.create_if_missing = true;
options.compression = rocksdb::CompressionType::kNoCompression; options.compression = rocksdb::CompressionType::kNoCompression;
options.internal_comparator =
new rocksdb::InternalKeyComparator(options.comparator);
if (FLAGS_plain_table) { if (FLAGS_plain_table) {
ro.prefix_seek = true;
options.allow_mmap_reads = true; options.allow_mmap_reads = true;
env_options.use_mmap_reads = true; env_options.use_mmap_reads = true;
tf = new rocksdb::PlainTableFactory(16, (FLAGS_prefix_len == 16) ? 0 : 8, tf = new rocksdb::PlainTableFactory(16, (FLAGS_prefix_len == 16) ? 0 : 8,

Loading…
Cancel
Save