diff --git a/include/xrpl/basics/TaggedCache.h b/include/xrpl/basics/TaggedCache.h index 64570ae061..93bf535bb2 100644 --- a/include/xrpl/basics/TaggedCache.h +++ b/include/xrpl/basics/TaggedCache.h @@ -192,8 +192,8 @@ public: // End CachedSLEs functions. private: - SharedPointerType - initialFetch(key_type const& key, std::lock_guard const& l); + // SharedPointerType + // initialFetch(key_type const& key, std::lock_guard const& l); void collect_metrics(); @@ -294,7 +294,7 @@ private: using cache_type = hardened_partitioned_hash_map; - [[nodiscard]] std::thread + /*[[nodiscard]] std::thread sweepHelper( clock_type::time_point const& when_expire, [[maybe_unused]] clock_type::time_point const& now, @@ -310,7 +310,7 @@ private: typename KeyOnlyCacheType::map_type& partition, SweptPointersVector&, std::atomic& allRemovals, - std::lock_guard const&); + std::lock_guard const&);*/ beast::Journal m_journal; clock_type& m_clock; diff --git a/include/xrpl/basics/TaggedCache.ipp b/include/xrpl/basics/TaggedCache.ipp index f14a4b9886..bc31909f95 100644 --- a/include/xrpl/basics/TaggedCache.ipp +++ b/include/xrpl/basics/TaggedCache.ipp @@ -54,7 +54,7 @@ inline TaggedCache< , m_clock(clock) , m_stats(name, std::bind(&TaggedCache::collect_metrics, this), collector) , m_name(name) - , m_target_size(0) + , m_target_size(size) , m_target_age(expiration) , m_cache_count(0) , m_hits(0) @@ -105,8 +105,9 @@ TaggedCache< KeyEqual, Mutex>::size() const { - std::lock_guard lock(m_mutex); - return m_cache.size(); + /*std::lock_guard lock(m_mutex); + return m_cache.size();*/ + return 0; } template < @@ -129,8 +130,9 @@ TaggedCache< KeyEqual, Mutex>::getCacheSize() const { - std::lock_guard lock(m_mutex); - return m_cache_count; + /*std::lock_guard lock(m_mutex); + return m_cache_count;*/ + return 0; } template < @@ -153,8 +155,9 @@ TaggedCache< KeyEqual, Mutex>::getTrackSize() const { - std::lock_guard lock(m_mutex); - return m_cache.size(); + /*std::lock_guard lock(m_mutex); + return m_cache.size();*/ + return 0; } template < @@ -177,9 +180,10 @@ TaggedCache< KeyEqual, Mutex>::getHitRate() { - std::lock_guard lock(m_mutex); + /*std::lock_guard lock(m_mutex); auto const total = static_cast(m_hits + m_misses); - return m_hits * (100.0f / std::max(1.0f, total)); + return m_hits * (100.0f / std::max(1.0f, total));*/ + return 0.0f; } template < @@ -202,9 +206,9 @@ TaggedCache< KeyEqual, Mutex>::clear() { - std::lock_guard lock(m_mutex); + /*std::lock_guard lock(m_mutex); m_cache.clear(); - m_cache_count = 0; + m_cache_count = 0;*/ } template < @@ -227,11 +231,11 @@ TaggedCache< KeyEqual, Mutex>::reset() { - std::lock_guard lock(m_mutex); + /*std::lock_guard lock(m_mutex); m_cache.clear(); m_cache_count = 0; m_hits = 0; - m_misses = 0; + m_misses = 0;*/ } template < @@ -255,7 +259,7 @@ TaggedCache< KeyEqual, Mutex>::touch_if_exists(KeyComparable const& key) { - std::lock_guard lock(m_mutex); + /*std::lock_guard lock(m_mutex); auto const iter(m_cache.find(key)); if (iter == m_cache.end()) { @@ -264,7 +268,8 @@ TaggedCache< } iter->second.touch(m_clock.now()); ++m_stats.hits; - return true; + return true;*/ + return false; } template < @@ -287,7 +292,7 @@ TaggedCache< KeyEqual, Mutex>::sweep() { - // Keep references to all the stuff we sweep + /*// Keep references to all the stuff we sweep // For performance, each worker thread should exit before the swept data // is destroyed but still within the main cache lock. std::vector allStuffToSweep(m_cache.partitions()); @@ -344,7 +349,7 @@ TaggedCache< << std::chrono::duration_cast( std::chrono::steady_clock::now() - start) .count() - << "ms"; + << "ms";*/ } template < @@ -367,7 +372,7 @@ TaggedCache< KeyEqual, Mutex>::del(const key_type& key, bool valid) { - // Remove from cache, if !valid, remove from map too. Returns true if + /*// Remove from cache, if !valid, remove from map too. Returns true if // removed from cache std::lock_guard lock(m_mutex); @@ -390,7 +395,8 @@ TaggedCache< if (!valid || entry.isExpired()) m_cache.erase(cit); - return ret; + return ret;*/ + return false; } template < @@ -418,7 +424,7 @@ TaggedCache< SharedPointerType& data, R&& replaceCallback) { - // Return canonical value, store if needed, refresh in cache + /*// Return canonical value, store if needed, refresh in cache // Return values: true=we had the data already std::lock_guard lock(m_mutex); @@ -484,7 +490,7 @@ TaggedCache< } entry.ptr = data; - ++m_cache_count; + ++m_cache_count;*/ return false; } @@ -560,11 +566,12 @@ TaggedCache< KeyEqual, Mutex>::fetch(const key_type& key) { - std::lock_guard l(m_mutex); + /*std::lock_guard l(m_mutex); auto ret = initialFetch(key, l); if (!ret) ++m_misses; - return ret; + return ret;*/ + return {}; } template < @@ -627,7 +634,7 @@ TaggedCache< Mutex>::insert(key_type const& key) -> std::enable_if_t { - std::lock_guard lock(m_mutex); + /*std::lock_guard lock(m_mutex); clock_type::time_point const now(m_clock.now()); auto [it, inserted] = m_cache.emplace( std::piecewise_construct, @@ -635,7 +642,8 @@ TaggedCache< std::forward_as_tuple(now)); if (!inserted) it->second.last_access = now; - return inserted; + return inserted;*/ + return false; } template < @@ -658,14 +666,15 @@ TaggedCache< KeyEqual, Mutex>::retrieve(const key_type& key, T& data) { - // retrieve the value of the stored data + /*// retrieve the value of the stored data auto entry = fetch(key); if (!entry) return false; data = *entry; - return true; + return true;*/ + return false; } template < @@ -713,12 +722,12 @@ TaggedCache< { std::vector v; - { + /*{ std::lock_guard lock(m_mutex); v.reserve(m_cache.size()); for (auto const& _ : m_cache) v.push_back(_.first); - } + }*/ return v; } @@ -743,11 +752,12 @@ TaggedCache< KeyEqual, Mutex>::rate() const { - std::lock_guard lock(m_mutex); + /*std::lock_guard lock(m_mutex); auto const tot = m_hits + m_misses; if (tot == 0) return 0; - return double(m_hits) / tot; + return double(m_hits) / tot;*/ + return 0.0; } template < @@ -771,27 +781,29 @@ TaggedCache< KeyEqual, Mutex>::fetch(key_type const& digest, Handler const& h) { - { + /*{ std::lock_guard l(m_mutex); if (auto ret = initialFetch(digest, l)) return ret; - } + }*/ auto sle = h(); if (!sle) return {}; - std::lock_guard l(m_mutex); + /*std::lock_guard l(m_mutex); ++m_misses; auto const [it, inserted] = m_cache.emplace(digest, Entry(m_clock.now(), std::move(sle))); if (!inserted) it->second.touch(m_clock.now()); - return it->second.ptr.getStrong(); + return it->second.ptr.getStrong();*/ + + return sle; } // End CachedSLEs functions. -template < +/*template < class Key, class T, bool IsKeyCache, @@ -834,7 +846,7 @@ TaggedCache< m_cache.erase(cit); return {}; -} +}*/ template < class Key, @@ -860,17 +872,17 @@ TaggedCache< { beast::insight::Gauge::value_type hit_rate(0); - { + /*{ std::lock_guard lock(m_mutex); auto const total(m_hits + m_misses); if (total != 0) hit_rate = (m_hits * 100) / total; - } + }*/ m_stats.hit_rate.set(hit_rate); } } -template < +/*template < class Key, class T, bool IsKeyCache, @@ -1022,7 +1034,7 @@ TaggedCache< allRemovals += cacheRemovals; }); -} +}*/ } // namespace ripple