From 5854397309bfc9b9cede15e38547e969b878d64d Mon Sep 17 00:00:00 2001 From: Maxim Deb Natkh Date: Tue, 21 Jan 2025 21:02:52 +0100 Subject: [PATCH 1/3] issue-1146: decrease verbosity of loading nodes and noderefs and add option to space out this loading over time --- cloud/filestore/config/storage.proto | 3 +++ cloud/filestore/libs/storage/core/config.cpp | 3 +++ cloud/filestore/libs/storage/core/config.h | 1 + .../storage/tablet/tablet_actor_loadstate.cpp | 27 +++++++++++++++++-- .../tablet_actor_loadstate_noderefs.cpp | 14 +++++----- .../tablet/tablet_actor_loadstate_nodes.cpp | 14 +++++----- .../libs/storage/tablet/tablet_private.h | 10 +++++-- .../filestore/libs/storage/tablet/tablet_tx.h | 10 +++++-- .../libs/storage/tablet/tablet_ut_cache.cpp | 2 ++ 9 files changed, 66 insertions(+), 18 deletions(-) diff --git a/cloud/filestore/config/storage.proto b/cloud/filestore/config/storage.proto index 7838ae1ca7b..cbf57d14089 100644 --- a/cloud/filestore/config/storage.proto +++ b/cloud/filestore/config/storage.proto @@ -512,4 +512,7 @@ message TStorageConfig // proportional to the aforementioned value multiplied my the size of // TRange optional uint64 MixedBlocksOffloadedRangesCapacity = 415; + + // During the InMemoryIndexCache load, the time between the batches loading + optional uint32 InMemoryIndexCacheLoadScheduleTimeout = 416; } diff --git a/cloud/filestore/libs/storage/core/config.cpp b/cloud/filestore/libs/storage/core/config.cpp index d35f7db474c..b63c3c739d2 100644 --- a/cloud/filestore/libs/storage/core/config.cpp +++ b/cloud/filestore/libs/storage/core/config.cpp @@ -220,6 +220,9 @@ using TAliases = NProto::TStorageConfig::TFilestoreAliases; xxx(InMemoryIndexCacheNodesToNodeRefsCapacityRatio, ui64, 0 )\ xxx(InMemoryIndexCacheLoadOnTabletStart, bool, false )\ xxx(InMemoryIndexCacheLoadOnTabletStartRowsPerTx, ui64, 1000000 )\ + xxx(InMemoryIndexCacheLoadScheduleTimeout, \ + TDuration, \ + TDuration::MilliSeconds(0) )\ \ xxx(NonNetworkMetricsBalancingFactor, ui32, 1_KB )\ \ diff --git a/cloud/filestore/libs/storage/core/config.h b/cloud/filestore/libs/storage/core/config.h index 5030d3c6a34..d0c155c16a8 100644 --- a/cloud/filestore/libs/storage/core/config.h +++ b/cloud/filestore/libs/storage/core/config.h @@ -241,6 +241,7 @@ class TStorageConfig ui64 GetInMemoryIndexCacheNodesToNodeRefsCapacityRatio() const; bool GetInMemoryIndexCacheLoadOnTabletStart() const; ui64 GetInMemoryIndexCacheLoadOnTabletStartRowsPerTx() const; + TDuration GetInMemoryIndexCacheLoadScheduleTimeout() const; bool GetAsyncDestroyHandleEnabled() const; TDuration GetAsyncHandleOperationPeriod() const; diff --git a/cloud/filestore/libs/storage/tablet/tablet_actor_loadstate.cpp b/cloud/filestore/libs/storage/tablet/tablet_actor_loadstate.cpp index ed3e082d238..d7775dc7a54 100644 --- a/cloud/filestore/libs/storage/tablet/tablet_actor_loadstate.cpp +++ b/cloud/filestore/libs/storage/tablet/tablet_actor_loadstate.cpp @@ -313,21 +313,44 @@ void TIndexTabletActor::CompleteTx_LoadState( { const ui64 maxRows = Config->GetInMemoryIndexCacheLoadOnTabletStartRowsPerTx(); + const TDuration timeout = + Config->GetInMemoryIndexCacheLoadScheduleTimeout(); // If necessary, code can iteratively call ReadNodeRefs for all nodes. // This will populate cache with node refs and allow us to perform // ListNodes using in-memory index state by knowing that the nodeRefs // cache is exhaustive + LOG_INFO( + ctx, + TFileStoreComponents::TABLET, + "%s LoadNodeRefs started (maxNodeRefs: %lu, timeout: %s)", + LogTag.c_str(), + maxRows, + timeout.ToString()); ctx.Send( SelfId(), - new TEvIndexTabletPrivate::TEvLoadNodeRefsRequest(0, "", maxRows)); + new TEvIndexTabletPrivate::TEvLoadNodeRefsRequest( + 0, + "", + maxRows, + timeout)); // Same logic is performed for batch loading nodes as well. The only // difference is that we do not need to keep track of the exhaustiveness // of the cache + LOG_INFO( + ctx, + TFileStoreComponents::TABLET, + "%s LoadNodes started (maxNodes: %lu, timeout: %s)", + LogTag.c_str(), + maxRows, + timeout.ToString()); ctx.Send( SelfId(), - new TEvIndexTabletPrivate::TEvLoadNodesRequest(0, maxRows)); + new TEvIndexTabletPrivate::TEvLoadNodesRequest( + 0, + maxRows, + timeout)); } ScheduleSyncSessions(ctx); diff --git a/cloud/filestore/libs/storage/tablet/tablet_actor_loadstate_noderefs.cpp b/cloud/filestore/libs/storage/tablet/tablet_actor_loadstate_noderefs.cpp index 9b2996c43ae..ec55f2de092 100644 --- a/cloud/filestore/libs/storage/tablet/tablet_actor_loadstate_noderefs.cpp +++ b/cloud/filestore/libs/storage/tablet/tablet_actor_loadstate_noderefs.cpp @@ -10,7 +10,7 @@ bool TIndexTabletActor::ValidateTx_LoadNodeRefs( const TActorContext& ctx, TTxIndexTablet::TLoadNodeRefs& args) { - LOG_INFO( + LOG_DEBUG( ctx, TFileStoreComponents::TABLET, "%s LoadingNodeRefs (nodeId: %lu, name: %s, maxNodeRefs: %lu)", @@ -36,7 +36,7 @@ bool TIndexTabletActor::PrepareTx_LoadNodeRefs( args.NextNodeId, args.NextCookie); - LOG_INFO( + LOG_DEBUG( ctx, TFileStoreComponents::TABLET, "%s LoadingNodeRefs (nodeId: %lu, name: %s, maxNodeRefs: %lu), read " @@ -55,7 +55,7 @@ void TIndexTabletActor::CompleteTx_LoadNodeRefs( const TActorContext& ctx, TTxIndexTablet::TLoadNodeRefs& args) { - LOG_INFO( + LOG_DEBUG( ctx, TFileStoreComponents::TABLET, "%s LoadNodeRefs iteration completed, next nodeId: %lu, next cookie: " @@ -70,7 +70,8 @@ void TIndexTabletActor::CompleteTx_LoadNodeRefs( new TEvIndexTabletPrivate::TEvLoadNodeRefsRequest( args.NextNodeId, args.NextCookie, - args.MaxNodeRefs)); + args.MaxNodeRefs, + args.ScheduleTimeout)); } else { LOG_INFO( ctx, @@ -90,7 +91,7 @@ void TIndexTabletActor::HandleLoadNodeRefsRequest( { auto* msg = ev->Get(); - LOG_INFO( + LOG_DEBUG( ctx, TFileStoreComponents::TABLET, "%s LoadNodeRefs iteration started (nodeId: %lu, name: %s, " @@ -109,7 +110,8 @@ void TIndexTabletActor::HandleLoadNodeRefsRequest( std::move(requestInfo), msg->NodeId, msg->Cookie, - msg->MaxNodeRefs); + msg->MaxNodeRefs, + msg->ScheduleTimeout); } } // namespace NCloud::NFileStore::NStorage diff --git a/cloud/filestore/libs/storage/tablet/tablet_actor_loadstate_nodes.cpp b/cloud/filestore/libs/storage/tablet/tablet_actor_loadstate_nodes.cpp index 678567de557..c41156eb6ff 100644 --- a/cloud/filestore/libs/storage/tablet/tablet_actor_loadstate_nodes.cpp +++ b/cloud/filestore/libs/storage/tablet/tablet_actor_loadstate_nodes.cpp @@ -10,7 +10,7 @@ bool TIndexTabletActor::ValidateTx_LoadNodes( const TActorContext& ctx, TTxIndexTablet::TLoadNodes& args) { - LOG_INFO( + LOG_DEBUG( ctx, TFileStoreComponents::TABLET, "%s LoadingNodes (nodeId: %lu, maxNodes: %lu)", @@ -31,7 +31,7 @@ bool TIndexTabletActor::PrepareTx_LoadNodes( bool ready = db.ReadNodes(args.NodeId, args.MaxNodes, args.NextNodeId, nodes); - LOG_INFO( + LOG_DEBUG( ctx, TFileStoreComponents::TABLET, "%s LoadingNodes (nodeId: %lu, maxNodes: %lu), read %lu nodes: %s", @@ -48,7 +48,7 @@ void TIndexTabletActor::CompleteTx_LoadNodes( const TActorContext& ctx, TTxIndexTablet::TLoadNodes& args) { - LOG_INFO( + LOG_DEBUG( ctx, TFileStoreComponents::TABLET, "%s LoadNodes iteration completed, next nodeId: %lu", @@ -60,7 +60,8 @@ void TIndexTabletActor::CompleteTx_LoadNodes( SelfId(), new TEvIndexTabletPrivate::TEvLoadNodesRequest( args.NextNodeId, - args.MaxNodes)); + args.MaxNodes, + args.ScheduleTimeout)); } else { LOG_INFO( ctx, @@ -78,7 +79,7 @@ void TIndexTabletActor::HandleLoadNodesRequest( { auto* msg = ev->Get(); - LOG_INFO( + LOG_DEBUG( ctx, TFileStoreComponents::TABLET, "%s LoadNodes iteration started (nodeId: %lu, maxNodes: %lu)", @@ -94,7 +95,8 @@ void TIndexTabletActor::HandleLoadNodesRequest( ctx, std::move(requestInfo), msg->NodeId, - msg->MaxNodes); + msg->MaxNodes, + msg->ScheduleTimeout); } } // namespace NCloud::NFileStore::NStorage diff --git a/cloud/filestore/libs/storage/tablet/tablet_private.h b/cloud/filestore/libs/storage/tablet/tablet_private.h index f4fc7a822c4..effa0f43215 100644 --- a/cloud/filestore/libs/storage/tablet/tablet_private.h +++ b/cloud/filestore/libs/storage/tablet/tablet_private.h @@ -534,14 +534,17 @@ struct TEvIndexTabletPrivate const ui64 NodeId; const TString Cookie; const ui32 MaxNodeRefs; + const TDuration ScheduleTimeout; TLoadNodeRefsRequest( ui64 nodeId, TString cookie, - ui32 maxNodeRefs) + ui32 maxNodeRefs, + TDuration scheduleTimeout) : NodeId(nodeId) , Cookie(std::move(cookie)) , MaxNodeRefs(maxNodeRefs) + , ScheduleTimeout(scheduleTimeout) {} }; @@ -553,12 +556,15 @@ struct TEvIndexTabletPrivate { const ui64 NodeId; const ui32 MaxNodes; + const TDuration ScheduleTimeout; TLoadNodesRequest( ui64 nodeId, - ui32 maxNodes) + ui32 maxNodes, + TDuration scheduleTimeout) : NodeId(nodeId) , MaxNodes(maxNodes) + , ScheduleTimeout(scheduleTimeout) {} }; diff --git a/cloud/filestore/libs/storage/tablet/tablet_tx.h b/cloud/filestore/libs/storage/tablet/tablet_tx.h index da39fb64dd9..1714bc90f0c 100644 --- a/cloud/filestore/libs/storage/tablet/tablet_tx.h +++ b/cloud/filestore/libs/storage/tablet/tablet_tx.h @@ -2256,6 +2256,7 @@ struct TTxIndexTablet const ui64 NodeId; const TString Cookie; const ui64 MaxNodeRefs; + const TDuration ScheduleTimeout; ui64 NextNodeId = 0; TString NextCookie; @@ -2264,11 +2265,13 @@ struct TTxIndexTablet TRequestInfoPtr requestInfo, ui64 nodeId, TString cookie, - ui64 maxNodeRefs) + ui64 maxNodeRefs, + TDuration scheduleTimeout) : RequestInfo(std::move(requestInfo)) , NodeId(nodeId) , Cookie(std::move(cookie)) , MaxNodeRefs(maxNodeRefs) + , ScheduleTimeout(scheduleTimeout) {} void Clear() @@ -2289,16 +2292,19 @@ struct TTxIndexTablet const TRequestInfoPtr RequestInfo; const ui64 NodeId; const ui64 MaxNodes; + const TDuration ScheduleTimeout; ui64 NextNodeId = 0; TLoadNodes( TRequestInfoPtr requestInfo, ui64 nodeId, - ui64 maxNodes) + ui64 maxNodes, + TDuration scheduleTimeout) : RequestInfo(std::move(requestInfo)) , NodeId(nodeId) , MaxNodes(maxNodes) + , ScheduleTimeout(scheduleTimeout) {} void Clear() diff --git a/cloud/filestore/libs/storage/tablet/tablet_ut_cache.cpp b/cloud/filestore/libs/storage/tablet/tablet_ut_cache.cpp index 49b49c7a9ad..a3231adf238 100644 --- a/cloud/filestore/libs/storage/tablet/tablet_ut_cache.cpp +++ b/cloud/filestore/libs/storage/tablet/tablet_ut_cache.cpp @@ -920,6 +920,8 @@ Y_UNIT_TEST_SUITE(TIndexTabletTest_NodesCache) storageConfig.SetInMemoryIndexCacheNodeRefsCapacity(100); storageConfig.SetInMemoryIndexCacheLoadOnTabletStart(true); storageConfig.SetInMemoryIndexCacheLoadOnTabletStartRowsPerTx(1); + storageConfig.SetInMemoryIndexCacheLoadScheduleTimeout( + TDuration::Seconds(1).MilliSeconds()); TTestEnv env({}, storageConfig); env.CreateSubDomain("nfs"); From 70124b22e1b6c896fb8e2b61b96c2ada6a21cb1e Mon Sep 17 00:00:00 2001 From: Maxim Deb Natkh Date: Wed, 22 Jan 2025 01:31:03 +0100 Subject: [PATCH 2/3] fix build + review issues --- cloud/filestore/config/storage.proto | 2 +- cloud/filestore/libs/storage/core/config.cpp | 4 ++-- cloud/filestore/libs/storage/core/config.h | 2 +- .../libs/storage/tablet/tablet_actor_loadstate.cpp | 12 ++++++------ .../tablet/tablet_actor_loadstate_noderefs.cpp | 4 ++-- .../storage/tablet/tablet_actor_loadstate_nodes.cpp | 4 ++-- cloud/filestore/libs/storage/tablet/tablet_private.h | 12 ++++++------ cloud/filestore/libs/storage/tablet/tablet_tx.h | 12 ++++++------ .../libs/storage/tablet/tablet_ut_cache.cpp | 4 ++-- 9 files changed, 28 insertions(+), 28 deletions(-) diff --git a/cloud/filestore/config/storage.proto b/cloud/filestore/config/storage.proto index cbf57d14089..dd809e1ec46 100644 --- a/cloud/filestore/config/storage.proto +++ b/cloud/filestore/config/storage.proto @@ -514,5 +514,5 @@ message TStorageConfig optional uint64 MixedBlocksOffloadedRangesCapacity = 415; // During the InMemoryIndexCache load, the time between the batches loading - optional uint32 InMemoryIndexCacheLoadScheduleTimeout = 416; + optional uint32 InMemoryIndexCacheLoadSchedulePeriod = 416; } diff --git a/cloud/filestore/libs/storage/core/config.cpp b/cloud/filestore/libs/storage/core/config.cpp index b63c3c739d2..725421cacb0 100644 --- a/cloud/filestore/libs/storage/core/config.cpp +++ b/cloud/filestore/libs/storage/core/config.cpp @@ -219,8 +219,8 @@ using TAliases = NProto::TStorageConfig::TFilestoreAliases; xxx(InMemoryIndexCacheNodeRefsCapacity, ui64, 0 )\ xxx(InMemoryIndexCacheNodesToNodeRefsCapacityRatio, ui64, 0 )\ xxx(InMemoryIndexCacheLoadOnTabletStart, bool, false )\ - xxx(InMemoryIndexCacheLoadOnTabletStartRowsPerTx, ui64, 1000000 )\ - xxx(InMemoryIndexCacheLoadScheduleTimeout, \ + xxx(InMemoryIndexCacheLoadOnTabletStartRowsPerTx, ui64, 1000 )\ + xxx(InMemoryIndexCacheLoadSchedulePeriod, \ TDuration, \ TDuration::MilliSeconds(0) )\ \ diff --git a/cloud/filestore/libs/storage/core/config.h b/cloud/filestore/libs/storage/core/config.h index d0c155c16a8..779d8637304 100644 --- a/cloud/filestore/libs/storage/core/config.h +++ b/cloud/filestore/libs/storage/core/config.h @@ -241,7 +241,7 @@ class TStorageConfig ui64 GetInMemoryIndexCacheNodesToNodeRefsCapacityRatio() const; bool GetInMemoryIndexCacheLoadOnTabletStart() const; ui64 GetInMemoryIndexCacheLoadOnTabletStartRowsPerTx() const; - TDuration GetInMemoryIndexCacheLoadScheduleTimeout() const; + TDuration GetInMemoryIndexCacheLoadSchedulePeriod() const; bool GetAsyncDestroyHandleEnabled() const; TDuration GetAsyncHandleOperationPeriod() const; diff --git a/cloud/filestore/libs/storage/tablet/tablet_actor_loadstate.cpp b/cloud/filestore/libs/storage/tablet/tablet_actor_loadstate.cpp index d7775dc7a54..365f3221bc0 100644 --- a/cloud/filestore/libs/storage/tablet/tablet_actor_loadstate.cpp +++ b/cloud/filestore/libs/storage/tablet/tablet_actor_loadstate.cpp @@ -313,8 +313,8 @@ void TIndexTabletActor::CompleteTx_LoadState( { const ui64 maxRows = Config->GetInMemoryIndexCacheLoadOnTabletStartRowsPerTx(); - const TDuration timeout = - Config->GetInMemoryIndexCacheLoadScheduleTimeout(); + const TDuration schedulePeriod = + Config->GetInMemoryIndexCacheLoadSchedulePeriod(); // If necessary, code can iteratively call ReadNodeRefs for all nodes. // This will populate cache with node refs and allow us to perform @@ -326,14 +326,14 @@ void TIndexTabletActor::CompleteTx_LoadState( "%s LoadNodeRefs started (maxNodeRefs: %lu, timeout: %s)", LogTag.c_str(), maxRows, - timeout.ToString()); + schedulePeriod.ToString().c_str()); ctx.Send( SelfId(), new TEvIndexTabletPrivate::TEvLoadNodeRefsRequest( 0, "", maxRows, - timeout)); + schedulePeriod)); // Same logic is performed for batch loading nodes as well. The only // difference is that we do not need to keep track of the exhaustiveness @@ -344,13 +344,13 @@ void TIndexTabletActor::CompleteTx_LoadState( "%s LoadNodes started (maxNodes: %lu, timeout: %s)", LogTag.c_str(), maxRows, - timeout.ToString()); + schedulePeriod.ToString().c_str()); ctx.Send( SelfId(), new TEvIndexTabletPrivate::TEvLoadNodesRequest( 0, maxRows, - timeout)); + schedulePeriod)); } ScheduleSyncSessions(ctx); diff --git a/cloud/filestore/libs/storage/tablet/tablet_actor_loadstate_noderefs.cpp b/cloud/filestore/libs/storage/tablet/tablet_actor_loadstate_noderefs.cpp index ec55f2de092..55d83ba8eea 100644 --- a/cloud/filestore/libs/storage/tablet/tablet_actor_loadstate_noderefs.cpp +++ b/cloud/filestore/libs/storage/tablet/tablet_actor_loadstate_noderefs.cpp @@ -71,7 +71,7 @@ void TIndexTabletActor::CompleteTx_LoadNodeRefs( args.NextNodeId, args.NextCookie, args.MaxNodeRefs, - args.ScheduleTimeout)); + args.SchedulePeriod)); } else { LOG_INFO( ctx, @@ -111,7 +111,7 @@ void TIndexTabletActor::HandleLoadNodeRefsRequest( msg->NodeId, msg->Cookie, msg->MaxNodeRefs, - msg->ScheduleTimeout); + msg->SchedulePeriod); } } // namespace NCloud::NFileStore::NStorage diff --git a/cloud/filestore/libs/storage/tablet/tablet_actor_loadstate_nodes.cpp b/cloud/filestore/libs/storage/tablet/tablet_actor_loadstate_nodes.cpp index c41156eb6ff..b454498f744 100644 --- a/cloud/filestore/libs/storage/tablet/tablet_actor_loadstate_nodes.cpp +++ b/cloud/filestore/libs/storage/tablet/tablet_actor_loadstate_nodes.cpp @@ -61,7 +61,7 @@ void TIndexTabletActor::CompleteTx_LoadNodes( new TEvIndexTabletPrivate::TEvLoadNodesRequest( args.NextNodeId, args.MaxNodes, - args.ScheduleTimeout)); + args.SchedulePeriod)); } else { LOG_INFO( ctx, @@ -96,7 +96,7 @@ void TIndexTabletActor::HandleLoadNodesRequest( std::move(requestInfo), msg->NodeId, msg->MaxNodes, - msg->ScheduleTimeout); + msg->SchedulePeriod); } } // namespace NCloud::NFileStore::NStorage diff --git a/cloud/filestore/libs/storage/tablet/tablet_private.h b/cloud/filestore/libs/storage/tablet/tablet_private.h index effa0f43215..74987181ac3 100644 --- a/cloud/filestore/libs/storage/tablet/tablet_private.h +++ b/cloud/filestore/libs/storage/tablet/tablet_private.h @@ -534,17 +534,17 @@ struct TEvIndexTabletPrivate const ui64 NodeId; const TString Cookie; const ui32 MaxNodeRefs; - const TDuration ScheduleTimeout; + const TDuration SchedulePeriod; TLoadNodeRefsRequest( ui64 nodeId, TString cookie, ui32 maxNodeRefs, - TDuration scheduleTimeout) + TDuration schedulePeriod) : NodeId(nodeId) , Cookie(std::move(cookie)) , MaxNodeRefs(maxNodeRefs) - , ScheduleTimeout(scheduleTimeout) + , SchedulePeriod(schedulePeriod) {} }; @@ -556,15 +556,15 @@ struct TEvIndexTabletPrivate { const ui64 NodeId; const ui32 MaxNodes; - const TDuration ScheduleTimeout; + const TDuration SchedulePeriod; TLoadNodesRequest( ui64 nodeId, ui32 maxNodes, - TDuration scheduleTimeout) + TDuration schedulePeriod) : NodeId(nodeId) , MaxNodes(maxNodes) - , ScheduleTimeout(scheduleTimeout) + , SchedulePeriod(schedulePeriod) {} }; diff --git a/cloud/filestore/libs/storage/tablet/tablet_tx.h b/cloud/filestore/libs/storage/tablet/tablet_tx.h index 1714bc90f0c..8b98c11b48f 100644 --- a/cloud/filestore/libs/storage/tablet/tablet_tx.h +++ b/cloud/filestore/libs/storage/tablet/tablet_tx.h @@ -2256,7 +2256,7 @@ struct TTxIndexTablet const ui64 NodeId; const TString Cookie; const ui64 MaxNodeRefs; - const TDuration ScheduleTimeout; + const TDuration SchedulePeriod; ui64 NextNodeId = 0; TString NextCookie; @@ -2266,12 +2266,12 @@ struct TTxIndexTablet ui64 nodeId, TString cookie, ui64 maxNodeRefs, - TDuration scheduleTimeout) + TDuration schedulePeriod) : RequestInfo(std::move(requestInfo)) , NodeId(nodeId) , Cookie(std::move(cookie)) , MaxNodeRefs(maxNodeRefs) - , ScheduleTimeout(scheduleTimeout) + , SchedulePeriod(schedulePeriod) {} void Clear() @@ -2292,7 +2292,7 @@ struct TTxIndexTablet const TRequestInfoPtr RequestInfo; const ui64 NodeId; const ui64 MaxNodes; - const TDuration ScheduleTimeout; + const TDuration SchedulePeriod; ui64 NextNodeId = 0; @@ -2300,11 +2300,11 @@ struct TTxIndexTablet TRequestInfoPtr requestInfo, ui64 nodeId, ui64 maxNodes, - TDuration scheduleTimeout) + TDuration schedulePeriod) : RequestInfo(std::move(requestInfo)) , NodeId(nodeId) , MaxNodes(maxNodes) - , ScheduleTimeout(scheduleTimeout) + , SchedulePeriod(schedulePeriod) {} void Clear() diff --git a/cloud/filestore/libs/storage/tablet/tablet_ut_cache.cpp b/cloud/filestore/libs/storage/tablet/tablet_ut_cache.cpp index a3231adf238..2762dbce86e 100644 --- a/cloud/filestore/libs/storage/tablet/tablet_ut_cache.cpp +++ b/cloud/filestore/libs/storage/tablet/tablet_ut_cache.cpp @@ -920,8 +920,8 @@ Y_UNIT_TEST_SUITE(TIndexTabletTest_NodesCache) storageConfig.SetInMemoryIndexCacheNodeRefsCapacity(100); storageConfig.SetInMemoryIndexCacheLoadOnTabletStart(true); storageConfig.SetInMemoryIndexCacheLoadOnTabletStartRowsPerTx(1); - storageConfig.SetInMemoryIndexCacheLoadScheduleTimeout( - TDuration::Seconds(1).MilliSeconds()); + storageConfig.SetInMemoryIndexCacheLoadSchedulePeriod( + TDuration::Seconds(1).MicroSeconds()); TTestEnv env({}, storageConfig); env.CreateSubDomain("nfs"); From e55c5fdff3c6485da2c2d916f8e43520442588f9 Mon Sep 17 00:00:00 2001 From: Maxim Deb Natkh Date: Thu, 23 Jan 2025 22:22:21 +0100 Subject: [PATCH 3/3] Send -> Schedule --- cloud/filestore/config/storage.proto | 2 +- cloud/filestore/libs/storage/core/config.cpp | 4 +- .../storage/tablet/tablet_actor_adddata.cpp | 2 - .../storage/tablet/tablet_actor_loadstate.cpp | 4 +- .../tablet_actor_loadstate_noderefs.cpp | 4 +- .../tablet/tablet_actor_loadstate_nodes.cpp | 4 +- .../libs/storage/tablet/tablet_ut_cache.cpp | 38 ++++++++++--------- 7 files changed, 29 insertions(+), 29 deletions(-) diff --git a/cloud/filestore/config/storage.proto b/cloud/filestore/config/storage.proto index dd809e1ec46..ffe1b804ae7 100644 --- a/cloud/filestore/config/storage.proto +++ b/cloud/filestore/config/storage.proto @@ -514,5 +514,5 @@ message TStorageConfig optional uint64 MixedBlocksOffloadedRangesCapacity = 415; // During the InMemoryIndexCache load, the time between the batches loading - optional uint32 InMemoryIndexCacheLoadSchedulePeriod = 416; + optional uint32 InMemoryIndexCacheLoadSchedulePeriod = 416; // in ms } diff --git a/cloud/filestore/libs/storage/core/config.cpp b/cloud/filestore/libs/storage/core/config.cpp index 725421cacb0..692b4e40b4e 100644 --- a/cloud/filestore/libs/storage/core/config.cpp +++ b/cloud/filestore/libs/storage/core/config.cpp @@ -220,9 +220,9 @@ using TAliases = NProto::TStorageConfig::TFilestoreAliases; xxx(InMemoryIndexCacheNodesToNodeRefsCapacityRatio, ui64, 0 )\ xxx(InMemoryIndexCacheLoadOnTabletStart, bool, false )\ xxx(InMemoryIndexCacheLoadOnTabletStartRowsPerTx, ui64, 1000 )\ - xxx(InMemoryIndexCacheLoadSchedulePeriod, \ + xxx(InMemoryIndexCacheLoadSchedulePeriod, \ TDuration, \ - TDuration::MilliSeconds(0) )\ + TDuration::Seconds(0) )\ \ xxx(NonNetworkMetricsBalancingFactor, ui32, 1_KB )\ \ diff --git a/cloud/filestore/libs/storage/tablet/tablet_actor_adddata.cpp b/cloud/filestore/libs/storage/tablet/tablet_actor_adddata.cpp index 004c8a67f2f..c3221c6e83a 100644 --- a/cloud/filestore/libs/storage/tablet/tablet_actor_adddata.cpp +++ b/cloud/filestore/libs/storage/tablet/tablet_actor_adddata.cpp @@ -296,8 +296,6 @@ void TIndexTabletActor::HandleGenerateBlobIds( offset += length; } - // TODO(debnatkh): Throttling - response->Record.SetCommitId(commitId); Metrics.GenerateBlobIds.Count.fetch_add(1, std::memory_order_relaxed); diff --git a/cloud/filestore/libs/storage/tablet/tablet_actor_loadstate.cpp b/cloud/filestore/libs/storage/tablet/tablet_actor_loadstate.cpp index 365f3221bc0..93fa0e2351a 100644 --- a/cloud/filestore/libs/storage/tablet/tablet_actor_loadstate.cpp +++ b/cloud/filestore/libs/storage/tablet/tablet_actor_loadstate.cpp @@ -323,7 +323,7 @@ void TIndexTabletActor::CompleteTx_LoadState( LOG_INFO( ctx, TFileStoreComponents::TABLET, - "%s LoadNodeRefs started (maxNodeRefs: %lu, timeout: %s)", + "%s LoadNodeRefs started (maxNodeRefs: %lu, period: %s)", LogTag.c_str(), maxRows, schedulePeriod.ToString().c_str()); @@ -341,7 +341,7 @@ void TIndexTabletActor::CompleteTx_LoadState( LOG_INFO( ctx, TFileStoreComponents::TABLET, - "%s LoadNodes started (maxNodes: %lu, timeout: %s)", + "%s LoadNodes started (maxNodes: %lu, period: %s)", LogTag.c_str(), maxRows, schedulePeriod.ToString().c_str()); diff --git a/cloud/filestore/libs/storage/tablet/tablet_actor_loadstate_noderefs.cpp b/cloud/filestore/libs/storage/tablet/tablet_actor_loadstate_noderefs.cpp index 55d83ba8eea..aeb01f41e3f 100644 --- a/cloud/filestore/libs/storage/tablet/tablet_actor_loadstate_noderefs.cpp +++ b/cloud/filestore/libs/storage/tablet/tablet_actor_loadstate_noderefs.cpp @@ -65,8 +65,8 @@ void TIndexTabletActor::CompleteTx_LoadNodeRefs( args.NextCookie.c_str()); if (args.NextCookie || args.NextNodeId) { - ctx.Send( - SelfId(), + ctx.Schedule( + args.SchedulePeriod, new TEvIndexTabletPrivate::TEvLoadNodeRefsRequest( args.NextNodeId, args.NextCookie, diff --git a/cloud/filestore/libs/storage/tablet/tablet_actor_loadstate_nodes.cpp b/cloud/filestore/libs/storage/tablet/tablet_actor_loadstate_nodes.cpp index b454498f744..5f51ff8f6d1 100644 --- a/cloud/filestore/libs/storage/tablet/tablet_actor_loadstate_nodes.cpp +++ b/cloud/filestore/libs/storage/tablet/tablet_actor_loadstate_nodes.cpp @@ -56,8 +56,8 @@ void TIndexTabletActor::CompleteTx_LoadNodes( args.NextNodeId); if (args.NextNodeId) { - ctx.Send( - SelfId(), + ctx.Schedule( + args.SchedulePeriod, new TEvIndexTabletPrivate::TEvLoadNodesRequest( args.NextNodeId, args.MaxNodes, diff --git a/cloud/filestore/libs/storage/tablet/tablet_ut_cache.cpp b/cloud/filestore/libs/storage/tablet/tablet_ut_cache.cpp index 2762dbce86e..4863b06c23d 100644 --- a/cloud/filestore/libs/storage/tablet/tablet_ut_cache.cpp +++ b/cloud/filestore/libs/storage/tablet/tablet_ut_cache.cpp @@ -921,7 +921,7 @@ Y_UNIT_TEST_SUITE(TIndexTabletTest_NodesCache) storageConfig.SetInMemoryIndexCacheLoadOnTabletStart(true); storageConfig.SetInMemoryIndexCacheLoadOnTabletStartRowsPerTx(1); storageConfig.SetInMemoryIndexCacheLoadSchedulePeriod( - TDuration::Seconds(1).MicroSeconds()); + TDuration::Seconds(1).MilliSeconds()); TTestEnv env({}, storageConfig); env.CreateSubDomain("nfs"); @@ -932,22 +932,25 @@ Y_UNIT_TEST_SUITE(TIndexTabletTest_NodesCache) tablet.InitSession("client", "session"); tablet.CreateNode(TCreateNodeArgs::File(RootNodeId, "test1")); - tablet.CreateNode(TCreateNodeArgs::File(RootNodeId, "test2")); env.GetRuntime().ClearCounters(); tablet.RebootTablet(); + + for (int i = 0; i < 10; ++i) { + tablet.AdvanceTime(TDuration::Seconds(1)); + env.GetRuntime().DispatchEvents({}, TDuration::Seconds(1)); + } + tablet.InitSession("client", "session"); - // It will take 2 iterations to load all the nodeRefs (root -> test1 and - // root -> test2) + // It will take 1 iteration to load all the nodeRefs (root -> test)1 UNIT_ASSERT_VALUES_EQUAL( - 2, + 1, env.GetRuntime().GetCounter( TEvIndexTabletPrivate::EEvents::EvLoadNodeRefs)); - // It also will take 3 iterations to load all the nodes (root, test1 and - // test2) + // It also will take 2 iterations to load all the nodes (root and test1) UNIT_ASSERT_VALUES_EQUAL( - 3, + 2, env.GetRuntime().GetCounter( TEvIndexTabletPrivate::EEvents::EvLoadNodes)); @@ -956,7 +959,7 @@ Y_UNIT_TEST_SUITE(TIndexTabletTest_NodesCache) // The noderefs cache is exhaustive thus list nodes should be a cache // hit UNIT_ASSERT_VALUES_EQUAL( - 2, + 1, tablet.ListNodes(RootNodeId)->Record.NodesSize()); auto statsAfter = GetTxStats(env, tablet); @@ -971,28 +974,27 @@ Y_UNIT_TEST_SUITE(TIndexTabletTest_NodesCache) statsBefore = statsAfter; - auto id3 = - tablet.CreateNode(TCreateNodeArgs::Directory(RootNodeId, "test3")) + auto id2 = + tablet.CreateNode(TCreateNodeArgs::Directory(RootNodeId, "test2")) ->Record.GetNode() .GetId(); - tablet.CreateNode(TCreateNodeArgs::File(id3, "test4")); - tablet.CreateNode(TCreateNodeArgs::File(id3, "test5")); - tablet.CreateNode(TCreateNodeArgs::File(id3, "test6")); + tablet.CreateNode(TCreateNodeArgs::File(id2, "test3")); + tablet.CreateNode(TCreateNodeArgs::File(id2, "test4")); + tablet.CreateNode(TCreateNodeArgs::File(id2, "test5")); /* |- test1 |- test2 - |- test3 + |- test3 |- test4 |- test5 - |- test6 */ // The NodeRefs cache is still exhaustive thus list nodes should be a // cache hit - UNIT_ASSERT_VALUES_EQUAL(3, tablet.ListNodes(id3)->Record.NodesSize()); + UNIT_ASSERT_VALUES_EQUAL(3, tablet.ListNodes(id2)->Record.NodesSize()); UNIT_ASSERT_VALUES_EQUAL( - 3, + 2, tablet.ListNodes(RootNodeId)->Record.NodesSize()); statsAfter = GetTxStats(env, tablet);