Skip to content

Commit cff3af9

Browse files
authored
change VDisk compaction params when working on a tiny PDisk (#22538)
1 parent 15cba86 commit cff3af9

16 files changed

+102
-29
lines changed

ydb/core/blobstorage/pdisk/blobstorage_pdisk.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ struct TEvYardInitResult : TEventLocal<TEvYardInitResult, TEvBlobStorage::EvYard
188188
TEvYardInitResult(const NKikimrProto::EReplyStatus status, TString errorReason)
189189
: Status(status)
190190
, StatusFlags(0)
191-
, PDiskParams(new TPDiskParams(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, DEVICE_TYPE_ROT))
191+
, PDiskParams(new TPDiskParams(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, DEVICE_TYPE_ROT, false))
192192
, ErrorReason(std::move(errorReason))
193193
{
194194
Y_VERIFY(status != NKikimrProto::OK, "Single-parameter constructor is for error responses only");
@@ -199,7 +199,7 @@ struct TEvYardInitResult : TEventLocal<TEvYardInitResult, TEvBlobStorage::EvYard
199199
ui64 bulkWriteBlockSize, ui32 chunkSize, ui32 appendBlockSize,
200200
TOwner owner, TOwnerRound ownerRound, ui32 ownerWeight, ui32 slotSizeInUnits,
201201
TStatusFlags statusFlags, TVector<TChunkIdx> ownedChunks,
202-
EDeviceType trueMediaType, TString errorReason)
202+
EDeviceType trueMediaType, bool isTinyDisk, TString errorReason)
203203
: Status(status)
204204
, StatusFlags(statusFlags)
205205
, PDiskParams(new TPDiskParams(
@@ -215,7 +215,8 @@ struct TEvYardInitResult : TEventLocal<TEvYardInitResult, TEvBlobStorage::EvYard
215215
readBlockSize,
216216
writeBlockSize,
217217
bulkWriteBlockSize,
218-
trueMediaType))
218+
trueMediaType,
219+
isTinyDisk))
219220
, OwnedChunks(std::move(ownedChunks))
220221
, ErrorReason(std::move(errorReason))
221222
{}

ydb/core/blobstorage/pdisk/blobstorage_pdisk_data.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ constexpr ui32 RecordsInSysLog = 16;
3838

3939
constexpr ui64 FullSizeDiskMinimumSize = 800ull * (1 << 30); // 800GB, all disks smaller are considered "small"
4040
constexpr ui32 SmallDiskMaximumChunkSize = 32 * (1 << 20); // 32MB
41+
constexpr ui64 TinyDiskSizeThreshold = 80ull * (1 << 30); // 80GB, all disks smaller are considered "tiny"
4142

4243
#define PDISK_FORMAT_VERSION 3
4344
#define PDISK_DATA_VERSION 2

ydb/core/blobstorage/pdisk/blobstorage_pdisk_impl.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1837,14 +1837,15 @@ void TPDisk::ReplyErrorYardInitResult(TYardInit &evYardInit, const TString &str,
18371837
P_LOG(PRI_ERROR, BPD01, error.Str());
18381838
ui64 writeBlockSize = ForsetiOpPieceSizeCached;
18391839
ui64 readBlockSize = ForsetiOpPieceSizeCached;
1840+
bool isTinyDisk = (Format.DiskSize < NPDisk::TinyDiskSizeThreshold);
18401841
PCtx->ActorSystem->Send(evYardInit.Sender, new NPDisk::TEvYardInitResult(status,
18411842
DriveModel.SeekTimeNs() / 1000ull, DriveModel.Speed(TDriveModel::OP_TYPE_READ),
18421843
DriveModel.Speed(TDriveModel::OP_TYPE_WRITE), readBlockSize, writeBlockSize,
18431844
DriveModel.BulkWriteBlockSize(),
18441845
Format.GetUserAccessibleChunkSize(), Format.GetAppendBlockSize(), OwnerSystem, 0,
18451846
0, Cfg->SlotSizeInUnits,
18461847
GetStatusFlags(OwnerSystem, evYardInit.OwnerGroupType), TVector<TChunkIdx>(),
1847-
Cfg->RetrieveDeviceType(), error.Str()));
1848+
Cfg->RetrieveDeviceType(), isTinyDisk, error.Str()));
18481849
Mon.YardInit.CountResponse();
18491850
}
18501851

