diff --git a/benchmarks/db_bench_FieldDB.cc b/benchmarks/db_bench_FieldDB.cc index a07795a..4238ef6 100644 --- a/benchmarks/db_bench_FieldDB.cc +++ b/benchmarks/db_bench_FieldDB.cc @@ -63,10 +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," @@ -647,6 +659,30 @@ class Benchmark { 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")) { @@ -1110,6 +1146,189 @@ class Benchmark { 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