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

Refactor Shared Cache configuration #11567

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 0 additions & 88 deletions ydb/core/cms/console/shared_cache_configurator.cpp

This file was deleted.

11 changes: 0 additions & 11 deletions ydb/core/cms/console/shared_cache_configurator.h

This file was deleted.

2 changes: 0 additions & 2 deletions ydb/core/cms/console/ya.make
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ SRCS(
modifications_validator.cpp
modifications_validator.h
net_classifier_updater.cpp
shared_cache_configurator.cpp
shared_cache_configurator.h
tx_processor.cpp
tx_processor.h
util.cpp
Expand Down
34 changes: 6 additions & 28 deletions ydb/core/driver_lib/run/kikimr_services_initializers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
#include <ydb/core/cms/console/immediate_controls_configurator.h>
#include <ydb/core/cms/console/jaeger_tracing_configurator.h>
#include <ydb/core/cms/console/log_settings_configurator.h>
#include <ydb/core/cms/console/shared_cache_configurator.h>
#include <ydb/core/cms/console/validators/core_validators.h>
#include <ydb/core/cms/http.h>

Expand Down Expand Up @@ -1092,38 +1091,17 @@ TSharedCacheInitializer::TSharedCacheInitializer(const TKikimrRunConfig& runConf
void TSharedCacheInitializer::InitializeServices(
NActors::TActorSystemSetup* setup,
const NKikimr::TAppData* appData) {
auto config = MakeHolder<TSharedPageCacheConfig>();

NKikimrSharedCache::TSharedCacheConfig cfg;
NKikimrSharedCache::TSharedCacheConfig config;
if (Config.HasBootstrapConfig() && Config.GetBootstrapConfig().HasSharedCacheConfig()) {
cfg.MergeFrom(Config.GetBootstrapConfig().GetSharedCacheConfig());
config.MergeFrom(Config.GetBootstrapConfig().GetSharedCacheConfig());
}
if (Config.HasSharedCacheConfig()) {
cfg.MergeFrom(Config.GetSharedCacheConfig());
config.MergeFrom(Config.GetSharedCacheConfig());
}

if (cfg.HasMemoryLimit() && cfg.GetMemoryLimit() != 0) {
// config limit is optional
// if preserved apply both memory controller limit and config limit
config->LimitBytes = cfg.GetMemoryLimit();
} else {
config->LimitBytes = {};
}
config->TotalAsyncQueueInFlyLimit = cfg.GetAsyncQueueInFlyLimit();
config->TotalScanQueueInFlyLimit = cfg.GetScanQueueInFlyLimit();
config->ReplacementPolicy = cfg.GetReplacementPolicy();
config->ActivePagesReservationPercent = cfg.GetActivePagesReservationPercent();

TIntrusivePtr<::NMonitoring::TDynamicCounters> tabletGroup = GetServiceCounters(appData->Counters, "tablets");
TIntrusivePtr<::NMonitoring::TDynamicCounters> sausageGroup = tabletGroup->GetSubgroup("type", "S_CACHE");
config->Counters = new TSharedPageCacheCounters(sausageGroup);

setup->LocalServices.push_back(std::pair<TActorId, TActorSetupCmd>(MakeSharedPageCacheId(0),
TActorSetupCmd(CreateSharedPageCache(std::move(config)), TMailboxType::ReadAsFilled, appData->UserPoolId)));

auto *configurator = NConsole::CreateSharedCacheConfigurator();
setup->LocalServices.emplace_back(TActorId(),
TActorSetupCmd(configurator, TMailboxType::HTSwap, appData->UserPoolId));
auto* actor = NSharedCache::CreateSharedPageCache(config, appData->Counters);
setup->LocalServices.emplace_back(NSharedCache::MakeSharedPageCacheId(0),
TActorSetupCmd(actor, TMailboxType::ReadAsFilled, appData->UserPoolId));
}

// TBlobCacheInitializer
Expand Down
9 changes: 5 additions & 4 deletions ydb/core/memory_controller/memory_controller_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace NKikimr::NMemory {

using namespace Tests;
using namespace NSharedCache;

namespace {

Expand Down Expand Up @@ -77,8 +78,8 @@ class TWithMemoryControllerServer : public TServer {
nodeIndex);
}

SharedPageCacheCounters = MakeIntrusive<TSharedPageCacheCounters>(Runtime->GetDynamicCounters());
MemoryControllerCounters = GetServiceCounters(Runtime->GetDynamicCounters(), "utils")->FindSubgroup("component", "memory_controller");
SharedPageCacheCounters = MakeHolder<TSharedPageCacheCounters>(GetServiceCounters(Runtime->GetDynamicCounters(), "tablets")->GetSubgroup("type", "S_CACHE"));
MemoryControllerCounters = GetServiceCounters(Runtime->GetDynamicCounters(), "utils")->GetSubgroup("component", "memory_controller");

Runtime->SetLogPriority(NKikimrServices::MEMORY_CONTROLLER, NLog::PRI_TRACE);
Runtime->SetLogPriority(NKikimrServices::TABLET_SAUSAGECACHE, NLog::PRI_TRACE);
Expand All @@ -89,7 +90,7 @@ class TWithMemoryControllerServer : public TServer {
TIntrusivePtr<TProcessMemoryInfoProvider> ProcessMemoryInfoProvider;

public:
TIntrusivePtr<TSharedPageCacheCounters> SharedPageCacheCounters;
THolder<TSharedPageCacheCounters> SharedPageCacheCounters;
TIntrusivePtr<::NMonitoring::TDynamicCounters> MemoryControllerCounters;
TProcessMemoryInfo* ProcessMemoryInfo;
};
Expand Down Expand Up @@ -332,7 +333,7 @@ Y_UNIT_TEST(SharedCache_ConfigLimit) {

auto memoryControllerConfig = serverSettings.AppConfig->MutableMemoryControllerConfig();
memoryControllerConfig->SetHardLimitBytes(300_MB);
serverSettings.CacheParams.Shared = 100_MB;
serverSettings.AppConfig->MutableSharedCacheConfig()->SetMemoryLimit(100_MB);

auto server = MakeIntrusive<TWithMemoryControllerServer>(serverSettings);
auto& runtime = *server->GetRuntime();
Expand Down
6 changes: 3 additions & 3 deletions ydb/core/mind/node_broker_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ void SetupServices(TTestActorRuntime &runtime,
SetupNodeWhiteboard(runtime, nodeIndex);
SetupTabletResolver(runtime, nodeIndex);
SetupResourceBroker(runtime, nodeIndex, {});
SetupSharedPageCache(runtime, nodeIndex, NFake::TCaches{
.Shared = 1,
});
NSharedCache::TSharedCacheConfig sharedCacheConfig;
sharedCacheConfig.SetMemoryLimit(0);
SetupSharedPageCache(runtime, nodeIndex, sharedCacheConfig);
SetupSchemeCache(runtime, nodeIndex, DOMAIN_NAME);
}

Expand Down
2 changes: 1 addition & 1 deletion ydb/core/tablet_flat/flat_executor_bootlogic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ NBoot::TSpawned TExecutorBootLogic::LoadPages(NBoot::IStep *step, TAutoPtr<NPage
Y_ABORT_UNLESS(success, "IPageCollection queued twice for loading");

Ops->Send(
MakeSharedPageCacheId(),
NSharedCache::MakeSharedPageCacheId(),
new NSharedCache::TEvRequest(
NBlockIO::EPriority::Fast,
req,
Expand Down
18 changes: 11 additions & 7 deletions ydb/core/tablet_flat/flat_executor_ut.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "flat_dbase_sz_env.h"
#include "flat_executor_ut_common.h"
#include <ydb/core/base/counters.h>

namespace NKikimr {
namespace NTabletFlatExecutor {
Expand Down Expand Up @@ -571,6 +572,9 @@ class TTestFlatTablet : public TActor<TTestFlatTablet>, public TTabletExecutedFl
}
};

THolder<TSharedPageCacheCounters> GetSharedPageCounters(TMyEnvBase& env) {
return MakeHolder<TSharedPageCacheCounters>(GetServiceCounters(env->GetDynamicCounters(), "tablets")->GetSubgroup("type", "S_CACHE"));
};

/**
* Test scan going in parallel with compactions.
Expand Down Expand Up @@ -6229,7 +6233,7 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorBTreeIndex) {
auto &appData = env->GetAppData();
UNIT_ASSERT_VALUES_EQUAL(appData.FeatureFlags.HasEnableLocalDBBtreeIndex(), false);
UNIT_ASSERT_VALUES_EQUAL(appData.FeatureFlags.HasEnableLocalDBFlatIndex(), false);
auto counters = MakeIntrusive<TSharedPageCacheCounters>(env->GetDynamicCounters());
auto counters = GetSharedPageCounters(env);
int readRows = 0, failedAttempts = 0;

env.FireDummyTablet(ui32(NFake::TDummy::EFlg::Comp));
Expand Down Expand Up @@ -6267,7 +6271,7 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorBTreeIndex) {

auto &appData = env->GetAppData();
appData.FeatureFlags.SetEnableLocalDBBtreeIndex(true);
auto counters = MakeIntrusive<TSharedPageCacheCounters>(env->GetDynamicCounters());
auto counters = GetSharedPageCounters(env);
int readRows = 0, failedAttempts = 0;

env.FireDummyTablet(ui32(NFake::TDummy::EFlg::Comp));
Expand Down Expand Up @@ -6306,7 +6310,7 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorBTreeIndex) {
auto &appData = env->GetAppData();

appData.FeatureFlags.SetEnableLocalDBBtreeIndex(false);
auto counters = MakeIntrusive<TSharedPageCacheCounters>(env->GetDynamicCounters());
auto counters = GetSharedPageCounters(env);
int readRows = 0, failedAttempts = 0;

env.FireDummyTablet(ui32(NFake::TDummy::EFlg::Comp));
Expand Down Expand Up @@ -6345,7 +6349,7 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorBTreeIndex) {
auto &appData = env->GetAppData();
appData.FeatureFlags.SetEnableLocalDBBtreeIndex(true);
appData.FeatureFlags.SetEnableLocalDBFlatIndex(false);
auto counters = MakeIntrusive<TSharedPageCacheCounters>(env->GetDynamicCounters());
auto counters = GetSharedPageCounters(env);
int readRows = 0, failedAttempts = 0;

env.FireDummyTablet(ui32(NFake::TDummy::EFlg::Comp));
Expand Down Expand Up @@ -6384,7 +6388,7 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorBTreeIndex) {
auto &appData = env->GetAppData();
appData.FeatureFlags.SetEnableLocalDBBtreeIndex(false);
appData.FeatureFlags.SetEnableLocalDBFlatIndex(false);
auto counters = MakeIntrusive<TSharedPageCacheCounters>(env->GetDynamicCounters());
auto counters = GetSharedPageCounters(env);
int readRows = 0, failedAttempts = 0;

env.FireDummyTablet(ui32(NFake::TDummy::EFlg::Comp));
Expand Down Expand Up @@ -6423,7 +6427,7 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorBTreeIndex) {
auto &appData = env->GetAppData();
appData.FeatureFlags.SetEnableLocalDBBtreeIndex(true);
appData.FeatureFlags.SetEnableLocalDBFlatIndex(true);
auto counters = MakeIntrusive<TSharedPageCacheCounters>(env->GetDynamicCounters());
auto counters = GetSharedPageCounters(env);
int readRows = 0, failedAttempts = 0;

env.FireDummyTablet(ui32(NFake::TDummy::EFlg::Comp));
Expand Down Expand Up @@ -6463,7 +6467,7 @@ Y_UNIT_TEST_SUITE(TFlatTableExecutorBTreeIndex) {

auto &appData = env->GetAppData();
appData.FeatureFlags.SetEnableLocalDBBtreeIndex(true);
auto counters = MakeIntrusive<TSharedPageCacheCounters>(env->GetDynamicCounters());
auto counters = GetSharedPageCounters(env);
int readRows = 0, failedAttempts = 0;

env.FireDummyTablet(ui32(NFake::TDummy::EFlg::Comp));
Expand Down
2 changes: 1 addition & 1 deletion ydb/core/tablet_flat/flat_part_loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ namespace NTable {
{
if (cookie == 0 && NeedPages.erase(loaded.PageId)) {
auto type = Cache->GetPageType(loaded.PageId);
SavedPages[loaded.PageId] = TPinnedPageRef(loaded.Page).GetData();
SavedPages[loaded.PageId] = NSharedCache::TPinnedPageRef(loaded.Page).GetData();
if (type != EPage::FlatIndex) {
// hack: saving flat index to private cache will break sticky logic
// keep it in shared cache only for now
Expand Down
2 changes: 2 additions & 0 deletions ydb/core/tablet_flat/flat_sausagecache.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
namespace NKikimr {
namespace NTabletFlatExecutor {

using namespace NSharedCache;

struct TPrivatePageCachePinPad : public TAtomicRefCount<TPrivatePageCachePinPad> {
// no internal state
};
Expand Down
2 changes: 1 addition & 1 deletion ydb/core/tablet_flat/shared_cache_clock_pro.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <library/cpp/monlib/counters/counters.h>
#include <library/cpp/monlib/dynamic_counters/counters.h>

namespace NKikimr::NCache {
namespace NKikimr::NSharedCache {

// TODO: remove template args and make some page base class

Expand Down
2 changes: 1 addition & 1 deletion ydb/core/tablet_flat/shared_cache_clock_pro_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <util/random/mersenne.h>
#include "shared_cache_clock_pro.h"

namespace NKikimr::NCache {
namespace NKikimr::NSharedCache {

namespace {

Expand Down
5 changes: 1 addition & 4 deletions ydb/core/tablet_flat/shared_cache_events.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
#include <util/generic/hash.h>
#include <util/generic/hash_set.h>

namespace NKikimr {
namespace NSharedCache {

namespace NKikimr::NSharedCache {
using EPriority = NTabletFlatExecutor::NBlockIO::EPriority;

enum EEv {
Expand Down Expand Up @@ -129,7 +127,6 @@ namespace NSharedCache {
THashMap<TLogoBlobID, TActions> Actions;
};
}
}

template<> inline
void Out<NKikimr::NTabletFlatExecutor::NBlockIO::EPriority>(
Expand Down
2 changes: 1 addition & 1 deletion ydb/core/tablet_flat/shared_cache_s3fifo.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <library/cpp/monlib/counters/counters.h>
#include <library/cpp/monlib/dynamic_counters/counters.h>

namespace NKikimr::NCache {
namespace NKikimr::NSharedCache {

// TODO: remove template args and make some page base class

Expand Down
2 changes: 1 addition & 1 deletion ydb/core/tablet_flat/shared_cache_s3fifo_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <library/cpp/resource/resource.h>
#include "shared_cache_s3fifo.h"

namespace NKikimr::NCache {
namespace NKikimr::NSharedCache {

namespace {

Expand Down
2 changes: 1 addition & 1 deletion ydb/core/tablet_flat/shared_cache_switchable.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <library/cpp/monlib/counters/counters.h>
#include <library/cpp/monlib/dynamic_counters/counters.h>

namespace NKikimr::NCache {
namespace NKikimr::NSharedCache {

template <typename TPage, typename TPageTraits>
class TSwitchableCache : public ICacheCache<TPage> {
Expand Down
2 changes: 1 addition & 1 deletion ydb/core/tablet_flat/shared_cache_switchable_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <ydb/core/tablet_flat/shared_cache_switchable.h>
#include <ydb/core/util/cache_cache_iface.h>

namespace NKikimr::NCache {
namespace NKikimr::NSharedCache {

namespace {

Expand Down
Loading
Loading