Skip to content

Commit

Permalink
add precharge for compaction map loading (#2089)
Browse files Browse the repository at this point in the history
  • Loading branch information
WilyTiger authored Sep 20, 2024
1 parent d91dbc7 commit 3a558c2
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand Down
9 changes: 7 additions & 2 deletions cloud/filestore/libs/storage/tablet/tablet_database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1683,16 +1683,21 @@ void TIndexTabletDatabase::WriteCompactionMap(
bool TIndexTabletDatabase::ReadCompactionMap(
TVector<TCompactionRangeInfo>& compactionMap)
{
return ReadCompactionMap(compactionMap, 0, Max<ui32>());
return ReadCompactionMap(compactionMap, 0, Max<ui32>(), true);
}

bool TIndexTabletDatabase::ReadCompactionMap(
TVector<TCompactionRangeInfo>& compactionMap,
ui32 firstRangeId,
ui32 rangeCount)
ui32 rangeCount,
bool prechargeAll)
{
using TTable = TIndexTabletSchema::CompactionMap;

if (!firstRangeId && prechargeAll) {
Table<TTable>().Precharge();
}

auto it = Table<TTable>()
.GreaterOrEqual(firstRangeId)
.Select();
Expand Down
3 changes: 2 additions & 1 deletion cloud/filestore/libs/storage/tablet/tablet_database.h
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,8 @@ FILESTORE_FILESYSTEM_STATS(FILESTORE_DECLARE_STATS)
bool ReadCompactionMap(
TVector<TCompactionRangeInfo>& compactionMap,
ui32 firstRangeId,
ui32 rangeCount);
ui32 rangeCount,
bool prechargeAll);

//
// OpLog
Expand Down
10 changes: 5 additions & 5 deletions cloud/filestore/libs/storage/tablet/tablet_database_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,19 +419,19 @@ Y_UNIT_TEST_SUITE(TIndexTabletDatabaseTest)

executor.ReadTx([&] (TIndexTabletDatabase db) {
TVector<TCompactionRangeInfo> 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));
});

Expand All @@ -446,7 +446,7 @@ Y_UNIT_TEST_SUITE(TIndexTabletDatabaseTest)

executor.ReadTx([&] (TIndexTabletDatabase db) {
TVector<TCompactionRangeInfo> chunk;
UNIT_ASSERT(db.ReadCompactionMap(chunk, 0, Max<ui32>()));
UNIT_ASSERT(db.ReadCompactionMap(chunk, 0, Max<ui32>(), true));
UNIT_ASSERT_VALUES_EQUAL(
toString(entries, 0, Max<ui32>(), true),
toString(chunk));
Expand Down

0 comments on commit 3a558c2

Please sign in to comment.