From 6b7928dcbcd8e0701229fd5bbe93719b01111810 Mon Sep 17 00:00:00 2001 From: Alexander Avdonkin Date: Fri, 25 Oct 2024 08:29:41 +0000 Subject: [PATCH 1/3] Added time counter for local db precharge --- ydb/core/tx/columnshard/columnshard__init.cpp | 8 ++++++-- ydb/core/tx/columnshard/columnshard_impl.cpp | 4 +++- ydb/core/tx/columnshard/columnshard_impl.h | 1 + 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/ydb/core/tx/columnshard/columnshard__init.cpp b/ydb/core/tx/columnshard/columnshard__init.cpp index 92b13656255d..fb30b3fa3364 100644 --- a/ydb/core/tx/columnshard/columnshard__init.cpp +++ b/ydb/core/tx/columnshard/columnshard__init.cpp @@ -99,8 +99,12 @@ bool TTxInit::Precharge(TTransactionContext& txc) { } bool TTxInit::ReadEverything(TTransactionContext& txc, const TActorContext& ctx) { - if (!Precharge(txc)) { - return false; + { + TLoadTimeSignals::TLoadTimer timer = Self->PrechargeTimeCounters.StartGuard(); + if (!Precharge(txc)) { + timer.AddLoadingFail(); + return false; + } } NIceDb::TNiceDb db(txc.DB); diff --git a/ydb/core/tx/columnshard/columnshard_impl.cpp b/ydb/core/tx/columnshard/columnshard_impl.cpp index 764da171f626..ebbfaaf4b426 100644 --- a/ydb/core/tx/columnshard/columnshard_impl.cpp +++ b/ydb/core/tx/columnshard/columnshard_impl.cpp @@ -89,7 +89,9 @@ TColumnShard::TColumnShard(TTabletStorageInfo* info, const TActorId& tablet) , TTLTaskSubscription(NOlap::TTTLColumnEngineChanges::StaticTypeName(), Counters.GetSubscribeCounters()) , BackgroundController(Counters.GetBackgroundControllerCounters()) , NormalizerController(StoragesManager, Counters.GetSubscribeCounters()) - , SysLocks(this) { + , SysLocks(this) + , PrechargeTimeCounters("Precharge") +{ } void TColumnShard::OnDetach(const TActorContext& ctx) { diff --git a/ydb/core/tx/columnshard/columnshard_impl.h b/ydb/core/tx/columnshard/columnshard_impl.h index 74cd2fd8796b..b38df21f4c04 100644 --- a/ydb/core/tx/columnshard/columnshard_impl.h +++ b/ydb/core/tx/columnshard/columnshard_impl.h @@ -494,6 +494,7 @@ class TColumnShard: public TActor, public NTabletFlatExecutor::TTa TLimits Limits; NOlap::TNormalizationController NormalizerController; NDataShard::TSysLocks SysLocks; + TLoadTimeSignals PrechargeTimeCounters; static TDuration GetMaxReadStaleness(); void TryRegisterMediatorTimeCast(); From 94b1a8cfa2674b8ecb63a14a7984cd24707a3111 Mon Sep 17 00:00:00 2001 From: Alexander Avdonkin Date: Mon, 28 Oct 2024 09:44:50 +0000 Subject: [PATCH 2/3] Moved PrechargeTimeCounters to TTableLoadTimeCounters --- ydb/core/tx/columnshard/columnshard__init.cpp | 4 ++-- ydb/core/tx/columnshard/columnshard_impl.cpp | 1 - ydb/core/tx/columnshard/columnshard_impl.h | 1 - ydb/core/tx/columnshard/counters/common_data.h | 2 ++ ydb/core/tx/columnshard/tables_manager.h | 2 ++ 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ydb/core/tx/columnshard/columnshard__init.cpp b/ydb/core/tx/columnshard/columnshard__init.cpp index fb30b3fa3364..0c85fc9bf6d5 100644 --- a/ydb/core/tx/columnshard/columnshard__init.cpp +++ b/ydb/core/tx/columnshard/columnshard__init.cpp @@ -99,8 +99,9 @@ bool TTxInit::Precharge(TTransactionContext& txc) { } bool TTxInit::ReadEverything(TTransactionContext& txc, const TActorContext& ctx) { + TTablesManager tManagerLocal(Self->StoragesManager, Self->TabletID()); { - TLoadTimeSignals::TLoadTimer timer = Self->PrechargeTimeCounters.StartGuard(); + TLoadTimeSignals::TLoadTimer timer = tManagerLocal.LoadTimeCounters->PrechargeTimeCounters.StartGuard(); if (!Precharge(txc)) { timer.AddLoadingFail(); return false; @@ -112,7 +113,6 @@ bool TTxInit::ReadEverything(TTransactionContext& txc, const TActorContext& ctx) NOlap::TDbWrapper dbTable(txc.DB, &dsGroupSelector); { ACFL_DEBUG("step", "TTablesManager::Load_Start"); - TTablesManager tManagerLocal(Self->StoragesManager, Self->TabletID()); { TMemoryProfileGuard g("TTxInit/TTablesManager"); if (!tManagerLocal.InitFromDB(db)) { diff --git a/ydb/core/tx/columnshard/columnshard_impl.cpp b/ydb/core/tx/columnshard/columnshard_impl.cpp index ebbfaaf4b426..6d03f3dae2a2 100644 --- a/ydb/core/tx/columnshard/columnshard_impl.cpp +++ b/ydb/core/tx/columnshard/columnshard_impl.cpp @@ -90,7 +90,6 @@ TColumnShard::TColumnShard(TTabletStorageInfo* info, const TActorId& tablet) , BackgroundController(Counters.GetBackgroundControllerCounters()) , NormalizerController(StoragesManager, Counters.GetSubscribeCounters()) , SysLocks(this) - , PrechargeTimeCounters("Precharge") { } diff --git a/ydb/core/tx/columnshard/columnshard_impl.h b/ydb/core/tx/columnshard/columnshard_impl.h index b38df21f4c04..74cd2fd8796b 100644 --- a/ydb/core/tx/columnshard/columnshard_impl.h +++ b/ydb/core/tx/columnshard/columnshard_impl.h @@ -494,7 +494,6 @@ class TColumnShard: public TActor, public NTabletFlatExecutor::TTa TLimits Limits; NOlap::TNormalizationController NormalizerController; NDataShard::TSysLocks SysLocks; - TLoadTimeSignals PrechargeTimeCounters; static TDuration GetMaxReadStaleness(); void TryRegisterMediatorTimeCast(); diff --git a/ydb/core/tx/columnshard/counters/common_data.h b/ydb/core/tx/columnshard/counters/common_data.h index 79af277b7948..5e6cfc13c2b4 100644 --- a/ydb/core/tx/columnshard/counters/common_data.h +++ b/ydb/core/tx/columnshard/counters/common_data.h @@ -120,6 +120,7 @@ class TTableLoadTimeCounters { NColumnShard::TLoadTimeSignals SchemaPresetLoadTimeCounters; NColumnShard::TLoadTimeSignals TableVersionsLoadTimeCounters; NColumnShard::TLoadTimeSignals SchemaPresetVersionsLoadTimeCounters; + NColumnShard::TLoadTimeSignals PrechargeTimeCounters; public: TTableLoadTimeCounters() @@ -127,6 +128,7 @@ class TTableLoadTimeCounters { , SchemaPresetLoadTimeCounters("SchemaPreset") , TableVersionsLoadTimeCounters("TableVersionss") , SchemaPresetVersionsLoadTimeCounters("SchemaPresetVersions") + , PrechargeTimeCounters("Precharge") { } }; diff --git a/ydb/core/tx/columnshard/tables_manager.h b/ydb/core/tx/columnshard/tables_manager.h index 76e2e3851276..62fddd4b4676 100644 --- a/ydb/core/tx/columnshard/tables_manager.h +++ b/ydb/core/tx/columnshard/tables_manager.h @@ -151,6 +151,8 @@ class TTablesManager { std::unique_ptr LoadTimeCounters; ui64 TabletId = 0; public: + friend class TTxInit; + TTablesManager(const std::shared_ptr& storagesManager, const ui64 tabletId); bool TryFinalizeDropPathOnExecute(NTable::TDatabase& dbTable, const ui64 pathId) const; From f87d526317effea5664355da1387832301b057d0 Mon Sep 17 00:00:00 2001 From: Alexander Avdonkin Date: Tue, 29 Oct 2024 08:17:33 +0000 Subject: [PATCH 3/3] Use accessor method rather than friend --- ydb/core/tx/columnshard/columnshard__init.cpp | 2 +- ydb/core/tx/columnshard/tables_manager.h | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ydb/core/tx/columnshard/columnshard__init.cpp b/ydb/core/tx/columnshard/columnshard__init.cpp index 0c85fc9bf6d5..ad2db7e1a672 100644 --- a/ydb/core/tx/columnshard/columnshard__init.cpp +++ b/ydb/core/tx/columnshard/columnshard__init.cpp @@ -101,7 +101,7 @@ bool TTxInit::Precharge(TTransactionContext& txc) { bool TTxInit::ReadEverything(TTransactionContext& txc, const TActorContext& ctx) { TTablesManager tManagerLocal(Self->StoragesManager, Self->TabletID()); { - TLoadTimeSignals::TLoadTimer timer = tManagerLocal.LoadTimeCounters->PrechargeTimeCounters.StartGuard(); + TLoadTimeSignals::TLoadTimer timer = tManagerLocal.GetLoadTimeCounters()->PrechargeTimeCounters.StartGuard(); if (!Precharge(txc)) { timer.AddLoadingFail(); return false; diff --git a/ydb/core/tx/columnshard/tables_manager.h b/ydb/core/tx/columnshard/tables_manager.h index 62fddd4b4676..91b351aa884f 100644 --- a/ydb/core/tx/columnshard/tables_manager.h +++ b/ydb/core/tx/columnshard/tables_manager.h @@ -155,6 +155,10 @@ class TTablesManager { TTablesManager(const std::shared_ptr& storagesManager, const ui64 tabletId); + const std::unique_ptr& GetLoadTimeCounters() const { + return LoadTimeCounters; + } + bool TryFinalizeDropPathOnExecute(NTable::TDatabase& dbTable, const ui64 pathId) const; bool TryFinalizeDropPathOnComplete(const ui64 pathId);