|
|
@ -63,6 +63,22 @@ static const char* FLAGS_benchmarks = |
|
|
|
"readreverse," |
|
|
|
"fill100K," |
|
|
|
"crc32c," |
|
|
|
"readwhilewriting," |
|
|
|
"CreateIndex," |
|
|
|
"FindKeysByField," |
|
|
|
"QueryByIndex," |
|
|
|
"DeleteIndex," |
|
|
|
"compact," |
|
|
|
"WriteSeqWhileCreating," |
|
|
|
"WriteSeqWhileDeleting," |
|
|
|
"compact," |
|
|
|
"WriteRandomWhileCreating," |
|
|
|
"WriteRandomWhileDeleting," |
|
|
|
"compact," |
|
|
|
"ReadSeqWhileCreating," |
|
|
|
"ReadSeqWhileDeleting," |
|
|
|
"ReadRandomWhileCreating," |
|
|
|
"ReadRandomWhileDeleting," |
|
|
|
"snappycomp," |
|
|
|
"snappyuncomp," |
|
|
|
"zstdcomp," |
|
|
@ -543,7 +559,7 @@ class Benchmark { |
|
|
|
} |
|
|
|
} |
|
|
|
if (!FLAGS_use_existing_db) { |
|
|
|
DestroyDB(FLAGS_db, Options()); |
|
|
|
fielddb::DestroyDB(FLAGS_db, Options()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -635,6 +651,38 @@ class Benchmark { |
|
|
|
method = &Benchmark::Compact; |
|
|
|
} else if (name == Slice("crc32c")) { |
|
|
|
method = &Benchmark::Crc32c; |
|
|
|
} else if (name == Slice("CreateIndex")) { |
|
|
|
method = &Benchmark::CreateIndex; |
|
|
|
} else if (name == Slice("FindKeysByField")) { |
|
|
|
method = &Benchmark::FindKeysByField; |
|
|
|
} else if (name == Slice("QueryByIndex")) { |
|
|
|
method = &Benchmark::QueryByIndex; |
|
|
|
} else if (name == Slice("DeleteIndex")) { |
|
|
|
method = &Benchmark::DeleteIndex; |
|
|
|
} else if (name == Slice("WriteSeqWhileCreating")) { |
|
|
|
num_threads++; |
|
|
|
method = &Benchmark::WriteSeqWhileCreating; |
|
|
|
} else if (name == Slice("WriteSeqWhileDeleting")) { |
|
|
|
num_threads++; |
|
|
|
method = &Benchmark::WriteSeqWhileDeleting; |
|
|
|
} else if (name == Slice("WriteRandomWhileCreating")) { |
|
|
|
num_threads++; |
|
|
|
method = &Benchmark::WriteRandomWhileCreating; |
|
|
|
} else if (name == Slice("WriteRandomWhileDeleting")) { |
|
|
|
num_threads++; |
|
|
|
method = &Benchmark::WriteRandomWhileDeleting; |
|
|
|
} else if (name == Slice("ReadSeqWhileCreating")) { |
|
|
|
num_threads++; |
|
|
|
method = &Benchmark::ReadSeqWhileCreating; |
|
|
|
} else if (name == Slice("ReadSeqWhileDeleting")) { |
|
|
|
num_threads++; |
|
|
|
method = &Benchmark::ReadSeqWhileDeleting; |
|
|
|
} else if (name == Slice("ReadRandomWhileCreating")) { |
|
|
|
num_threads++; |
|
|
|
method = &Benchmark::ReadRandomWhileCreating; |
|
|
|
} else if (name == Slice("ReadRandomWhileDeleting")) { |
|
|
|
num_threads++; |
|
|
|
method = &Benchmark::ReadRandomWhileDeleting; |
|
|
|
} else if (name == Slice("snappycomp")) { |
|
|
|
method = &Benchmark::SnappyCompress; |
|
|
|
} else if (name == Slice("snappyuncomp")) { |
|
|
@ -664,7 +712,7 @@ class Benchmark { |
|
|
|
} else { |
|
|
|
delete db_; |
|
|
|
db_ = nullptr; |
|
|
|
//DestroyDB(FLAGS_db, Options());
|
|
|
|
fielddb::DestroyDB(FLAGS_db, Options()); |
|
|
|
Open(); |
|
|
|
} |
|
|
|
} |
|
|
@ -821,7 +869,6 @@ class Benchmark { |
|
|
|
options.compression = |
|
|
|
FLAGS_compression ? kSnappyCompression : kNoCompression; |
|
|
|
// Status s = DB::Open(options, FLAGS_db, &db_);
|
|
|
|
fielddb::DestroyDB(FLAGS_db, options); |
|
|
|
db_ = new FieldDB(); |
|
|
|
Status s = FieldDB::OpenFieldDB(options, FLAGS_db, &db_); |
|
|
|
if (!s.ok()) { |
|
|
@ -1078,6 +1125,210 @@ class Benchmark { |
|
|
|
g_env->RemoveFile(fname); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void CreateIndex(ThreadState* thread) { |
|
|
|
db_->CreateIndexOnField("age", write_options_); |
|
|
|
} |
|
|
|
|
|
|
|
void FindKeysByField(ThreadState* thread) { |
|
|
|
Field f = {"age", "20"}; |
|
|
|
std::vector<std::string> res; |
|
|
|
res = db_->FindKeysByField(f); |
|
|
|
} |
|
|
|
|
|
|
|
void QueryByIndex(ThreadState* thread) { |
|
|
|
Field f = {"age", "20"}; |
|
|
|
Status s; |
|
|
|
db_->QueryByIndex(f, &s); |
|
|
|
} |
|
|
|
|
|
|
|
void DeleteIndex(ThreadState* thread) { |
|
|
|
db_->DeleteIndex("age", write_options_); |
|
|
|
} |
|
|
|
|
|
|
|
void WriteSeqWhileCreating(ThreadState* thread) { |
|
|
|
if (thread->tid > 0) { |
|
|
|
WriteSeq(thread); |
|
|
|
} else { |
|
|
|
// Special thread that keeps creating index until other threads are done.
|
|
|
|
if (db_->GetIndexStatus("age") != IndexStatus::NotExist) { |
|
|
|
std::fprintf(stderr, "index status error in WriteWhileCreating\n"); |
|
|
|
std::exit(1); |
|
|
|
} |
|
|
|
|
|
|
|
while (true) { |
|
|
|
if (db_->GetIndexStatus("age") == IndexStatus::Exist) { |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
db_->CreateIndexOnField("age", write_options_); |
|
|
|
} |
|
|
|
|
|
|
|
// Do not count any of the preceding work/delay in stats.
|
|
|
|
thread->stats.Start(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void WriteSeqWhileDeleting(ThreadState* thread) { |
|
|
|
if (thread->tid > 0) { |
|
|
|
WriteSeq(thread); |
|
|
|
} else { |
|
|
|
// Special thread that keeps creating index until other threads are done.
|
|
|
|
if (db_->GetIndexStatus("age") != IndexStatus::Exist) { |
|
|
|
std::fprintf(stderr, "index status error in WriteWhileDeleting\n"); |
|
|
|
std::exit(1); |
|
|
|
} |
|
|
|
|
|
|
|
while (true) { |
|
|
|
if (db_->GetIndexStatus("age") == IndexStatus::NotExist) { |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
db_->DeleteIndex("age", write_options_); |
|
|
|
} |
|
|
|
|
|
|
|
// Do not count any of the preceding work/delay in stats.
|
|
|
|
thread->stats.Start(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void WriteRandomWhileCreating(ThreadState* thread) { |
|
|
|
if (thread->tid > 0) { |
|
|
|
WriteRandom(thread); |
|
|
|
} else { |
|
|
|
// Special thread that keeps creating index until other threads are done.
|
|
|
|
if (db_->GetIndexStatus("age") != IndexStatus::NotExist) { |
|
|
|
std::fprintf(stderr, "index status error in WriteWhileCreating\n"); |
|
|
|
std::exit(1); |
|
|
|
} |
|
|
|
|
|
|
|
while (true) { |
|
|
|
if (db_->GetIndexStatus("age") == IndexStatus::Exist) { |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
db_->CreateIndexOnField("age", write_options_); |
|
|
|
} |
|
|
|
|
|
|
|
// Do not count any of the preceding work/delay in stats.
|
|
|
|
thread->stats.Start(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void WriteRandomWhileDeleting(ThreadState* thread) { |
|
|
|
if (thread->tid > 0) { |
|
|
|
WriteRandom(thread); |
|
|
|
} else { |
|
|
|
// Special thread that keeps creating index until other threads are done.
|
|
|
|
if (db_->GetIndexStatus("age") != IndexStatus::Exist) { |
|
|
|
std::fprintf(stderr, "index status error in WriteWhileDeleting\n"); |
|
|
|
std::exit(1); |
|
|
|
} |
|
|
|
|
|
|
|
while (true) { |
|
|
|
if (db_->GetIndexStatus("age") == IndexStatus::NotExist) { |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
db_->DeleteIndex("age", write_options_); |
|
|
|
} |
|
|
|
|
|
|
|
// Do not count any of the preceding work/delay in stats.
|
|
|
|
thread->stats.Start(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void ReadSeqWhileCreating(ThreadState* thread) { |
|
|
|
if (thread->tid > 0) { |
|
|
|
ReadSequential(thread); |
|
|
|
} else { |
|
|
|
// Special thread that keeps creating index until other threads are done.
|
|
|
|
if (db_->GetIndexStatus("age") != IndexStatus::NotExist) { |
|
|
|
std::fprintf(stderr, "index status error in WriteWhileCreating\n"); |
|
|
|
std::exit(1); |
|
|
|
} |
|
|
|
|
|
|
|
while (true) { |
|
|
|
if (db_->GetIndexStatus("age") == IndexStatus::Exist) { |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
db_->CreateIndexOnField("age", write_options_); |
|
|
|
} |
|
|
|
|
|
|
|
// Do not count any of the preceding work/delay in stats.
|
|
|
|
thread->stats.Start(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void ReadSeqWhileDeleting(ThreadState* thread) { |
|
|
|
if (thread->tid > 0) { |
|
|
|
ReadSequential(thread); |
|
|
|
} else { |
|
|
|
// Special thread that keeps creating index until other threads are done.
|
|
|
|
if (db_->GetIndexStatus("age") != IndexStatus::Exist) { |
|
|
|
std::fprintf(stderr, "index status error in WriteWhileDeleting\n"); |
|
|
|
std::exit(1); |
|
|
|
} |
|
|
|
|
|
|
|
while (true) { |
|
|
|
if (db_->GetIndexStatus("age") == IndexStatus::NotExist) { |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
db_->DeleteIndex("age", write_options_); |
|
|
|
} |
|
|
|
|
|
|
|
// Do not count any of the preceding work/delay in stats.
|
|
|
|
thread->stats.Start(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void ReadRandomWhileCreating(ThreadState* thread) { |
|
|
|
if (thread->tid > 0) { |
|
|
|
ReadRandom(thread); |
|
|
|
} else { |
|
|
|
// Special thread that keeps creating index until other threads are done.
|
|
|
|
if (db_->GetIndexStatus("age") != IndexStatus::NotExist) { |
|
|
|
std::fprintf(stderr, "index status error in WriteWhileCreating\n"); |
|
|
|
std::exit(1); |
|
|
|
} |
|
|
|
|
|
|
|
while (true) { |
|
|
|
if (db_->GetIndexStatus("age") == IndexStatus::Exist) { |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
db_->CreateIndexOnField("age", write_options_); |
|
|
|
} |
|
|
|
|
|
|
|
// Do not count any of the preceding work/delay in stats.
|
|
|
|
thread->stats.Start(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void ReadRandomWhileDeleting(ThreadState* thread) { |
|
|
|
if (thread->tid > 0) { |
|
|
|
ReadRandom(thread); |
|
|
|
} else { |
|
|
|
// Special thread that keeps creating index until other threads are done.
|
|
|
|
if (db_->GetIndexStatus("age") != IndexStatus::Exist) { |
|
|
|
std::fprintf(stderr, "index status error in WriteWhileDeleting\n"); |
|
|
|
std::exit(1); |
|
|
|
} |
|
|
|
|
|
|
|
while (true) { |
|
|
|
if (db_->GetIndexStatus("age") == IndexStatus::NotExist) { |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
db_->DeleteIndex("age", write_options_); |
|
|
|
} |
|
|
|
|
|
|
|
// Do not count any of the preceding work/delay in stats.
|
|
|
|
thread->stats.Start(); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
} // namespace leveldb
|
|
|
|