@@ -1892,13 +1893,16 @@ bool TPDisk::YardInitForKnownVDisk(TYardInit &evYardInit, TOwner owner) {
18921893
ui64 writeBlockSize = ForsetiOpPieceSizeCached;
18931894
ui64 readBlockSize = ForsetiOpPieceSizeCached;
18941895
ui32 ownerWeight = Cfg->GetOwnerWeight(evYardInit.GroupSizeInUnits);
1896+
bool isTinyDisk = (Format.DiskSize < NPDisk::TinyDiskSizeThreshold);
1897+
18951898
THolder<NPDisk::TEvYardInitResult> result(new NPDisk::TEvYardInitResult(NKikimrProto::OK,
18961899
DriveModel.SeekTimeNs() / 1000ull, DriveModel.Speed(TDriveModel::OP_TYPE_READ),
18971900
DriveModel.Speed(TDriveModel::OP_TYPE_WRITE), readBlockSize, writeBlockSize,
18981901
DriveModel.BulkWriteBlockSize(), Format.GetUserAccessibleChunkSize(), Format.GetAppendBlockSize(), owner,
18991902
ownerRound, ownerWeight, Cfg->SlotSizeInUnits,
19001903
GetStatusFlags(OwnerSystem, evYardInit.OwnerGroupType), ownedChunks,
1901-
Cfg->RetrieveDeviceType(), ""));
1904+
Cfg->RetrieveDeviceType(), isTinyDisk, ""));
1905+
19021906
GetStartingPoints(owner, result->StartingPoints);
19031907
ownerData.VDiskId = vDiskId;
19041908
ownerData.CutLogId = evYardInit.CutLogId;
@@ -2053,6 +2057,7 @@ void TPDisk::YardInitFinish(TYardInit &evYardInit) {
20532057

20542058
ui64 writeBlockSize = ForsetiOpPieceSizeCached;
20552059
ui64 readBlockSize = ForsetiOpPieceSizeCached;
2060+
bool isTinyDisk = (Format.DiskSize < NPDisk::TinyDiskSizeThreshold);
20562061

20572062
THolder<NPDisk::TEvYardInitResult> result(new NPDisk::TEvYardInitResult(
20582063
NKikimrProto::OK,
@@ -2061,7 +2066,8 @@ void TPDisk::YardInitFinish(TYardInit &evYardInit) {
20612066
DriveModel.BulkWriteBlockSize(), Format.GetUserAccessibleChunkSize(), Format.GetAppendBlockSize(), owner, ownerRound,
20622067
Cfg->GetOwnerWeight(evYardInit.GroupSizeInUnits), Cfg->SlotSizeInUnits,
20632068
GetStatusFlags(OwnerSystem, evYardInit.OwnerGroupType) | ui32(NKikimrBlobStorage::StatusNewOwner), TVector<TChunkIdx>(),
2064-
Cfg->RetrieveDeviceType(), ""));
2069+
Cfg->RetrieveDeviceType(), isTinyDisk, ""));
2070+
20652071
GetStartingPoints(result->PDiskParams->Owner, result->StartingPoints);
20662072
WriteSysLogRestorePoint(new TCompletionEventSender(
20672073
this, evYardInit.Sender, result.Release(), Mon.YardInit.Results), evYardInit.ReqId, {});

