Skip to content

Commit

Permalink
Fix table_reader_bench and add it to "make"
Browse files Browse the repository at this point in the history
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
  • Loading branch information
siying committed Feb 13, 2014
1 parent f3ae3d0 commit b5140a0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ TOOLS = \
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

# The library name is configurable since we are maintaining libraries of both
Expand Down
18 changes: 10 additions & 8 deletions table/table_reader_bench.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "port/atomic_pointer.h"
#include "table/block_based_table_factory.h"
#include "table/plain_table_factory.h"
#include "table/table_builder.h"
#include "util/histogram.h"
#include "util/testharness.h"
#include "util/testutil.h"
Expand Down Expand Up @@ -57,12 +58,13 @@ void TableReaderBenchmark(Options& opts, EnvOptions& env_options,
int num_keys2, int num_iter, int prefix_len,
bool if_query_empty_keys, bool for_iterator,
bool through_db) {
rocksdb::InternalKeyComparator ikc(opts.comparator);

Slice prefix = Slice();

std::string file_name = test::TmpDir()
+ "/rocksdb_table_reader_benchmark";
std::string dbname = test::TmpDir() + "/rocksdb_table_reader_bench_db";
ReadOptions ro;
WriteOptions wo;
unique_ptr<WritableFile> file;
Env* env = Env::Default();
Expand All @@ -71,7 +73,7 @@ void TableReaderBenchmark(Options& opts, EnvOptions& env_options,
Status s;
if (!through_db) {
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);
} else {
s = DB::Open(opts, dbname, &db);
Expand Down Expand Up @@ -102,8 +104,8 @@ void TableReaderBenchmark(Options& opts, EnvOptions& env_options,
Status s = env->NewRandomAccessFile(file_name, &raf, env_options);
uint64_t file_size;
env->GetFileSize(file_name, &file_size);
s = opts.table_factory->NewTableReader(opts, env_options, std::move(raf),
file_size, &table_reader);
s = opts.table_factory->NewTableReader(
opts, env_options, ikc, std::move(raf), file_size, &table_reader);
}

Random rnd(301);
Expand All @@ -127,9 +129,10 @@ void TableReaderBenchmark(Options& opts, EnvOptions& env_options,
uint64_t start_micros = env->NowMicros();
port::MemoryBarrier();
if (!through_db) {
s = table_reader->Get(ro, key, arg, DummySaveValue, nullptr);
s = table_reader->Get(read_options, key, arg, DummySaveValue,
nullptr);
} else {
s = db->Get(ro, key, &result);
s = db->Get(read_options, key, &result);
}
port::MemoryBarrier();
hist.Add(env->NowMicros() - start_micros);
Expand Down Expand Up @@ -237,10 +240,9 @@ int main(int argc, char** argv) {
rocksdb::EnvOptions env_options;
options.create_if_missing = true;
options.compression = rocksdb::CompressionType::kNoCompression;
options.internal_comparator =
new rocksdb::InternalKeyComparator(options.comparator);

if (FLAGS_plain_table) {
ro.prefix_seek = true;
options.allow_mmap_reads = true;
env_options.use_mmap_reads = true;
tf = new rocksdb::PlainTableFactory(16, (FLAGS_prefix_len == 16) ? 0 : 8,
Expand Down

0 comments on commit b5140a0

Please sign in to comment.