Skip to content

Commit b5140a0

Browse files
committed
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
1 parent f3ae3d0 commit b5140a0

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ TOOLS = \
9696
blob_store_bench
9797

9898

99-
PROGRAMS = db_bench signal_test $(TESTS) $(TOOLS)
99+
PROGRAMS = db_bench signal_test table_reader_bench $(TESTS) $(TOOLS)
100100
BENCHMARKS = db_bench_sqlite3 db_bench_tree_db table_reader_bench
101101

102102
# The library name is configurable since we are maintaining libraries of both

table/table_reader_bench.cc

+10-8
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "port/atomic_pointer.h"
1414
#include "table/block_based_table_factory.h"
1515
#include "table/plain_table_factory.h"
16+
#include "table/table_builder.h"
1617
#include "util/histogram.h"
1718
#include "util/testharness.h"
1819
#include "util/testutil.h"
@@ -57,12 +58,13 @@ void TableReaderBenchmark(Options& opts, EnvOptions& env_options,
5758
int num_keys2, int num_iter, int prefix_len,
5859
bool if_query_empty_keys, bool for_iterator,
5960
bool through_db) {
61+
rocksdb::InternalKeyComparator ikc(opts.comparator);
62+
6063
Slice prefix = Slice();
6164

6265
std::string file_name = test::TmpDir()
6366
+ "/rocksdb_table_reader_benchmark";
6467
std::string dbname = test::TmpDir() + "/rocksdb_table_reader_bench_db";
65-
ReadOptions ro;
6668
WriteOptions wo;
6769
unique_ptr<WritableFile> file;
6870
Env* env = Env::Default();
@@ -71,7 +73,7 @@ void TableReaderBenchmark(Options& opts, EnvOptions& env_options,
7173
Status s;
7274
if (!through_db) {
7375
env->NewWritableFile(file_name, &file, env_options);
74-
tb = opts.table_factory->NewTableBuilder(opts, file.get(),
76+
tb = opts.table_factory->NewTableBuilder(opts, ikc, file.get(),
7577
CompressionType::kNoCompression);
7678
} else {
7779
s = DB::Open(opts, dbname, &db);
@@ -102,8 +104,8 @@ void TableReaderBenchmark(Options& opts, EnvOptions& env_options,
102104
Status s = env->NewRandomAccessFile(file_name, &raf, env_options);
103105
uint64_t file_size;
104106
env->GetFileSize(file_name, &file_size);
105-
s = opts.table_factory->NewTableReader(opts, env_options, std::move(raf),
106-
file_size, &table_reader);
107+
s = opts.table_factory->NewTableReader(
108+
opts, env_options, ikc, std::move(raf), file_size, &table_reader);
107109
}
108110

109111
Random rnd(301);
@@ -127,9 +129,10 @@ void TableReaderBenchmark(Options& opts, EnvOptions& env_options,
127129
uint64_t start_micros = env->NowMicros();
128130
port::MemoryBarrier();
129131
if (!through_db) {
130-
s = table_reader->Get(ro, key, arg, DummySaveValue, nullptr);
132+
s = table_reader->Get(read_options, key, arg, DummySaveValue,
133+
nullptr);
131134
} else {
132-
s = db->Get(ro, key, &result);
135+
s = db->Get(read_options, key, &result);
133136
}
134137
port::MemoryBarrier();
135138
hist.Add(env->NowMicros() - start_micros);
@@ -237,10 +240,9 @@ int main(int argc, char** argv) {
237240
rocksdb::EnvOptions env_options;
238241
options.create_if_missing = true;
239242
options.compression = rocksdb::CompressionType::kNoCompression;
240-
options.internal_comparator =
241-
new rocksdb::InternalKeyComparator(options.comparator);
242243

243244
if (FLAGS_plain_table) {
245+
ro.prefix_seek = true;
244246
options.allow_mmap_reads = true;
245247
env_options.use_mmap_reads = true;
246248
tf = new rocksdb::PlainTableFactory(16, (FLAGS_prefix_len == 16) ? 0 : 8,

0 commit comments

Comments
 (0)