Skip to content

Commit ddcdc99

Browse files
authored
Support arbitrary chain set in huge blob keeper heap (#11983)
1 parent ec09486 commit ddcdc99

16 files changed

+457
-621
lines changed

ydb/core/blobstorage/ut_vdisk/lib/test_huge.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ class THugeModuleRecoveryActor : public TActorBootstrapped<THugeModuleRecoveryAc
137137

138138
bool InitHugeBlobKeeper(const TActorContext &ctx, const TStartingPoints &startingPoints) {
139139
Y_UNUSED(ctx);
140-
const ui32 oldMinHugeBlobInBytes = 64 << 10;
141140
const ui32 milestoneHugeBlobInBytes = 64 << 10;
142141
const ui32 maxBlobInBytes = 128 << 10;
143142
auto logFunc = [] (const TString) { /* empty */ };
@@ -150,7 +149,6 @@ class THugeModuleRecoveryActor : public TActorBootstrapped<THugeModuleRecoveryAc
150149
HmCtx->PDiskCtx->Dsk->ChunkSize,
151150
HmCtx->PDiskCtx->Dsk->AppendBlockSize,
152151
HmCtx->PDiskCtx->Dsk->AppendBlockSize,
153-
oldMinHugeBlobInBytes,
154152
milestoneHugeBlobInBytes,
155153
maxBlobInBytes,
156154
HmCtx->Config->HugeBlobOverhead,
@@ -169,7 +167,6 @@ class THugeModuleRecoveryActor : public TActorBootstrapped<THugeModuleRecoveryAc
169167
HmCtx->PDiskCtx->Dsk->ChunkSize,
170168
HmCtx->PDiskCtx->Dsk->AppendBlockSize,
171169
HmCtx->PDiskCtx->Dsk->AppendBlockSize,
172-
oldMinHugeBlobInBytes,
173170
milestoneHugeBlobInBytes,
174171
maxBlobInBytes,
175172
HmCtx->Config->HugeBlobOverhead,

ydb/core/blobstorage/vdisk/common/vdisk_config.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,7 @@ namespace NKikimr {
136136
MinHugeBlobInBytes = 512u << 10u;
137137
break;
138138
}
139-
OldMinHugeBlobInBytes = MinHugeBlobInBytes; // preserved to migrate entry point state correctly
140139
MilestoneHugeBlobInBytes = 512u << 10u; // for compatibility reasons it must be 512KB
141-
142140
}
143141

144142
void TVDiskConfig::Merge(const NKikimrBlobStorage::TVDiskConfig &update) {

ydb/core/blobstorage/vdisk/common/vdisk_config.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ namespace NKikimr {
120120
ui32 HullSstSizeInChunksLevel;
121121
ui32 HugeBlobsFreeChunkReservation;
122122
ui32 MinHugeBlobInBytes;
123-
ui32 OldMinHugeBlobInBytes;
124123
ui32 MilestoneHugeBlobInBytes;
125124
ui32 HugeBlobOverhead;
126125
ui32 HullCompLevel0MaxSstsAtOnce;

ydb/core/blobstorage/vdisk/common/vdisk_hugeblobctx.cpp

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,23 @@
33

44
namespace NKikimr {
55

6-
THugeSlotsMap::THugeSlotsMap(ui32 appendBlockSize, TAllSlotsInfo &&slotsInfo, TSearchTable &&searchTable)
6+
THugeSlotsMap::THugeSlotsMap(ui32 appendBlockSize, ui32 minHugeBlobInBlocks, TAllSlotsInfo &&slotsInfo,
7+
TSearchTable &&searchTable)
78
: AppendBlockSize(appendBlockSize)
9+
, MinHugeBlobInBlocks(minHugeBlobInBlocks)
810
, AllSlotsInfo(std::move(slotsInfo))
911
, SearchTable(std::move(searchTable))
1012
{}
1113

1214
const THugeSlotsMap::TSlotInfo *THugeSlotsMap::GetSlotInfo(ui32 size) const {
13-
ui32 sizeInBlocks = size / AppendBlockSize;
14-
sizeInBlocks += !(sizeInBlocks * AppendBlockSize == size);
15-
const ui64 idx = SearchTable.at(sizeInBlocks);
15+
const ui32 sizeInBlocks = (size + AppendBlockSize - 1) / AppendBlockSize;
16+
Y_ABORT_UNLESS(MinHugeBlobInBlocks <= sizeInBlocks);
17+
const ui64 idx = SearchTable.at(sizeInBlocks - MinHugeBlobInBlocks);
1618
return &AllSlotsInfo.at(idx);
1719
}
1820

1921
ui32 THugeSlotsMap::AlignByBlockSize(ui32 size) const {
20-
ui32 sizeInBlocks = size / AppendBlockSize;
21-
Y_ABORT_UNLESS(sizeInBlocks, "Blob size to align is smaller than a single block. BlobSize# %" PRIu32, size);
22-
return sizeInBlocks * AppendBlockSize;
22+
return Max(MinHugeBlobInBlocks * AppendBlockSize, size - size % AppendBlockSize);
2323
}
2424

2525
void THugeSlotsMap::Output(IOutputStream &str) const {
@@ -31,11 +31,7 @@ namespace NKikimr {
3131
str << "]}\n";
3232
str << "{SearchTable# [";
3333
for (const auto &idx : SearchTable) {
34-
if (idx != NoOpIdx) {
35-
AllSlotsInfo.at(idx).Output(str);
36-
} else {
37-
str << "null";
38-
}
34+
AllSlotsInfo.at(idx).Output(str);
3935
str << "\n";
4036
}
4137
str << "]}";

ydb/core/blobstorage/vdisk/common/vdisk_hugeblobctx.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,21 @@ namespace NKikimr {
3838
};
3939

4040
// All slot types
41-
using TAllSlotsInfo = TVector<TSlotInfo>;
41+
using TAllSlotsInfo = std::vector<TSlotInfo>;
4242
// Type to address TAllSlotsInfo
4343
using TIndex = ui16;
4444
// Size in AppendBlockSize -> index in TAllSlotsInfo
45-
using TSearchTable = TVector<TIndex>;
46-
// Idx that indicates there is no record for it in TAllSlotsInfo
47-
static constexpr TIndex NoOpIdx = Max<TIndex>();
45+
using TSearchTable = std::vector<TIndex>;
4846

49-
50-
THugeSlotsMap(ui32 appendBlockSize, TAllSlotsInfo &&slotsInfo, TSearchTable &&searchTable);
47+
THugeSlotsMap(ui32 appendBlockSize, ui32 minHugeBlobInBlocks, TAllSlotsInfo &&slotsInfo, TSearchTable &&searchTable);
5148
const TSlotInfo *GetSlotInfo(ui32 size) const;
5249
ui32 AlignByBlockSize(ui32 size) const;
5350
void Output(IOutputStream &str) const;
5451
TString ToString() const;
5552

5653
private:
5754
const ui32 AppendBlockSize;
55+
const ui32 MinHugeBlobInBlocks;
5856
TAllSlotsInfo AllSlotsInfo;
5957
TSearchTable SearchTable;
6058
};

ydb/core/blobstorage/vdisk/huge/blobstorage_hullhuge.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,7 @@ LWTRACE_USING(BLOBSTORAGE_PROVIDER);
890890

891891
for (const auto &x : msg->HugeBlobs) {
892892
slotSizes.insert(State.Pers->Heap->SlotSizeOfThisSize(x.Size));
893-
NHuge::TFreeRes freeRes = State.Pers->Heap->Free(x);
893+
State.Pers->Heap->Free(x);
894894
State.Pers->DeleteChunkSize(State.Pers->Heap->ConvertDiskPartToHugeSlot(x));
895895
LOG_DEBUG(ctx, BS_HULLHUGE,
896896
VDISKP(HugeKeeperCtx->VCtx->VDiskLogPrefix,

ydb/core/blobstorage/vdisk/huge/blobstorage_hullhuge_ut.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ namespace NKikimr {
1717
Y_UNIT_TEST(SerializeParse) {
1818
ui32 chunkSize = 134274560u;
1919
ui32 appendBlockSize = 56896u;
20-
ui32 minHugeBlobInBytes = 512u << 10u;
2120
ui32 milestoneHugeBlobInBytes = 512u << 10u;
2221
ui32 maxBlobInBytes = 10u << 20u;
2322
ui32 overhead = 8;
@@ -29,8 +28,8 @@ namespace NKikimr {
2928
auto vctx = MakeIntrusive<TVDiskContext>(TActorId(), info->PickTopology(), counters, TVDiskID(0, 1, 0, 0, 0),
3029
nullptr, NPDisk::DEVICE_TYPE_UNKNOWN);
3130
std::unique_ptr<THullHugeKeeperPersState> state(
32-
new THullHugeKeeperPersState(vctx, chunkSize, appendBlockSize, appendBlockSize,
33-
minHugeBlobInBytes, milestoneHugeBlobInBytes, maxBlobInBytes,
31+
new THullHugeKeeperPersState(vctx, chunkSize, appendBlockSize,
32+
appendBlockSize, milestoneHugeBlobInBytes, maxBlobInBytes,
3433
overhead, freeChunksReservation, logf));
3534

3635
state->LogPos = THullHugeRecoveryLogPos(0, 0, 100500, 50000, 70000, 56789, 39482);

ydb/core/blobstorage/vdisk/huge/blobstorage_hullhugedefs.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@ namespace NKikimr {
1111
// TFreeRes
1212
////////////////////////////////////////////////////////////////////////////
1313
void TFreeRes::Output(IOutputStream &str) const {
14-
str << "{ChunkIdx: " << ChunkId << " Mask# ";
15-
for (size_t i = 0; i < MaskSize; ++i) {
16-
str << (Mask[i] ? "1" : "0");
17-
}
18-
str << "}";
14+
str << "{ChunkIdx: " << ChunkId << " InLockedChunks# " << InLockedChunks << '}';
1915
}
2016

2117
////////////////////////////////////////////////////////////////////////////

ydb/core/blobstorage/vdisk/huge/blobstorage_hullhugedefs.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,16 @@ namespace NKikimr {
2121
////////////////////////////////////////////////////////////////////////////
2222
struct TFreeRes {
2323
ui32 ChunkId = 0;
24-
TMask Mask;
25-
ui32 MaskSize = 0;
2624
bool InLockedChunks = false;
2725

2826
TFreeRes() = default;
29-
TFreeRes(ui32 chunkId, TMask mask, ui32 maskSize, bool inLockedChunks)
27+
TFreeRes(ui32 chunkId, bool inLockedChunks)
3028
: ChunkId(chunkId)
31-
, Mask(mask)
32-
, MaskSize(maskSize)
3329
, InLockedChunks(inLockedChunks)
3430
{}
3531

3632
void Output(IOutputStream &str) const;
33+
3734
TString ToString() const {
3835
TStringStream str;
3936
Output(str);

0 commit comments

Comments
 (0)