X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=ceph%2Fsrc%2Frocksdb%2Futilities%2Fpersistent_cache%2Fblock_cache_tier.h;h=1aac287cc0ed9e65fa67f030dc4a18e92b030902;hb=1e59de90020f1d8d374046ef9cca56ccd4e806e2;hp=d0114355291cb76ac61e5a6008146aad989805d8;hpb=7c673caec407dd16107e56e4b51a6d00f021315c;p=ceph.git diff --git a/ceph/src/rocksdb/utilities/persistent_cache/block_cache_tier.h b/ceph/src/rocksdb/utilities/persistent_cache/block_cache_tier.h index d01143552..1aac287cc 100644 --- a/ceph/src/rocksdb/utilities/persistent_cache/block_cache_tier.h +++ b/ceph/src/rocksdb/utilities/persistent_cache/block_cache_tier.h @@ -1,15 +1,16 @@ // Copyright (c) 2013, Facebook, Inc. All rights reserved. -// This source code is licensed under the BSD-style license found in the -// LICENSE file in the root directory of this source tree. An additional grant -// of patent rights can be found in the PATENTS file in the same directory. +// 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 -#ifndef OS_WIN +#ifndef OS_WIN #include -#endif // ! OS_WIN +#endif // ! OS_WIN +#include #include #include #include @@ -18,23 +19,22 @@ #include #include -#include "rocksdb/cache.h" -#include "rocksdb/comparator.h" -#include "rocksdb/persistent_cache.h" - -#include "utilities/persistent_cache/block_cache_tier_file.h" -#include "utilities/persistent_cache/block_cache_tier_metadata.h" -#include "utilities/persistent_cache/persistent_cache_util.h" - +#include "memory/arena.h" #include "memtable/skiplist.h" #include "monitoring/histogram.h" #include "port/port.h" -#include "util/arena.h" +#include "rocksdb/cache.h" +#include "rocksdb/comparator.h" +#include "rocksdb/persistent_cache.h" +#include "rocksdb/system_clock.h" #include "util/coding.h" #include "util/crc32c.h" #include "util/mutexlock.h" +#include "utilities/persistent_cache/block_cache_tier_file.h" +#include "utilities/persistent_cache/block_cache_tier_metadata.h" +#include "utilities/persistent_cache/persistent_cache_util.h" -namespace rocksdb { +namespace ROCKSDB_NAMESPACE { // // Block cache tier implementation @@ -43,16 +43,17 @@ class BlockCacheTier : public PersistentCacheTier { public: explicit BlockCacheTier(const PersistentCacheConfig& opt) : opt_(opt), - insert_ops_(opt_.max_write_pipeline_backlog_size), + insert_ops_(static_cast(opt_.max_write_pipeline_backlog_size)), buffer_allocator_(opt.write_buffer_size, opt.write_buffer_count()), - writer_(this, opt_.writer_qdepth, opt_.writer_dispatch_size) { - Info(opt_.log, "Initializing allocator. size=%d B count=%d", + writer_(this, opt_.writer_qdepth, + static_cast(opt_.writer_dispatch_size)) { + Info(opt_.log, "Initializing allocator. size=%d B count=%" ROCKSDB_PRIszt, opt_.write_buffer_size, opt_.write_buffer_count()); } virtual ~BlockCacheTier() { // Close is re-entrant so we can call close even if it is already closed - Close(); + Close().PermitUncheckedError(); assert(!insert_th_.joinable()); } @@ -73,7 +74,7 @@ class BlockCacheTier : public PersistentCacheTier { void TEST_Flush() override { while (insert_ops_.Size()) { /* sleep override */ - Env::Default()->SleepForMicroseconds(1000000); + SystemClock::Default()->SleepForMicroseconds(1000000); } } @@ -91,7 +92,7 @@ class BlockCacheTier : public PersistentCacheTier { ~InsertOp() {} InsertOp() = delete; - InsertOp(InsertOp&& rhs) = default; + InsertOp(InsertOp&& /*rhs*/) = default; InsertOp& operator=(InsertOp&& rhs) = default; // used for estimating size by bounded queue @@ -99,7 +100,7 @@ class BlockCacheTier : public PersistentCacheTier { std::string key_; std::string data_; - const bool signal_ = false; // signal to request processing thread to exit + bool signal_ = false; // signal to request processing thread to exit }; // entry point for insert thread @@ -121,10 +122,10 @@ class BlockCacheTier : public PersistentCacheTier { HistogramImpl read_hit_latency_; HistogramImpl read_miss_latency_; HistogramImpl write_latency_; - uint64_t cache_hits_ = 0; - uint64_t cache_misses_ = 0; - uint64_t cache_errors_ = 0; - uint64_t insert_dropped_ = 0; + std::atomic cache_hits_{0}; + std::atomic cache_misses_{0}; + std::atomic cache_errors_{0}; + std::atomic insert_dropped_{0}; double CacheHitPct() const { const auto lookups = cache_hits_ + cache_misses_; @@ -140,16 +141,16 @@ class BlockCacheTier : public PersistentCacheTier { port::RWMutex lock_; // Synchronization const PersistentCacheConfig opt_; // BlockCache options BoundedQueue insert_ops_; // Ops waiting for insert - rocksdb::port::Thread insert_th_; // Insert thread + ROCKSDB_NAMESPACE::port::Thread insert_th_; // Insert thread uint32_t writer_cache_id_ = 0; // Current cache file identifier WriteableCacheFile* cache_file_ = nullptr; // Current cache file reference CacheWriteBufferAllocator buffer_allocator_; // Buffer provider ThreadedWriter writer_; // Writer threads BlockCacheTierMetadata metadata_; // Cache meta data manager std::atomic size_{0}; // Size of the cache - Statistics stats_; // Statistics + Statistics stats_; // Statistics }; -} // namespace rocksdb +} // namespace ROCKSDB_NAMESPACE #endif