Add statistics for BlobDB GC (#6296)
Summary: The patch adds statistics support to the new BlobDB garbage collection implementation; namely, it adds support for the following (pre-existing) tickers: `BLOB_DB_GC_NUM_FILES`: the number of blob files obsoleted by the GC logic. `BLOB_DB_GC_NUM_NEW_FILES`: the number of new blob files generated by the GC logic. `BLOB_DB_GC_FAILURES`: the number of failed GC passes (where a GC pass is equivalent to a (sub)compaction). `BLOB_DB_GC_NUM_KEYS_RELOCATED`: the number of blobs relocated to new blob files by the GC logic. `BLOB_DB_GC_BYTES_RELOCATED`: the total size of blobs relocated to new blob files. The tickers `BLOB_DB_GC_NUM_KEYS_OVERWRITTEN`, `BLOB_DB_GC_NUM_KEYS_EXPIRED`, `BLOB_DB_GC_BYTES_OVERWRITTEN`, `BLOB_DB_GC_BYTES_EXPIRED`, and `BLOB_DB_GC_MICROS` are not relevant for the new GC logic, and are thus marked deprecated. The patch also adds a couple of log messages that log the number and total size of blobs encountered and relocated during a GC pass, as well as the number of blob files created and obsoleted. Pull Request resolved: https://github.com/facebook/rocksdb/pull/6296 Test Plan: Extended unit tests and used the BlobDB mode of `db_bench`. Differential Revision: D19402513 Pulled By: ltamasi fbshipit-source-id: d53d2bfbf4928a1db1e9346c67ebb9007b8932ecmain
parent
71874c5aaf
commit
9e3ace42a4
@ -0,0 +1,52 @@ |
|||||||
|
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
|
||||||
|
// This source code is licensed under both the GPLv2 (found in the
|
||||||
|
// COPYING file in the root directory) and Apache 2.0 License
|
||||||
|
// (found in the LICENSE.Apache file in the root directory).
|
||||||
|
//
|
||||||
|
#pragma once |
||||||
|
|
||||||
|
#ifndef ROCKSDB_LITE |
||||||
|
|
||||||
|
namespace rocksdb { |
||||||
|
|
||||||
|
namespace blob_db { |
||||||
|
|
||||||
|
/**
|
||||||
|
* Statistics related to a single garbage collection pass (i.e. a single |
||||||
|
* (sub)compaction). |
||||||
|
*/ |
||||||
|
class BlobDBGarbageCollectionStats { |
||||||
|
public: |
||||||
|
uint64_t AllBlobs() const { return all_blobs_; } |
||||||
|
uint64_t AllBytes() const { return all_bytes_; } |
||||||
|
uint64_t RelocatedBlobs() const { return relocated_blobs_; } |
||||||
|
uint64_t RelocatedBytes() const { return relocated_bytes_; } |
||||||
|
uint64_t NewFiles() const { return new_files_; } |
||||||
|
bool HasError() const { return error_; } |
||||||
|
|
||||||
|
void AddBlob(uint64_t size) { |
||||||
|
++all_blobs_; |
||||||
|
all_bytes_ += size; |
||||||
|
} |
||||||
|
|
||||||
|
void AddRelocatedBlob(uint64_t size) { |
||||||
|
++relocated_blobs_; |
||||||
|
relocated_bytes_ += size; |
||||||
|
} |
||||||
|
|
||||||
|
void AddNewFile() { ++new_files_; } |
||||||
|
|
||||||
|
void SetError() { error_ = true; } |
||||||
|
|
||||||
|
private: |
||||||
|
uint64_t all_blobs_ = 0; |
||||||
|
uint64_t all_bytes_ = 0; |
||||||
|
uint64_t relocated_blobs_ = 0; |
||||||
|
uint64_t relocated_bytes_ = 0; |
||||||
|
uint64_t new_files_ = 0; |
||||||
|
bool error_ = false; |
||||||
|
}; |
||||||
|
|
||||||
|
} // namespace blob_db
|
||||||
|
} // namespace rocksdb
|
||||||
|
#endif // ROCKSDB_LITE
|
Loading…
Reference in new issue