Print log message when we are throttling writes.
Summary: Added option --writes=xxx to specify the number of keys that we want to overwrite in the benchmark. Task ID: # Blame Rev: Test Plan: Revert Plan: Reviewers: adsharma CC: sc Differential Revision: https://reviews.facebook.net/D3465
This commit is contained in:
parent
f50ece60c7
commit
338939e5c1
@ -116,6 +116,12 @@ static bool FLAGS_verify_checksum = false;
|
|||||||
static bool FLAGS_statistics = false;
|
static bool FLAGS_statistics = false;
|
||||||
static class leveldb::DBStatistics* dbstats = NULL;
|
static class leveldb::DBStatistics* dbstats = NULL;
|
||||||
|
|
||||||
|
// Number of write operations to do. If negative, do FLAGS_num reads.
|
||||||
|
static long FLAGS_writes = -1;
|
||||||
|
|
||||||
|
// Sync all writes to disk
|
||||||
|
static bool FLAGS_sync = false;
|
||||||
|
|
||||||
extern bool useOsBuffer;
|
extern bool useOsBuffer;
|
||||||
|
|
||||||
namespace leveldb {
|
namespace leveldb {
|
||||||
@ -328,6 +334,7 @@ class Benchmark {
|
|||||||
int entries_per_batch_;
|
int entries_per_batch_;
|
||||||
WriteOptions write_options_;
|
WriteOptions write_options_;
|
||||||
long reads_;
|
long reads_;
|
||||||
|
long writes_;
|
||||||
int heap_counter_;
|
int heap_counter_;
|
||||||
|
|
||||||
void PrintHeader() {
|
void PrintHeader() {
|
||||||
@ -427,6 +434,7 @@ class Benchmark {
|
|||||||
value_size_(FLAGS_value_size),
|
value_size_(FLAGS_value_size),
|
||||||
entries_per_batch_(1),
|
entries_per_batch_(1),
|
||||||
reads_(FLAGS_reads < 0 ? FLAGS_num : FLAGS_reads),
|
reads_(FLAGS_reads < 0 ? FLAGS_num : FLAGS_reads),
|
||||||
|
writes_(FLAGS_writes < 0 ? FLAGS_num : FLAGS_writes),
|
||||||
heap_counter_(0) {
|
heap_counter_(0) {
|
||||||
std::vector<std::string> files;
|
std::vector<std::string> files;
|
||||||
Env::Default()->GetChildren(FLAGS_db, &files);
|
Env::Default()->GetChildren(FLAGS_db, &files);
|
||||||
@ -465,9 +473,13 @@ class Benchmark {
|
|||||||
// Reset parameters that may be overriddden bwlow
|
// Reset parameters that may be overriddden bwlow
|
||||||
num_ = FLAGS_num;
|
num_ = FLAGS_num;
|
||||||
reads_ = (FLAGS_reads < 0 ? FLAGS_num : FLAGS_reads);
|
reads_ = (FLAGS_reads < 0 ? FLAGS_num : FLAGS_reads);
|
||||||
|
writes_ = (FLAGS_writes < 0 ? FLAGS_num : FLAGS_writes);
|
||||||
value_size_ = FLAGS_value_size;
|
value_size_ = FLAGS_value_size;
|
||||||
entries_per_batch_ = 1;
|
entries_per_batch_ = 1;
|
||||||
write_options_ = WriteOptions();
|
write_options_ = WriteOptions();
|
||||||
|
if (FLAGS_sync) {
|
||||||
|
write_options_.sync = true;
|
||||||
|
}
|
||||||
|
|
||||||
void (Benchmark::*method)(ThreadState*) = NULL;
|
void (Benchmark::*method)(ThreadState*) = NULL;
|
||||||
bool fresh_db = false;
|
bool fresh_db = false;
|
||||||
@ -754,7 +766,7 @@ class Benchmark {
|
|||||||
WriteBatch batch;
|
WriteBatch batch;
|
||||||
Status s;
|
Status s;
|
||||||
int64_t bytes = 0;
|
int64_t bytes = 0;
|
||||||
for (int i = 0; i < num_; i += entries_per_batch_) {
|
for (int i = 0; i < writes_; i += entries_per_batch_) {
|
||||||
batch.Clear();
|
batch.Clear();
|
||||||
for (int j = 0; j < entries_per_batch_; j++) {
|
for (int j = 0; j < entries_per_batch_; j++) {
|
||||||
const int k = seq ? i+j : (thread->rand.Next() % FLAGS_num);
|
const int k = seq ? i+j : (thread->rand.Next() % FLAGS_num);
|
||||||
@ -1007,6 +1019,11 @@ int main(int argc, char** argv) {
|
|||||||
dbstats = new leveldb::DBStatistics();
|
dbstats = new leveldb::DBStatistics();
|
||||||
FLAGS_statistics = true;
|
FLAGS_statistics = true;
|
||||||
}
|
}
|
||||||
|
} else if (sscanf(argv[i], "--writes=%d%c", &n, &junk) == 1) {
|
||||||
|
FLAGS_writes = n;
|
||||||
|
} else if (sscanf(argv[i], "--sync=%d%c", &n, &junk) == 1 &&
|
||||||
|
(n == 0 || n == 1)) {
|
||||||
|
FLAGS_sync = n;
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "Invalid flag '%s'\n", argv[i]);
|
fprintf(stderr, "Invalid flag '%s'\n", argv[i]);
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -1243,6 +1243,7 @@ Status DBImpl::MakeRoomForWrite(bool force) {
|
|||||||
mutex_.Unlock();
|
mutex_.Unlock();
|
||||||
env_->SleepForMicroseconds(1000);
|
env_->SleepForMicroseconds(1000);
|
||||||
allow_delay = false; // Do not delay a single write more than once
|
allow_delay = false; // Do not delay a single write more than once
|
||||||
|
Log(options_.info_log, "delaying write...\n");
|
||||||
mutex_.Lock();
|
mutex_.Lock();
|
||||||
} else if (!force &&
|
} else if (!force &&
|
||||||
(mem_->ApproximateMemoryUsage() <= options_.write_buffer_size)) {
|
(mem_->ApproximateMemoryUsage() <= options_.write_buffer_size)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user