Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New caching strategies #34651

Merged
merged 30 commits into from Aug 12, 2022
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
d7bdf9e
Add SLRU cache
alexX512 Feb 16, 2022
a0d2da7
Add tests for SLRU cache
alexX512 Mar 10, 2022
1133e42
Add CacheBase clas instead of LRUCache and SLRUCache fo simpler conf…
alexX512 Apr 28, 2022
c606ccc
Fix formatting problems
alexX512 Apr 28, 2022
6bf29cb
Change class LRUCache to class CachBase. Check running CacheBase with…
alexX512 Apr 30, 2022
4f52efd
Build fix
alexX512 Apr 30, 2022
910645a
Include fix in SLRUCachePolicy.h
alexX512 Apr 30, 2022
9940b69
Include fix in ICachePolicy.h
alexX512 Apr 30, 2022
a94950d
Test only with LRU
alexX512 Apr 30, 2022
69cc89e
Check with default cache policy = LRU
alexX512 May 10, 2022
50a8887
Add [[maybe_unused]] locks and delete all objects from cache queue
alexX512 May 14, 2022
994a9fc
Minor fixes
alexX512 May 14, 2022
daab749
Test with default cache policy = SLRU
alexX512 May 14, 2022
a238e34
Unblocking get max_size
alexX512 May 15, 2022
c044fee
Test with LRU
alexX512 May 15, 2022
8be6277
Test with SLRU and debug logs
alexX512 May 15, 2022
a057e16
Fix remove operation, add evict ion i from cachef number of elements …
alexX512 May 17, 2022
5bed94a
Restart GH
alexX512 May 17, 2022
2be7256
Add loading of mark cache policy
alexX512 Jun 14, 2022
77def20
Fix typos in some js code and ignore some typos
alexX512 Jun 14, 2022
8adf9f2
fix compile error
alexX512 Jun 30, 2022
62f84b8
Review fixes
alexX512 Aug 7, 2022
269631c
Fix typo
alexX512 Aug 7, 2022
1c9d40e
Fix build error
alexX512 Aug 7, 2022
f16c668
Delete Args from CacheBase
alexX512 Aug 7, 2022
c1a8c61
Restart GH
alexX512 Aug 8, 2022
c9c26d4
Fix review
alexX512 Aug 8, 2022
ca93dae
Restart GH
alexX512 Aug 8, 2022
2162470
Fix tidy build
alexX512 Aug 9, 2022
06cb873
Delete TODO
alexX512 Aug 11, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions programs/local/LocalServer.cpp
Expand Up @@ -558,14 +558,16 @@ void LocalServer::processConfig()
global_context->getProcessList().setMaxSize(0);

/// Size of cache for uncompressed blocks. Zero means disabled.
String uncompressed_cache_policy = config().getString("uncompressed_cache_policy", "");
size_t uncompressed_cache_size = config().getUInt64("uncompressed_cache_size", 0);
if (uncompressed_cache_size)
global_context->setUncompressedCache(uncompressed_cache_size);
global_context->setUncompressedCache(uncompressed_cache_size, uncompressed_cache_policy);

/// Size of cache for marks (index of MergeTree family of tables).
String mark_cache_policy = config().getString("mark_cache_policy", "");
size_t mark_cache_size = config().getUInt64("mark_cache_size", 5368709120);
if (mark_cache_size)
global_context->setMarkCache(mark_cache_size);
global_context->setMarkCache(mark_cache_size, mark_cache_policy);

/// Size of cache for uncompressed blocks of MergeTree indices. Zero means disabled.
size_t index_uncompressed_cache_size = config().getUInt64("index_uncompressed_cache_size", 0);
Expand Down
7 changes: 5 additions & 2 deletions programs/server/Server.cpp
Expand Up @@ -1362,14 +1362,16 @@ int Server::main(const std::vector<std::string> & /*args*/)
size_t max_cache_size = memory_amount * cache_size_to_ram_max_ratio;

/// Size of cache for uncompressed blocks. Zero means disabled.
String uncompressed_cache_policy = config().getString("uncompressed_cache_policy", "");
LOG_INFO(log, "Uncompressed cache policy name {}", uncompressed_cache_policy);
size_t uncompressed_cache_size = config().getUInt64("uncompressed_cache_size", 0);
if (uncompressed_cache_size > max_cache_size)
{
uncompressed_cache_size = max_cache_size;
LOG_INFO(log, "Uncompressed cache size was lowered to {} because the system has low amount of memory",
formatReadableSizeWithBinarySuffix(uncompressed_cache_size));
}
global_context->setUncompressedCache(uncompressed_cache_size);
global_context->setUncompressedCache(uncompressed_cache_size, uncompressed_cache_policy);

/// Load global settings from default_profile and system_profile.
global_context->setDefaultProfiles(config());
Expand All @@ -1388,6 +1390,7 @@ int Server::main(const std::vector<std::string> & /*args*/)

/// Size of cache for marks (index of MergeTree family of tables).
size_t mark_cache_size = config().getUInt64("mark_cache_size", 5368709120);
String mark_cache_policy = config().getString("mark_cache_policy", "");
if (!mark_cache_size)
LOG_ERROR(log, "Too low mark cache size will lead to severe performance degradation.");
if (mark_cache_size > max_cache_size)
Expand All @@ -1396,7 +1399,7 @@ int Server::main(const std::vector<std::string> & /*args*/)
LOG_INFO(log, "Mark cache size was lowered to {} because the system has low amount of memory",
formatReadableSizeWithBinarySuffix(mark_cache_size));
}
global_context->setMarkCache(mark_cache_size);
global_context->setMarkCache(mark_cache_size, mark_cache_policy);

/// Size of cache for uncompressed blocks of MergeTree indices. Zero means disabled.
size_t index_uncompressed_cache_size = config().getUInt64("index_uncompressed_cache_size", 0);
Expand Down
4 changes: 2 additions & 2 deletions src/Access/MultipleAccessStorage.h
Expand Up @@ -2,7 +2,7 @@

#include <Access/IAccessStorage.h>
#include <base/defines.h>
#include <Common/LRUCache.h>
#include <Common/CacheBase.h>
#include <mutex>


Expand Down Expand Up @@ -63,7 +63,7 @@ class MultipleAccessStorage : public IAccessStorage
std::shared_ptr<const Storages> getStoragesInternal() const;

std::shared_ptr<const Storages> nested_storages TSA_GUARDED_BY(mutex);
mutable LRUCache<UUID, Storage> ids_cache TSA_GUARDED_BY(mutex);
mutable CacheBase<UUID, Storage> ids_cache TSA_GUARDED_BY(mutex);
mutable std::mutex mutex;
};

Expand Down