|
|
@ -312,7 +312,7 @@ class Stats { |
|
|
|
|
|
|
|
|
|
|
|
void SetId(int id) { id_ = id; } |
|
|
|
void SetId(int id) { id_ = id; } |
|
|
|
|
|
|
|
|
|
|
|
void FinishedSingleOp() { |
|
|
|
void FinishedSingleOp(DB* db) { |
|
|
|
if (FLAGS_histogram) { |
|
|
|
if (FLAGS_histogram) { |
|
|
|
double now = FLAGS_env->NowMicros(); |
|
|
|
double now = FLAGS_env->NowMicros(); |
|
|
|
double micros = now - last_op_finish_; |
|
|
|
double micros = now - last_op_finish_; |
|
|
@ -339,13 +339,18 @@ class Stats { |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
double now = FLAGS_env->NowMicros(); |
|
|
|
double now = FLAGS_env->NowMicros(); |
|
|
|
fprintf(stderr, |
|
|
|
fprintf(stderr, |
|
|
|
"%s thread %d: %ld ops in %.6f seconds and %.2f ops/sec\n", |
|
|
|
"%s thread %d: (%ld,%ld) ops (interval,total) in %.6f seconds and %.2f ops/sec\n", |
|
|
|
FLAGS_env->TimeToString((uint64_t) now/1000000).c_str(), |
|
|
|
FLAGS_env->TimeToString((uint64_t) now/1000000).c_str(), |
|
|
|
id_, |
|
|
|
id_, |
|
|
|
done_ - last_report_done_, |
|
|
|
done_ - last_report_done_, done_, |
|
|
|
(now - last_report_finish_) / 1000000.0, |
|
|
|
(now - last_report_finish_) / 1000000.0, |
|
|
|
(done_ - last_report_done_) / |
|
|
|
(done_ - last_report_done_) / |
|
|
|
((now - last_report_finish_) / 1000000.0)); |
|
|
|
((now - last_report_finish_) / 1000000.0)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::string stats; |
|
|
|
|
|
|
|
if (db && db->GetProperty("leveldb.stats", &stats)) |
|
|
|
|
|
|
|
fprintf(stderr, stats.c_str()); |
|
|
|
|
|
|
|
|
|
|
|
fflush(stderr); |
|
|
|
fflush(stderr); |
|
|
|
next_report_ += FLAGS_stats_interval; |
|
|
|
next_report_ += FLAGS_stats_interval; |
|
|
|
last_report_finish_ = now; |
|
|
|
last_report_finish_ = now; |
|
|
@ -808,7 +813,7 @@ class Benchmark { |
|
|
|
uint32_t crc = 0; |
|
|
|
uint32_t crc = 0; |
|
|
|
while (bytes < 500 * 1048576) { |
|
|
|
while (bytes < 500 * 1048576) { |
|
|
|
crc = crc32c::Value(data.data(), size); |
|
|
|
crc = crc32c::Value(data.data(), size); |
|
|
|
thread->stats.FinishedSingleOp(); |
|
|
|
thread->stats.FinishedSingleOp(NULL); |
|
|
|
bytes += size; |
|
|
|
bytes += size; |
|
|
|
} |
|
|
|
} |
|
|
|
// Print so result is not dead
|
|
|
|
// Print so result is not dead
|
|
|
@ -829,7 +834,7 @@ class Benchmark { |
|
|
|
ptr = ap.Acquire_Load(); |
|
|
|
ptr = ap.Acquire_Load(); |
|
|
|
} |
|
|
|
} |
|
|
|
count++; |
|
|
|
count++; |
|
|
|
thread->stats.FinishedSingleOp(); |
|
|
|
thread->stats.FinishedSingleOp(NULL); |
|
|
|
} |
|
|
|
} |
|
|
|
if (ptr == NULL) exit(1); // Disable unused variable warning.
|
|
|
|
if (ptr == NULL) exit(1); // Disable unused variable warning.
|
|
|
|
} |
|
|
|
} |
|
|
@ -845,7 +850,7 @@ class Benchmark { |
|
|
|
ok = port::Snappy_Compress(input.data(), input.size(), &compressed); |
|
|
|
ok = port::Snappy_Compress(input.data(), input.size(), &compressed); |
|
|
|
produced += compressed.size(); |
|
|
|
produced += compressed.size(); |
|
|
|
bytes += input.size(); |
|
|
|
bytes += input.size(); |
|
|
|
thread->stats.FinishedSingleOp(); |
|
|
|
thread->stats.FinishedSingleOp(NULL); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!ok) { |
|
|
|
if (!ok) { |
|
|
@ -870,7 +875,7 @@ class Benchmark { |
|
|
|
ok = port::Snappy_Uncompress(compressed.data(), compressed.size(), |
|
|
|
ok = port::Snappy_Uncompress(compressed.data(), compressed.size(), |
|
|
|
uncompressed); |
|
|
|
uncompressed); |
|
|
|
bytes += input.size(); |
|
|
|
bytes += input.size(); |
|
|
|
thread->stats.FinishedSingleOp(); |
|
|
|
thread->stats.FinishedSingleOp(NULL); |
|
|
|
} |
|
|
|
} |
|
|
|
delete[] uncompressed; |
|
|
|
delete[] uncompressed; |
|
|
|
|
|
|
|
|
|
|
@ -903,7 +908,7 @@ class Benchmark { |
|
|
|
options.max_bytes_for_level_multiplier = |
|
|
|
options.max_bytes_for_level_multiplier = |
|
|
|
FLAGS_max_bytes_for_level_multiplier; |
|
|
|
FLAGS_max_bytes_for_level_multiplier; |
|
|
|
options.level0_stop_writes_trigger = FLAGS_level0_stop_writes_trigger; |
|
|
|
options.level0_stop_writes_trigger = FLAGS_level0_stop_writes_trigger; |
|
|
|
options.level0_file_num_compaction_trigger =
|
|
|
|
options.level0_file_num_compaction_trigger = |
|
|
|
FLAGS_level0_file_num_compaction_trigger; |
|
|
|
FLAGS_level0_file_num_compaction_trigger; |
|
|
|
options.level0_slowdown_writes_trigger = |
|
|
|
options.level0_slowdown_writes_trigger = |
|
|
|
FLAGS_level0_slowdown_writes_trigger; |
|
|
|
FLAGS_level0_slowdown_writes_trigger; |
|
|
@ -945,7 +950,7 @@ class Benchmark { |
|
|
|
snprintf(key, sizeof(key), "%016d", k); |
|
|
|
snprintf(key, sizeof(key), "%016d", k); |
|
|
|
batch.Put(key, gen.Generate(value_size_)); |
|
|
|
batch.Put(key, gen.Generate(value_size_)); |
|
|
|
bytes += value_size_ + strlen(key); |
|
|
|
bytes += value_size_ + strlen(key); |
|
|
|
thread->stats.FinishedSingleOp(); |
|
|
|
thread->stats.FinishedSingleOp(db_); |
|
|
|
} |
|
|
|
} |
|
|
|
s = db_->Write(write_options_, &batch); |
|
|
|
s = db_->Write(write_options_, &batch); |
|
|
|
if (!s.ok()) { |
|
|
|
if (!s.ok()) { |
|
|
@ -962,7 +967,7 @@ class Benchmark { |
|
|
|
int64_t bytes = 0; |
|
|
|
int64_t bytes = 0; |
|
|
|
for (iter->SeekToFirst(); i < reads_ && iter->Valid(); iter->Next()) { |
|
|
|
for (iter->SeekToFirst(); i < reads_ && iter->Valid(); iter->Next()) { |
|
|
|
bytes += iter->key().size() + iter->value().size(); |
|
|
|
bytes += iter->key().size() + iter->value().size(); |
|
|
|
thread->stats.FinishedSingleOp(); |
|
|
|
thread->stats.FinishedSingleOp(db_); |
|
|
|
++i; |
|
|
|
++i; |
|
|
|
} |
|
|
|
} |
|
|
|
delete iter; |
|
|
|
delete iter; |
|
|
@ -975,7 +980,7 @@ class Benchmark { |
|
|
|
int64_t bytes = 0; |
|
|
|
int64_t bytes = 0; |
|
|
|
for (iter->SeekToLast(); i < reads_ && iter->Valid(); iter->Prev()) { |
|
|
|
for (iter->SeekToLast(); i < reads_ && iter->Valid(); iter->Prev()) { |
|
|
|
bytes += iter->key().size() + iter->value().size(); |
|
|
|
bytes += iter->key().size() + iter->value().size(); |
|
|
|
thread->stats.FinishedSingleOp(); |
|
|
|
thread->stats.FinishedSingleOp(db_); |
|
|
|
++i; |
|
|
|
++i; |
|
|
|
} |
|
|
|
} |
|
|
|
delete iter; |
|
|
|
delete iter; |
|
|
@ -993,7 +998,7 @@ class Benchmark { |
|
|
|
if (db_->Get(options, key, &value).ok()) { |
|
|
|
if (db_->Get(options, key, &value).ok()) { |
|
|
|
found++; |
|
|
|
found++; |
|
|
|
} |
|
|
|
} |
|
|
|
thread->stats.FinishedSingleOp(); |
|
|
|
thread->stats.FinishedSingleOp(db_); |
|
|
|
} |
|
|
|
} |
|
|
|
char msg[100]; |
|
|
|
char msg[100]; |
|
|
|
snprintf(msg, sizeof(msg), "(%ld of %ld found)", found, num_); |
|
|
|
snprintf(msg, sizeof(msg), "(%ld of %ld found)", found, num_); |
|
|
@ -1008,7 +1013,7 @@ class Benchmark { |
|
|
|
const int k = thread->rand.Next() % FLAGS_num; |
|
|
|
const int k = thread->rand.Next() % FLAGS_num; |
|
|
|
snprintf(key, sizeof(key), "%016d.", k); |
|
|
|
snprintf(key, sizeof(key), "%016d.", k); |
|
|
|
db_->Get(options, key, &value); |
|
|
|
db_->Get(options, key, &value); |
|
|
|
thread->stats.FinishedSingleOp(); |
|
|
|
thread->stats.FinishedSingleOp(db_); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1021,7 +1026,7 @@ class Benchmark { |
|
|
|
const int k = thread->rand.Next() % range; |
|
|
|
const int k = thread->rand.Next() % range; |
|
|
|
snprintf(key, sizeof(key), "%016d", k); |
|
|
|
snprintf(key, sizeof(key), "%016d", k); |
|
|
|
db_->Get(options, key, &value); |
|
|
|
db_->Get(options, key, &value); |
|
|
|
thread->stats.FinishedSingleOp(); |
|
|
|
thread->stats.FinishedSingleOp(db_); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1037,7 +1042,7 @@ class Benchmark { |
|
|
|
iter->Seek(key); |
|
|
|
iter->Seek(key); |
|
|
|
if (iter->Valid() && iter->key() == key) found++; |
|
|
|
if (iter->Valid() && iter->key() == key) found++; |
|
|
|
delete iter; |
|
|
|
delete iter; |
|
|
|
thread->stats.FinishedSingleOp(); |
|
|
|
thread->stats.FinishedSingleOp(db_); |
|
|
|
} |
|
|
|
} |
|
|
|
char msg[100]; |
|
|
|
char msg[100]; |
|
|
|
snprintf(msg, sizeof(msg), "(%ld of %ld found)", found, num_); |
|
|
|
snprintf(msg, sizeof(msg), "(%ld of %ld found)", found, num_); |
|
|
@ -1055,7 +1060,7 @@ class Benchmark { |
|
|
|
char key[100]; |
|
|
|
char key[100]; |
|
|
|
snprintf(key, sizeof(key), "%016d", k); |
|
|
|
snprintf(key, sizeof(key), "%016d", k); |
|
|
|
batch.Delete(key); |
|
|
|
batch.Delete(key); |
|
|
|
thread->stats.FinishedSingleOp(); |
|
|
|
thread->stats.FinishedSingleOp(db_); |
|
|
|
} |
|
|
|
} |
|
|
|
s = db_->Write(write_options_, &batch); |
|
|
|
s = db_->Write(write_options_, &batch); |
|
|
|
if (!s.ok()) { |
|
|
|
if (!s.ok()) { |
|
|
@ -1144,7 +1149,7 @@ class Benchmark { |
|
|
|
put_weight--; |
|
|
|
put_weight--; |
|
|
|
writes_done++; |
|
|
|
writes_done++; |
|
|
|
} |
|
|
|
} |
|
|
|
thread->stats.FinishedSingleOp(); |
|
|
|
thread->stats.FinishedSingleOp(db_); |
|
|
|
} |
|
|
|
} |
|
|
|
char msg[100]; |
|
|
|
char msg[100]; |
|
|
|
snprintf(msg, sizeof(msg), "( reads:%ld writes:%ld total:%ld )", |
|
|
|
snprintf(msg, sizeof(msg), "( reads:%ld writes:%ld total:%ld )", |
|
|
|