diff options
author | lavrinovich <lavrinovich@yandex-team.com> | 2023-11-07 16:55:34 +0300 |
---|---|---|
committer | lavrinovich <lavrinovich@yandex-team.com> | 2023-11-07 17:25:14 +0300 |
commit | d2de62164bfaeedfd9a65c5e0e2adfd748ab1f37 (patch) | |
tree | a9943b9dc6c096d68c844e16505af9dd9a757899 | |
parent | b1972492282e41abaf605831cd634765db80d2c8 (diff) | |
download | ydb-d2de62164bfaeedfd9a65c5e0e2adfd748ab1f37.tar.gz |
Shared LM weight cache
-rw-r--r-- | yt/yt/core/misc/sync_cache-inl.h | 11 | ||||
-rw-r--r-- | yt/yt/core/misc/sync_cache.h | 2 |
2 files changed, 7 insertions, 6 deletions
diff --git a/yt/yt/core/misc/sync_cache-inl.h b/yt/yt/core/misc/sync_cache-inl.h index bd80cfa1e0..ef675192d1 100644 --- a/yt/yt/core/misc/sync_cache-inl.h +++ b/yt/yt/core/misc/sync_cache-inl.h @@ -142,13 +142,14 @@ TSyncSlruCacheBase<TKey, TValue, THash>::Find(const TKey& key) template <class TKey, class TValue, class THash> std::vector<typename TSyncSlruCacheBase<TKey, TValue, THash>::TValuePtr> -TSyncSlruCacheBase<TKey, TValue, THash>::GetAll() +TSyncSlruCacheBase<TKey, TValue, THash>::GetAll() const { std::vector<TValuePtr> result; - result.reseve(GetSize()); - for (const auto& shard : Shards_) { - auto guard = ReaderGuard(shard->SpinLock); - for (const auto& [key, item] : shard->ItemMap) { + result.reserve(GetSize()); + for (int index = 0; index < Config_->ShardCount; ++index) { + const auto& shard = Shards_[index]; + auto guard = ReaderGuard(shard.SpinLock); + for (const auto& [key, item] : shard.ItemMap) { result.push_back(item->Value); } } diff --git a/yt/yt/core/misc/sync_cache.h b/yt/yt/core/misc/sync_cache.h index 399dec86be..ab02908bc0 100644 --- a/yt/yt/core/misc/sync_cache.h +++ b/yt/yt/core/misc/sync_cache.h @@ -42,7 +42,7 @@ public: using TValuePtr = TIntrusivePtr<TValue>; int GetSize() const; - std::vector<TValuePtr> GetAll(); + std::vector<TValuePtr> GetAll() const; TValuePtr Find(const TKey& key); |