ydb/core/blobstorage/pdisk/blobstorage_pdisk_params.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ namespace NKikimr {
1212
TPDiskParams::TPDiskParams(NPDisk::TOwner owner, ui64 ownerRound, ui32 OwnerWeight, ui32 slotSizeInUnits,
1313
ui32 chunkSize, ui32 appendBlockSize,
1414
ui64 seekTimeUs, ui64 readSpeedBps, ui64 writeSpeedBps, ui64 readBlockSize,
15-
ui64 writeBlockSize, ui64 bulkWriteBlockSize, NPDisk::EDeviceType trueMediaType)
15+
ui64 writeBlockSize, ui64 bulkWriteBlockSize, NPDisk::EDeviceType trueMediaType,
16+
bool isTinyDisk)
1617
: Owner(owner)
1718
, OwnerRound(ownerRound)
1819
, OwnerWeight(OwnerWeight)
@@ -29,6 +30,7 @@ namespace NKikimr {
2930
, PrefetchSizeBytes(CalculatePrefetchSizeBytes(seekTimeUs, readSpeedBps))
3031
, GlueRequestDistanceBytes(CalculateGlueRequestDistanceBytes(seekTimeUs, readSpeedBps))
3132
, TrueMediaType(trueMediaType)
33+
, IsTinyDisk(isTinyDisk)
3234
{
3335
Y_VERIFY_DEBUG(AppendBlockSize <= ChunkSize);
3436
}
@@ -74,6 +76,7 @@ namespace NKikimr {
7476
str << " BulkWriteBlockSize# " << BulkWriteBlockSize;
7577
str << " PrefetchSizeBytes# " << PrefetchSizeBytes;
7678
str << " GlueRequestDistanceBytes# " << GlueRequestDistanceBytes;
79+
str << " IsTinyDisk# " << IsTinyDisk;
7780
str << "}";
7881
return str.Str();
7982
}
@@ -144,6 +147,10 @@ namespace NKikimr {
144147
TABLED() {str << "GlueRequestDistanceBytes";}
145148
TABLED() {str << GlueRequestDistanceBytes;}
146149
}
150+
TABLER() {
151+
TABLED() {str << "IsTinyDisk";}
152+
TABLED() {str << IsTinyDisk;}
153+
}
147154
}
148155
}
149156
}

ydb/core/blobstorage/pdisk/blobstorage_pdisk_params.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,17 @@ namespace NKikimr {
3131

3232
const NPDisk::EDeviceType TrueMediaType;
3333

34+
bool IsTinyDisk;
35+
3436
static ui32 CalculateRecommendedReadSize(ui64 seekTimeUs, ui64 readSpeedBps, ui64 appendBlockSize);
3537
static ui64 CalculatePrefetchSizeBytes(ui64 seekTimeUs, ui64 readSpeedBps);
3638
static ui64 CalculateGlueRequestDistanceBytes(ui64 seekTimeUs, ui64 readSpeedBps);
3739

3840
TPDiskParams(NPDisk::TOwner owner, ui64 ownerRound, ui32 ownerWeight, ui32 slotSizeInUnits,
3941
ui32 chunkSize, ui32 appendBlockSize,
4042
ui64 seekTimeUs, ui64 readSpeedBps, ui64 writeSpeedBps, ui64 readBlockSize,
41-
ui64 writeBlockSize, ui64 bulkWriteBlockSize, NPDisk::EDeviceType trueMediaType);
43+
ui64 writeBlockSize, ui64 bulkWriteBlockSize, NPDisk::EDeviceType trueMediaType,
44+
bool isTinyDisk);
4245
void OutputHtml(IOutputStream &str) const;
4346
TString ToString() const;
4447
};

