Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ydb/core/blobstorage/nodewarden/node_warden_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ void TNodeWarden::Bootstrap() {
icb->RegisterSharedControl(DefaultHugeGarbagePerMille, "VDiskControls.DefaultHugeGarbagePerMille");
icb->RegisterSharedControl(HugeDefragFreeSpaceBorderPerMille, "VDiskControls.HugeDefragFreeSpaceBorderPerMille");
icb->RegisterSharedControl(MaxChunksToDefragInflight, "VDiskControls.MaxChunksToDefragInflight");
icb->RegisterSharedControl(EnableExplicitCompactionAfterDefrag, "VDiskControls.EnableExplicitCompactionAfterDefrag");
icb->RegisterSharedControl(FreshCompMaxInFlightWrites, "VDiskControls.FreshCompMaxInFlightWrites");
icb->RegisterSharedControl(HullCompMaxInFlightWrites, "VDiskControls.HullCompMaxInFlightWrites");
icb->RegisterSharedControl(HullCompMaxInFlightReads, "VDiskControls.HullCompMaxInFlightReads");

icb->RegisterSharedControl(CostMetricsParametersByMedia[NPDisk::DEVICE_TYPE_ROT].BurstThresholdNs,
"VDiskControls.BurstThresholdNsHDD");
Expand Down
4 changes: 4 additions & 0 deletions ydb/core/blobstorage/nodewarden/node_warden_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ namespace NKikimr::NStorage {
TControlWrapper DefaultHugeGarbagePerMille;
TControlWrapper HugeDefragFreeSpaceBorderPerMille;
TControlWrapper MaxChunksToDefragInflight;
TControlWrapper EnableExplicitCompactionAfterDefrag;
TControlWrapper FreshCompMaxInFlightWrites;
TControlWrapper HullCompMaxInFlightWrites;
TControlWrapper HullCompMaxInFlightReads;

TReplQuoter::TPtr ReplNodeRequestQuoter;
TReplQuoter::TPtr ReplNodeResponseQuoter;
Expand Down
4 changes: 4 additions & 0 deletions ydb/core/blobstorage/nodewarden/node_warden_vdisk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ namespace NKikimr::NStorage {
vdiskConfig->DefaultHugeGarbagePerMille = DefaultHugeGarbagePerMille;
vdiskConfig->HugeDefragFreeSpaceBorderPerMille = HugeDefragFreeSpaceBorderPerMille;
vdiskConfig->MaxChunksToDefragInflight = MaxChunksToDefragInflight;
vdiskConfig->EnableExplicitCompactionAfterDefrag = EnableExplicitCompactionAfterDefrag;
vdiskConfig->FreshCompMaxInFlightWrites = FreshCompMaxInFlightWrites;
vdiskConfig->HullCompMaxInFlightWrites = HullCompMaxInFlightWrites;
vdiskConfig->HullCompMaxInFlightReads = HullCompMaxInFlightReads;

vdiskConfig->EnableLocalSyncLogDataCutting = EnableLocalSyncLogDataCutting;
if (deviceType == NPDisk::EDeviceType::DEVICE_TYPE_ROT) {
Expand Down
6 changes: 5 additions & 1 deletion ydb/core/blobstorage/vdisk/common/vdisk_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ namespace NKikimr {
HandoffTimeout = TDuration::Seconds(10);
RunRepl = !baseInfo.ReadOnly;

ReplMaxTimeToMakeProgress = VDiskPerformance.at(baseInfo.DeviceType).ReplMaxTimeToMakeProgress;
if (const auto& perf = VDiskPerformance.find(baseInfo.DeviceType); perf != VDiskPerformance.end()) {
ReplMaxTimeToMakeProgress = perf->second.ReplMaxTimeToMakeProgress;
} else {
ReplMaxTimeToMakeProgress = TDuration::Minutes(180);
}

SkeletonFrontGets_MaxInFlightCount = 24;
SkeletonFrontGets_MaxInFlightCost = 200000000; // 200ms
Expand Down
7 changes: 4 additions & 3 deletions ydb/core/blobstorage/vdisk/common/vdisk_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ namespace NKikimr {
ui32 HullCompSortedPartsNum;
double HullCompLevelRateThreshold;
double HullCompFreeSpaceThreshold;
ui32 FreshCompMaxInFlightWrites;
ui32 HullCompMaxInFlightWrites;
ui32 HullCompMaxInFlightReads;
TControlWrapper FreshCompMaxInFlightWrites;
TControlWrapper HullCompMaxInFlightWrites;
TControlWrapper HullCompMaxInFlightReads;
double HullCompReadBatchEfficiencyThreshold;
ui64 AnubisOsirisMaxInFly;
bool AddHeader;
Expand Down Expand Up @@ -239,6 +239,7 @@ namespace NKikimr {
TControlWrapper DefaultHugeGarbagePerMille = 300;
TControlWrapper HugeDefragFreeSpaceBorderPerMille = 260;
TControlWrapper MaxChunksToDefragInflight = 10;
TControlWrapper EnableExplicitCompactionAfterDefrag = 1;

///////////// COST METRICS SETTINGS ////////////////
bool UseCostTracker = true;
Expand Down
2 changes: 1 addition & 1 deletion ydb/core/blobstorage/vdisk/defrag/defrag_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ namespace NKikimr {
InProgress = true;
ActiveActors.Insert(ctx.Register(CreateDefragQuantumActor(DCtx,
GInfo->GetVDiskId(DCtx->VCtx->ShortSelfVDisk),
std::visit([](auto& r) { return GetChunksToDefrag(r); }, task.Request))), __FILE__, __LINE__,
std::visit([](auto& r) { return GetChunksToDefrag(r); }, task.Request), DCtx->VCfg->EnableExplicitCompactionAfterDefrag)), __FILE__, __LINE__,
ctx, NKikimrServices::BLOBSTORAGE);
}

Expand Down
12 changes: 8 additions & 4 deletions ydb/core/blobstorage/vdisk/defrag/defrag_quantum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ namespace NKikimr {
std::shared_ptr<TDefragCtx> DCtx;
const TVDiskID SelfVDiskId;
std::optional<TChunksToDefrag> ChunksToDefrag;
bool NeedCompaction;

enum {
EvResume = EventSpaceBegin(TEvents::ES_PRIVATE)
Expand All @@ -28,11 +29,12 @@ namespace NKikimr {

public:
TDefragQuantum(const std::shared_ptr<TDefragCtx>& dctx, const TVDiskID& selfVDiskId,
std::optional<TChunksToDefrag> chunksToDefrag)
std::optional<TChunksToDefrag> chunksToDefrag, bool needCompaction)
: TActorCoroImpl(64_KB, true)
, DCtx(dctx)
, SelfVDiskId(selfVDiskId)
, ChunksToDefrag(std::move(chunksToDefrag))
, NeedCompaction(needCompaction)
{}

void ProcessUnexpectedEvent(TAutoPtr<IEventHandle> ev) {
Expand Down Expand Up @@ -92,7 +94,9 @@ namespace NKikimr {
stat.RewrittenRecs = ev->Get()->RewrittenRecs;
stat.RewrittenBytes = ev->Get()->RewrittenBytes;

Compact();
if (NeedCompaction) {
Compact();
}

auto hugeStat = GetHugeStat();
Y_DEBUG_ABORT_UNLESS(hugeStat.LockedChunks.size() < 100);
Expand Down Expand Up @@ -129,8 +133,8 @@ namespace NKikimr {
};

IActor *CreateDefragQuantumActor(const std::shared_ptr<TDefragCtx>& dctx, const TVDiskID& selfVDiskId,
std::optional<TChunksToDefrag> chunksToDefrag) {
return new TActorCoro(MakeHolder<TDefragQuantum>(dctx, selfVDiskId, std::move(chunksToDefrag)),
std::optional<TChunksToDefrag> chunksToDefrag, bool needCompaction) {
return new TActorCoro(MakeHolder<TDefragQuantum>(dctx, selfVDiskId, std::move(chunksToDefrag), needCompaction),
NKikimrServices::TActivity::BS_DEFRAG_QUANTUM);
}

Expand Down
2 changes: 1 addition & 1 deletion ydb/core/blobstorage/vdisk/defrag/defrag_quantum.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace NKikimr {
struct TChunksToDefrag;

IActor *CreateDefragQuantumActor(const std::shared_ptr<TDefragCtx>& dctx, const TVDiskID& selfVDiskId,
std::optional<TChunksToDefrag> chunksToDefrag);
std::optional<TChunksToDefrag> chunksToDefrag, bool needCompaction);

} // NKikimr

Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ namespace NKikimr {
str << "{Id# " << Id << "}";
}

THullCtx::THullCtx(TVDiskContextPtr vctx, ui32 chunkSize, ui32 compWorthReadSize, bool freshCompaction,
bool gcOnlySynced, bool allowKeepFlags, bool barrierValidation, ui32 hullSstSizeInChunksFresh,
ui32 hullSstSizeInChunksLevel, double hullCompFreeSpaceThreshold, ui32 freshCompMaxInFlightWrites,
ui32 hullCompMaxInFlightWrites, ui32 hullCompMaxInFlightReads, double hullCompReadBatchEfficiencyThreshold,
THullCtx::THullCtx(TVDiskContextPtr vctx, const TIntrusivePtr<TVDiskConfig> vcfg, ui32 chunkSize, ui32 compWorthReadSize,
bool freshCompaction, bool gcOnlySynced, bool allowKeepFlags, bool barrierValidation, ui32 hullSstSizeInChunksFresh,
ui32 hullSstSizeInChunksLevel, double hullCompFreeSpaceThreshold, double hullCompReadBatchEfficiencyThreshold,
TDuration hullCompStorageRatioCalcPeriod, TDuration hullCompStorageRatioMaxCalcDuration, bool addHeader)
: VCtx(std::move(vctx))
, VCfg(vcfg)
, IngressCache(TIngressCache::Create(VCtx->Top, VCtx->ShortSelfVDisk))
, ChunkSize(chunkSize)
, CompWorthReadSize(compWorthReadSize)
Expand All @@ -101,9 +101,6 @@ namespace NKikimr {
, HullSstSizeInChunksFresh(hullSstSizeInChunksFresh)
, HullSstSizeInChunksLevel(hullSstSizeInChunksLevel)
, HullCompFreeSpaceThreshold(hullCompFreeSpaceThreshold)
, FreshCompMaxInFlightWrites(freshCompMaxInFlightWrites)
, HullCompMaxInFlightWrites(hullCompMaxInFlightWrites)
, HullCompMaxInFlightReads(hullCompMaxInFlightReads)
, HullCompReadBatchEfficiencyThreshold(hullCompReadBatchEfficiencyThreshold)
, HullCompStorageRatioCalcPeriod(hullCompStorageRatioCalcPeriod)
, HullCompStorageRatioMaxCalcDuration(hullCompStorageRatioMaxCalcDuration)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ namespace NKikimr {
///////////////////////////////////////////////////////////////////////////////////////
struct THullCtx : public TThrRefBase {
TVDiskContextPtr VCtx;
const TIntrusivePtr<TVDiskConfig> VCfg;
const TIntrusivePtr<TIngressCache> IngressCache;
const ui32 ChunkSize;
const ui32 CompWorthReadSize;
Expand All @@ -131,9 +132,6 @@ namespace NKikimr {
const ui32 HullSstSizeInChunksFresh;
const ui32 HullSstSizeInChunksLevel;
const double HullCompFreeSpaceThreshold;
const ui32 FreshCompMaxInFlightWrites;
const ui32 HullCompMaxInFlightWrites;
const ui32 HullCompMaxInFlightReads;
const double HullCompReadBatchEfficiencyThreshold;
const TDuration HullCompStorageRatioCalcPeriod;
const TDuration HullCompStorageRatioMaxCalcDuration;
Expand All @@ -144,6 +142,7 @@ namespace NKikimr {

THullCtx(
TVDiskContextPtr vctx,
const TIntrusivePtr<TVDiskConfig> vcfg,
ui32 chunkSize,
ui32 compWorthReadSize,
bool freshCompaction,
Expand All @@ -153,9 +152,6 @@ namespace NKikimr {
ui32 hullSstSizeInChunksFresh,
ui32 hullSstSizeInChunksLevel,
double hullCompFreeSpaceThreshold,
ui32 freshCompMaxInFlightWrites,
ui32 hullCompMaxInFlightWrites,
ui32 hullCompMaxInFlightReads,
double hullCompReadBatchEfficiencyThreshold,
TDuration hullCompStorageRatioCalcPeriod,
TDuration hullCompStorageRatioMaxCalcDuration,
Expand Down
8 changes: 4 additions & 4 deletions ydb/core/blobstorage/vdisk/hulldb/base/hullds_ut.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ namespace NKikimr {
: ChunkSize(chunkSize)
, CompWorthReadSize(compWorthReadSize)
, GroupInfo(TBlobStorageGroupType::ErasureMirror3, 2, 4)
, VCfg(TVDiskConfig::TBaseInfo::SampleForTests())
, VCtx(new TVDiskContext(TActorId(), GroupInfo.PickTopology(), new ::NMonitoring::TDynamicCounters(),
TVDiskID(), nullptr, NPDisk::DEVICE_TYPE_UNKNOWN))
, HullCtx(
new THullCtx(
VCtx,
MakeIntrusive<TVDiskConfig>(VCfg),
ChunkSize,
CompWorthReadSize,
true,
Expand All @@ -26,13 +28,10 @@ namespace NKikimr {
1, // HullSstSizeInChunksFresh
1, // HullSstSizeInChunksLevel
2.0,
10, // FreshCompMaxInFlightWrites
10, // HullCompMaxInFlightWrites
20, // HullCompMaxInFlightReads
0.5,
TDuration::Minutes(5),
TDuration::Seconds(1),
true)) // AddHeader
true))// AddHeader
, LevelIndexSettings(
HullCtx,
8u, // Level0MaxSstsAtOnce
Expand Down Expand Up @@ -60,6 +59,7 @@ namespace NKikimr {
const ui32 ChunkSize;
const ui64 CompWorthReadSize;
TBlobStorageGroupInfo GroupInfo;
TVDiskConfig VCfg;
TVDiskContextPtr VCtx;
THullCtxPtr HullCtx;
TLevelIndexSettings LevelIndexSettings;
Expand Down
26 changes: 12 additions & 14 deletions ydb/core/blobstorage/vdisk/hullop/blobstorage_hullcompactworker.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,9 @@ namespace NKikimr {
// number of currently unresponded write requests
ui32 InFlightWrites = 0;

// maximum number of such requests
ui32 MaxInFlightWrites;

// number of currently unresponded read requests
ui32 InFlightReads = 0;

// maximum number of such requests
ui32 MaxInFlightReads;

// vector of freed huge blobs
TDiskPartVec FreedHugeBlobs;

Expand Down Expand Up @@ -295,14 +289,10 @@ namespace NKikimr {
{
if (IsFresh) {
ChunksToUse = HullCtx->HullSstSizeInChunksFresh;
MaxInFlightWrites = HullCtx->FreshCompMaxInFlightWrites;
MaxInFlightReads = 0;
ReadsInFlight = nullptr;
WritesInFlight = &LevelIndex->FreshCompWritesInFlight;
} else {
ChunksToUse = HullCtx->HullSstSizeInChunksLevel;
MaxInFlightWrites = HullCtx->HullCompMaxInFlightWrites;
MaxInFlightReads = HullCtx->HullCompMaxInFlightReads;
ReadsInFlight = &LevelIndex->HullCompReadsInFlight;
WritesInFlight = &LevelIndex->HullCompWritesInFlight;
}
Expand Down Expand Up @@ -411,7 +401,7 @@ namespace NKikimr {

case EState::FlushingSST:
// do not continue processing if there are too many writes in flight
if (InFlightWrites >= MaxInFlightWrites) {
if (InFlightWrites >= GetMaxInFlightWrites()) {
return false;
}
// try to flush SST
Expand Down Expand Up @@ -673,7 +663,7 @@ namespace NKikimr {
bool FlushSST(TVector<std::unique_ptr<IEventBase>>& msgsForYard) {
// try to flush some more data; if the flush fails, it means that we have reached in flight write limit and
// there is nothing to do here now, so we return
const bool flushDone = WriterPtr->FlushNext(FirstLsn, LastLsn, MaxInFlightWrites - InFlightWrites);
const bool flushDone = WriterPtr->FlushNext(FirstLsn, LastLsn, GetMaxInFlightWrites() - InFlightWrites);
ProcessPendingMessages(msgsForYard);
if (!flushDone) {
return false;
Expand All @@ -697,7 +687,7 @@ namespace NKikimr {

// send new messages until we reach in flight limit
std::unique_ptr<NPDisk::TEvChunkWrite> msg;
while (InFlightWrites < MaxInFlightWrites && (msg = WriterPtr->GetPendingMessage())) {
while (InFlightWrites < GetMaxInFlightWrites() && (msg = WriterPtr->GetPendingMessage())) {
HullCtx->VCtx->CountCompactionCost(*msg);
Statistics.Update(msg.get());
msgsForYard.push_back(std::move(msg));
Expand All @@ -706,7 +696,7 @@ namespace NKikimr {
}

std::unique_ptr<NPDisk::TEvChunkRead> readMsg;
while (InFlightReads < MaxInFlightReads && (readMsg = ReadBatcher.GetPendingMessage(
while (InFlightReads < GetMaxInFlightReads() && (readMsg = ReadBatcher.GetPendingMessage(
PDiskCtx->Dsk->Owner, PDiskCtx->Dsk->OwnerRound, NPriRead::HullComp))) {
HullCtx->VCtx->CountCompactionCost(*readMsg);
Statistics.Update(readMsg.get());
Expand All @@ -724,6 +714,14 @@ namespace NKikimr {
ChunkReservePending += num;
return std::make_unique<NPDisk::TEvChunkReserve>(PDiskCtx->Dsk->Owner, PDiskCtx->Dsk->OwnerRound, num);
}

ui32 GetMaxInFlightWrites() {
return IsFresh ? HullCtx->VCfg->FreshCompMaxInFlightWrites : HullCtx->VCfg->HullCompMaxInFlightWrites;
}

ui32 GetMaxInFlightReads() {
return IsFresh ? (ui32) 0 : (ui32) HullCtx->VCfg->HullCompMaxInFlightReads;
}
};

} // NKikimr
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,7 @@ namespace NKikimr {
Y_ABORT_UNLESS(LocRecCtx->VCtx && LocRecCtx->VCtx->Top);
auto hullCtx = MakeIntrusive<THullCtx>(
LocRecCtx->VCtx,
Config,
ui32(LocRecCtx->PDiskCtx->Dsk->ChunkSize),
ui32(LocRecCtx->PDiskCtx->Dsk->PrefetchSizeBytes),
Config->FreshCompaction && !Config->BaseInfo.ReadOnly,
Expand All @@ -489,9 +490,6 @@ namespace NKikimr {
Config->HullSstSizeInChunksFresh,
Config->HullSstSizeInChunksLevel,
Config->HullCompFreeSpaceThreshold,
Config->FreshCompMaxInFlightWrites,
Config->HullCompMaxInFlightWrites,
Config->HullCompMaxInFlightReads,
Config->HullCompReadBatchEfficiencyThreshold,
Config->HullCompStorageRatioCalcPeriod,
Config->HullCompStorageRatioMaxCalcDuration,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ TVDiskContextPtr CreateVDiskContext(const TBlobStorageGroupInfo& info) {
}

TIntrusivePtr<THullCtx> CreateHullCtx(const TBlobStorageGroupInfo& info, ui32 chunkSize, ui32 compWorthReadSize) {
return MakeIntrusive<THullCtx>(CreateVDiskContext(info), chunkSize, compWorthReadSize, true, true, true, true, 1u,
1u, 2.0, 10u, 10u, 20u, 0.5, TDuration::Minutes(5), TDuration::Seconds(1), true);
auto baseInfo = TVDiskConfig::TBaseInfo::SampleForTests();
return MakeIntrusive<THullCtx>(CreateVDiskContext(info), MakeIntrusive<TVDiskConfig>(baseInfo), chunkSize, compWorthReadSize, true, true, true, true, 1u,
1u, 2.0, 0.5, TDuration::Minutes(5), TDuration::Seconds(1), true);
}

TIntrusivePtr<THullDs> CreateHullDs(const TBlobStorageGroupInfo& info) {
Expand Down
30 changes: 30 additions & 0 deletions ydb/core/protos/config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1352,6 +1352,36 @@ message TImmediateControlsConfig {
MinValue: 1,
MaxValue: 50,
DefaultValue: 10 }];

optional uint64 EnableExplicitCompactionAfterDefrag = 28 [(ControlOptions) = {
Description: "Enable explicit compaction call after defragmentation",
MinValue: 0,
MaxValue: 1,
DefaultValue: 1 }];

optional uint64 FreshCompMaxInFlightWrites = 29 [(ControlOptions) = {
Description: "Max writes inflight for fresh level compaction",
MinValue: 1,
MaxValue: 1000,
DefaultValue: 10 }];

optional uint64 FreshCompMaxInFlightReads = 30 [(ControlOptions) = {
Description: "Max reads inflight for fresh level compaction",
MinValue: 1,
MaxValue: 1000,
DefaultValue: 10 }];

optional uint64 HullCompMaxInFlightWrites = 31 [(ControlOptions) = {
Description: "Max writes inflight for level compaction",
MinValue: 1,
MaxValue: 1000,
DefaultValue: 10 }];

optional uint64 HullCompMaxInFlightReads = 32 [(ControlOptions) = {
Description: "Max reads inflight for level compaction",
MinValue: 1,
MaxValue: 1000,
DefaultValue: 20 }];
}

message TTabletControls {
Expand Down
Loading