mirror of https://github.com/facebook/rocksdb.git
Fix benchmarks under ROCKSDB_LITE
Summary: Fix db_bench and memtablerep_bench under ROCKSDB_LITE Test Plan: OPT=-DROCKSDB_LITE make db_bench -j64 OPT=-DROCKSDB_LITE make memtablerep_bench -j64 make db_bench -j64 make memtablerep_bench -j64 Reviewers: yhchiang, anthony, rven, igor, sdong Reviewed By: sdong Subscribers: dhruba Differential Revision: https://reviews.facebook.net/D48717
This commit is contained in:
parent
e587dbe03a
commit
b81b2ec25d
|
@ -486,6 +486,7 @@ DEFINE_int32(deletepercent, 2, "Percentage of deletes out of reads/writes/"
|
|||
DEFINE_uint64(delete_obsolete_files_period_micros, 0,
|
||||
"Ignored. Left here for backward compatibility");
|
||||
|
||||
#ifndef ROCKSDB_LITE
|
||||
DEFINE_bool(optimistic_transaction_db, false,
|
||||
"Open a OptimisticTransactionDB instance. "
|
||||
"Required for randomtransaction benchmark.");
|
||||
|
@ -509,6 +510,7 @@ DEFINE_int32(transaction_sleep, 0,
|
|||
DEFINE_uint64(transaction_lock_timeout, 100,
|
||||
"If using a transaction_db, specifies the lock wait timeout in"
|
||||
" milliseconds before failing a transaction waiting on a lock");
|
||||
#endif // ROCKSDB_LITE
|
||||
|
||||
DEFINE_bool(compaction_measure_io_stats, false,
|
||||
"Measure times spents on I/Os while in compactions. ");
|
||||
|
@ -645,7 +647,9 @@ DEFINE_int32(max_grandparent_overlap_factor, 10, "Control maximum bytes of "
|
|||
"overlaps in grandparent (i.e., level+2) before we stop building a"
|
||||
" single file in a level->level+1 compaction.");
|
||||
|
||||
#ifndef ROCKSDB_LITE
|
||||
DEFINE_bool(readonly, false, "Run read only benchmarks.");
|
||||
#endif // ROCKSDB_LITE
|
||||
|
||||
DEFINE_bool(disable_auto_compactions, false, "Do not auto trigger compactions");
|
||||
|
||||
|
@ -983,7 +987,9 @@ static void AppendWithSpace(std::string* str, Slice msg) {
|
|||
struct DBWithColumnFamilies {
|
||||
std::vector<ColumnFamilyHandle*> cfh;
|
||||
DB* db;
|
||||
#ifndef ROCKSDB_LITE
|
||||
OptimisticTransactionDB* opt_txn_db;
|
||||
#endif // ROCKSDB_LITE
|
||||
std::atomic<size_t> num_created; // Need to be updated after all the
|
||||
// new entries in cfh are set.
|
||||
size_t num_hot; // Number of column families to be queried at each moment.
|
||||
|
@ -991,7 +997,12 @@ struct DBWithColumnFamilies {
|
|||
// Column families will be created and used to be queried.
|
||||
port::Mutex create_cf_mutex; // Only one thread can execute CreateNewCf()
|
||||
|
||||
DBWithColumnFamilies() : db(nullptr), opt_txn_db(nullptr) {
|
||||
DBWithColumnFamilies()
|
||||
: db(nullptr)
|
||||
#ifndef ROCKSDB_LITE
|
||||
, opt_txn_db(nullptr)
|
||||
#endif // ROCKSDB_LITE
|
||||
{
|
||||
cfh.clear();
|
||||
num_created = 0;
|
||||
num_hot = 0;
|
||||
|
@ -1000,7 +1011,9 @@ struct DBWithColumnFamilies {
|
|||
DBWithColumnFamilies(const DBWithColumnFamilies& other)
|
||||
: cfh(other.cfh),
|
||||
db(other.db),
|
||||
#ifndef ROCKSDB_LITE
|
||||
opt_txn_db(other.opt_txn_db),
|
||||
#endif // ROCKSDB_LITE
|
||||
num_created(other.num_created.load()),
|
||||
num_hot(other.num_hot) {}
|
||||
|
||||
|
@ -1008,13 +1021,18 @@ struct DBWithColumnFamilies {
|
|||
std::for_each(cfh.begin(), cfh.end(),
|
||||
[](ColumnFamilyHandle* cfhi) { delete cfhi; });
|
||||
cfh.clear();
|
||||
#ifndef ROCKSDB_LITE
|
||||
if (opt_txn_db) {
|
||||
delete opt_txn_db;
|
||||
opt_txn_db = nullptr;
|
||||
} else {
|
||||
delete db;
|
||||
db = nullptr;
|
||||
}
|
||||
#else
|
||||
delete db;
|
||||
db = nullptr;
|
||||
#endif // ROCKSDB_LITE
|
||||
}
|
||||
|
||||
ColumnFamilyHandle* GetCfh(int64_t rand_num) {
|
||||
|
@ -1940,9 +1958,11 @@ class Benchmark {
|
|||
method = &Benchmark::Compress;
|
||||
} else if (name == "uncompress") {
|
||||
method = &Benchmark::Uncompress;
|
||||
#ifndef ROCKSDB_LITE
|
||||
} else if (name == "randomtransaction") {
|
||||
method = &Benchmark::RandomTransaction;
|
||||
post_process_method = &Benchmark::RandomTransactionVerify;
|
||||
#endif // ROCKSDB_LITE
|
||||
} else if (name == "randomreplacekeys") {
|
||||
fresh_db = true;
|
||||
method = &Benchmark::RandomReplaceKeys;
|
||||
|
@ -2518,10 +2538,12 @@ class Benchmark {
|
|||
NewGenericRateLimiter(FLAGS_rate_limiter_bytes_per_sec));
|
||||
}
|
||||
|
||||
#ifndef ROCKSDB_LITE
|
||||
if (FLAGS_readonly && FLAGS_transaction_db) {
|
||||
fprintf(stderr, "Cannot use readonly flag with transaction_db\n");
|
||||
exit(1);
|
||||
}
|
||||
#endif // ROCKSDB_LITE
|
||||
|
||||
if (FLAGS_num_multi_db <= 1) {
|
||||
OpenDb(options, FLAGS_db, &db_);
|
||||
|
@ -2554,6 +2576,7 @@ class Benchmark {
|
|||
column_families.push_back(ColumnFamilyDescriptor(
|
||||
ColumnFamilyName(i), ColumnFamilyOptions(options)));
|
||||
}
|
||||
#ifndef ROCKSDB_LITE
|
||||
if (FLAGS_readonly) {
|
||||
s = DB::OpenForReadOnly(options, db_name, column_families,
|
||||
&db->cfh, &db->db);
|
||||
|
@ -2574,9 +2597,13 @@ class Benchmark {
|
|||
} else {
|
||||
s = DB::Open(options, db_name, column_families, &db->cfh, &db->db);
|
||||
}
|
||||
#else
|
||||
s = DB::Open(options, db_name, column_families, &db->cfh, &db->db);
|
||||
#endif // ROCKSDB_LITE
|
||||
db->cfh.resize(FLAGS_num_column_families);
|
||||
db->num_created = num_hot;
|
||||
db->num_hot = num_hot;
|
||||
#ifndef ROCKSDB_LITE
|
||||
} else if (FLAGS_readonly) {
|
||||
s = DB::OpenForReadOnly(options, db_name, &db->db);
|
||||
} else if (FLAGS_optimistic_transaction_db) {
|
||||
|
@ -2591,7 +2618,7 @@ class Benchmark {
|
|||
if (s.ok()) {
|
||||
db->db = ptr;
|
||||
}
|
||||
|
||||
#endif // ROCKSDB_LITE
|
||||
} else {
|
||||
s = DB::Open(options, db_name, &db->db);
|
||||
}
|
||||
|
@ -3636,6 +3663,7 @@ class Benchmark {
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef ROCKSDB_LITE
|
||||
// This benchmark stress tests Transactions. For a given --duration (or
|
||||
// total number of --writes, a Transaction will perform a read-modify-write
|
||||
// to increment the value of a key in each of N(--transaction-sets) sets of
|
||||
|
@ -3868,6 +3896,7 @@ class Benchmark {
|
|||
|
||||
fprintf(stdout, "RandomTransactionVerify Success!\n");
|
||||
}
|
||||
#endif // ROCKSDB_LITE
|
||||
|
||||
// Writes and deletes random keys without overwriting keys.
|
||||
//
|
||||
|
|
|
@ -592,6 +592,7 @@ int main(int argc, char** argv) {
|
|||
std::unique_ptr<rocksdb::MemTableRepFactory> factory;
|
||||
if (FLAGS_memtablerep == "skiplist") {
|
||||
factory.reset(new rocksdb::SkipListFactory);
|
||||
#ifndef ROCKSDB_LITE
|
||||
} else if (FLAGS_memtablerep == "vector") {
|
||||
factory.reset(new rocksdb::VectorRepFactory);
|
||||
} else if (FLAGS_memtablerep == "hashskiplist") {
|
||||
|
@ -613,6 +614,7 @@ int main(int argc, char** argv) {
|
|||
static_cast<uint32_t>(FLAGS_hash_function_count)));
|
||||
options.prefix_extractor.reset(
|
||||
rocksdb::NewFixedPrefixTransform(FLAGS_prefix_length));
|
||||
#endif // ROCKSDB_LITE
|
||||
} else {
|
||||
fprintf(stdout, "Unknown memtablerep: %s\n", FLAGS_memtablerep.c_str());
|
||||
exit(1);
|
||||
|
|
Loading…
Reference in New Issue