ydb/core/blobstorage/pdisk/mock/pdisk_mock.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ class TPDiskMockActor : public TActorBootstrapped<TPDiskMockActor> {
491491
const ui64 bulkWriteBlockSize = 65536;
492492
res = std::make_unique<NPDisk::TEvYardInitResult>(NKikimrProto::OK, seekTimeUs, readSpeedBps, writeSpeedBps,
493493
readBlockSize, writeBlockSize, bulkWriteBlockSize, Impl.ChunkSize, Impl.AppendBlockSize, ownerId,
494-
owner->OwnerRound, owner->Weight, 0u, GetStatusFlags(), std::move(ownedChunks), NPDisk::DEVICE_TYPE_NVME, TString());
494+
owner->OwnerRound, owner->Weight, 0u, GetStatusFlags(), std::move(ownedChunks), NPDisk::DEVICE_TYPE_NVME, false, TString());
495495
res->StartingPoints = owner->StartingPoints;
496496
} else {
497497
res = std::make_unique<NPDisk::TEvYardInitResult>(NKikimrProto::INVALID_ROUND, "invalid owner round");

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ namespace NKikimr {
132132

133133
}
134134

135+
const ui32 TVDiskConfig::TinyDiskHullCompLevel0MaxSstsAtOnce = 2u;
136+
const ui32 TVDiskConfig::TinyDiskHullCompSortedPartsNum = 2u;
137+
135138
void TVDiskConfig::SetupHugeBytes() {
136139
switch (BaseInfo.DeviceType) {
137140
case NPDisk::DEVICE_TYPE_SSD:

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ namespace NKikimr {
134134
ui64 AnubisOsirisMaxInFly;
135135
bool AddHeader;
136136

137+
static const ui32 TinyDiskHullCompLevel0MaxSstsAtOnce;
138+
static const ui32 TinyDiskHullCompSortedPartsNum;
139+
137140
//////////////// LOG CUTTER SETTINGS ////////////////
138141
TDuration RecoveryLogCutterFirstDuration;
139142
TDuration RecoveryLogCutterRegularDuration;

ydb/core/blobstorage/vdisk/hulldb/base/blobstorage_hulldefs.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ namespace NKikimr {
111111
THullCtx::THullCtx(TVDiskContextPtr vctx, const TIntrusivePtr<TVDiskConfig> vcfg, ui32 chunkSize, ui32 compWorthReadSize,
112112
bool freshCompaction, bool gcOnlySynced, bool allowKeepFlags, bool barrierValidation, ui32 hullSstSizeInChunksFresh,
113113
ui32 hullSstSizeInChunksLevel, double hullCompFreeSpaceThreshold, double hullCompReadBatchEfficiencyThreshold,
114-
TDuration hullCompStorageRatioCalcPeriod, TDuration hullCompStorageRatioMaxCalcDuration, bool addHeader)
114+
TDuration hullCompStorageRatioCalcPeriod, TDuration hullCompStorageRatioMaxCalcDuration, bool addHeader,
115+
ui32 hullCompLevel0MaxSstsAtOnce, ui32 hullCompSortedPartsNum)
115116
: VCtx(std::move(vctx))
116117
, VCfg(vcfg)
117118
, IngressCache(TIngressCache::Create(VCtx->Top, VCtx->ShortSelfVDisk))
@@ -128,6 +129,8 @@ namespace NKikimr {
128129
, HullCompStorageRatioCalcPeriod(hullCompStorageRatioCalcPeriod)
129130
, HullCompStorageRatioMaxCalcDuration(hullCompStorageRatioMaxCalcDuration)
130131
, AddHeader(addHeader)
132+
, HullCompLevel0MaxSstsAtOnce(hullCompLevel0MaxSstsAtOnce)
133+
, HullCompSortedPartsNum(hullCompSortedPartsNum)
131134
, CompactionStrategyGroup(VCtx->VDiskCounters, "subsystem", "compstrategy")
132135
, LsmHullGroup(VCtx->VDiskCounters, "subsystem", "lsmhull")
133136
, LsmHullSpaceGroup(VCtx->VDiskCounters, "subsystem", "outofspace")

ydb/core/blobstorage/vdisk/hulldb/base/blobstorage_hulldefs.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ namespace NKikimr {
136136
const TDuration HullCompStorageRatioCalcPeriod;
137137
const TDuration HullCompStorageRatioMaxCalcDuration;
138138
const bool AddHeader;
139+
ui32 HullCompLevel0MaxSstsAtOnce;
140+
ui32 HullCompSortedPartsNum;
139141

140142
NMonGroup::TCompactionStrategyGroup CompactionStrategyGroup;
141143
NMonGroup::TLsmHullGroup LsmHullGroup;
@@ -156,7 +158,10 @@ namespace NKikimr {
156158
double hullCompReadBatchEfficiencyThreshold,
157159
TDuration hullCompStorageRatioCalcPeriod,
158160
TDuration hullCompStorageRatioMaxCalcDuration,
159-
bool addHeader);
161+
bool addHeader,
162+
ui32 hullCompLevel0MaxSstsAtOnce,
163+
ui32 hullCompSortedPartsNum
164+
);
160165

161166
void UpdateSpaceCounters(const NHullComp::TSstRatio& prev, const NHullComp::TSstRatio& current);
162167
};
@@ -192,4 +197,3 @@ namespace NKikimr {
192197
};
193198

194199
} // NKikimr
195-

0 commit comments

Comments
 (0)