From 3a558c29f501a5481fae52a561a5649b241cba8e Mon Sep 17 00:00:00 2001 From: Darya Frolova <47457802+WilyTiger@users.noreply.github.com> Date: Fri, 20 Sep 2024 07:13:25 -0700 Subject: [PATCH] add precharge for compaction map loading (#2089) --- .../libs/storage/tablet/tablet_actor_loadstate.cpp | 3 ++- .../filestore/libs/storage/tablet/tablet_database.cpp | 9 +++++++-- cloud/filestore/libs/storage/tablet/tablet_database.h | 3 ++- .../libs/storage/tablet/tablet_database_ut.cpp | 10 +++++----- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/cloud/filestore/libs/storage/tablet/tablet_actor_loadstate.cpp b/cloud/filestore/libs/storage/tablet/tablet_actor_loadstate.cpp index 70ad99c0173..576b5c1e6b1 100644 --- a/cloud/filestore/libs/storage/tablet/tablet_actor_loadstate.cpp +++ b/cloud/filestore/libs/storage/tablet/tablet_actor_loadstate.cpp @@ -446,7 +446,8 @@ bool TIndexTabletActor::PrepareTx_LoadCompactionMapChunk( bool ready = db.ReadCompactionMap( args.CompactionMap, args.FirstRangeId, - args.RangeCount); + args.RangeCount, + true); LOG_INFO_S(ctx, TFileStoreComponents::TABLET, LogTag << " Loading compaction map chunk " diff --git a/cloud/filestore/libs/storage/tablet/tablet_database.cpp b/cloud/filestore/libs/storage/tablet/tablet_database.cpp index b5f5fe5979f..27bcece8ec2 100644 --- a/cloud/filestore/libs/storage/tablet/tablet_database.cpp +++ b/cloud/filestore/libs/storage/tablet/tablet_database.cpp @@ -1683,16 +1683,21 @@ void TIndexTabletDatabase::WriteCompactionMap( bool TIndexTabletDatabase::ReadCompactionMap( TVector& compactionMap) { - return ReadCompactionMap(compactionMap, 0, Max()); + return ReadCompactionMap(compactionMap, 0, Max(), true); } bool TIndexTabletDatabase::ReadCompactionMap( TVector& compactionMap, ui32 firstRangeId, - ui32 rangeCount) + ui32 rangeCount, + bool prechargeAll) { using TTable = TIndexTabletSchema::CompactionMap; + if (!firstRangeId && prechargeAll) { + Table().Precharge(); + } + auto it = Table() .GreaterOrEqual(firstRangeId) .Select(); diff --git a/cloud/filestore/libs/storage/tablet/tablet_database.h b/cloud/filestore/libs/storage/tablet/tablet_database.h index 9388141ea69..edd3f95dd8a 100644 --- a/cloud/filestore/libs/storage/tablet/tablet_database.h +++ b/cloud/filestore/libs/storage/tablet/tablet_database.h @@ -498,7 +498,8 @@ FILESTORE_FILESYSTEM_STATS(FILESTORE_DECLARE_STATS) bool ReadCompactionMap( TVector& compactionMap, ui32 firstRangeId, - ui32 rangeCount); + ui32 rangeCount, + bool prechargeAll); // // OpLog diff --git a/cloud/filestore/libs/storage/tablet/tablet_database_ut.cpp b/cloud/filestore/libs/storage/tablet/tablet_database_ut.cpp index 8f9c98f7619..66f064c7047 100644 --- a/cloud/filestore/libs/storage/tablet/tablet_database_ut.cpp +++ b/cloud/filestore/libs/storage/tablet/tablet_database_ut.cpp @@ -419,19 +419,19 @@ Y_UNIT_TEST_SUITE(TIndexTabletDatabaseTest) executor.ReadTx([&] (TIndexTabletDatabase db) { TVector chunk; - UNIT_ASSERT(db.ReadCompactionMap(chunk, 0, 5)); + UNIT_ASSERT(db.ReadCompactionMap(chunk, 0, 5, true)); UNIT_ASSERT_VALUES_EQUAL(toString(entries, 0, 5), toString(chunk)); chunk.clear(); - UNIT_ASSERT(db.ReadCompactionMap(chunk, 111, 5)); + UNIT_ASSERT(db.ReadCompactionMap(chunk, 111, 5, true)); UNIT_ASSERT_VALUES_EQUAL(toString(entries, 5, 5), toString(chunk)); chunk.clear(); - UNIT_ASSERT(db.ReadCompactionMap(chunk, 6002, 5)); + UNIT_ASSERT(db.ReadCompactionMap(chunk, 6002, 5, true)); UNIT_ASSERT_VALUES_EQUAL(toString(entries, 10, 5), toString(chunk)); chunk.clear(); - UNIT_ASSERT(db.ReadCompactionMap(chunk, 7001, 5)); + UNIT_ASSERT(db.ReadCompactionMap(chunk, 7001, 5, true)); UNIT_ASSERT_VALUES_EQUAL("", toString(chunk)); }); @@ -446,7 +446,7 @@ Y_UNIT_TEST_SUITE(TIndexTabletDatabaseTest) executor.ReadTx([&] (TIndexTabletDatabase db) { TVector chunk; - UNIT_ASSERT(db.ReadCompactionMap(chunk, 0, Max())); + UNIT_ASSERT(db.ReadCompactionMap(chunk, 0, Max(), true)); UNIT_ASSERT_VALUES_EQUAL( toString(entries, 0, Max(), true), toString(chunk));