flush_job logs data size too (#4979)

Summary:
Right now when a flush is triggered, the memory consumption is logged but data size is not.
It's useful to log both when we debug unexpected small flushed file size.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/4979

Differential Revision: D14071979

Pulled By: siying

fbshipit-source-id: 0cd60449c5205eb00e0fbc299084418f609904ed
main
Siying Dong 6 years ago committed by Facebook Github Bot
parent 4db46aa2e6
commit 26a33ee5bd
  1. 17
      db/flush_job.cc
  2. 4
      db/memtable.h

@ -311,6 +311,7 @@ Status FlushJob::WriteLevel0Table() {
ro.total_order_seek = true; ro.total_order_seek = true;
Arena arena; Arena arena;
uint64_t total_num_entries = 0, total_num_deletes = 0; uint64_t total_num_entries = 0, total_num_deletes = 0;
uint64_t total_data_size = 0;
size_t total_memory_usage = 0; size_t total_memory_usage = 0;
for (MemTable* m : mems_) { for (MemTable* m : mems_) {
ROCKS_LOG_INFO( ROCKS_LOG_INFO(
@ -325,16 +326,18 @@ Status FlushJob::WriteLevel0Table() {
} }
total_num_entries += m->num_entries(); total_num_entries += m->num_entries();
total_num_deletes += m->num_deletes(); total_num_deletes += m->num_deletes();
total_data_size += m->get_data_size();
total_memory_usage += m->ApproximateMemoryUsage(); total_memory_usage += m->ApproximateMemoryUsage();
} }
event_logger_->Log() event_logger_->Log() << "job" << job_context_->job_id << "event"
<< "job" << job_context_->job_id << "event" << "flush_started"
<< "flush_started" << "num_memtables" << mems_.size() << "num_entries"
<< "num_memtables" << mems_.size() << "num_entries" << total_num_entries << total_num_entries << "num_deletes"
<< "num_deletes" << total_num_deletes << "memory_usage" << total_num_deletes << "total_data_size"
<< total_memory_usage << "flush_reason" << total_data_size << "memory_usage"
<< GetFlushReasonString(cfd_->GetFlushReason()); << total_memory_usage << "flush_reason"
<< GetFlushReasonString(cfd_->GetFlushReason());
{ {
ScopedArenaIterator iter( ScopedArenaIterator iter(

@ -265,6 +265,10 @@ class MemTable {
return num_deletes_.load(std::memory_order_relaxed); return num_deletes_.load(std::memory_order_relaxed);
} }
uint64_t get_data_size() const {
return data_size_.load(std::memory_order_relaxed);
}
// Dynamically change the memtable's capacity. If set below the current usage, // Dynamically change the memtable's capacity. If set below the current usage,
// the next key added will trigger a flush. Can only increase size when // the next key added will trigger a flush. Can only increase size when
// memtable prefix bloom is disabled, since we can't easily allocate more // memtable prefix bloom is disabled, since we can't easily allocate more

Loading…
Cancel
Save