Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue-539: add tablet-side two-stage writes support for scaling throughput #707

Merged
merged 19 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from 12 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
8 changes: 8 additions & 0 deletions cloud/filestore/config/storage.proto
Original file line number Diff line number Diff line change
Expand Up @@ -216,4 +216,12 @@ message TStorageConfig
optional uint32 EntryTimeout = 335;
optional uint32 NegativeEntryTimeout = 336;
optional uint32 AttrTimeout = 337;

// Enables GenerateBlobs + WriteBlob + AddData instead of WriteBlob
// for writing.
optional bool TwoStageWriteEnabled = 338;
debnatkh marked this conversation as resolved.
Show resolved Hide resolved

// When issuing blobs, the tablet acquires collect barrier. In order to
debnatkh marked this conversation as resolved.
Show resolved Hide resolved
// release it in case of a client disconnect, this timeout is used.
optional uint32 GenerateBlobsReleaseCollectBarrierTimeout = 339;
}
8 changes: 8 additions & 0 deletions cloud/filestore/libs/storage/api/tablet.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ namespace NCloud::NFileStore::NStorage {
xxx(ChangeStorageConfig, __VA_ARGS__) \
xxx(DescribeData, __VA_ARGS__) \
xxx(DescribeSessions, __VA_ARGS__) \
xxx(GenerateBlobs, __VA_ARGS__) \
debnatkh marked this conversation as resolved.
Show resolved Hide resolved
xxx(AddData, __VA_ARGS__) \
// FILESTORE_TABLET_REQUESTS

////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -65,6 +67,12 @@ struct TEvIndexTablet
EvDescribeSessionsRequest = EvBegin + 17,
EvDescribeSessionsResponse,

EvGenerateBlobsRequest = EvBegin + 19,
EvGenerateBlobsResponse,

EvAddDataRequest = EvBegin + 21,
EvAddDataResponse,

EvEnd
};

Expand Down
5 changes: 5 additions & 0 deletions cloud/filestore/libs/storage/core/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,16 @@ namespace {
NCloud::NProto::AUTHORIZATION_IGNORE )\
\
xxx(TwoStageReadEnabled, bool, false )\
xxx(TwoStageWriteEnabled, bool, false )\
xxx(EntryTimeout, TDuration, TDuration::Zero() )\
xxx(NegativeEntryTimeout, TDuration, TDuration::Zero() )\
xxx(AttrTimeout, TDuration, TDuration::Zero() )\
xxx(MaxOutOfOrderCompactionMapLoadRequestsInQueue, ui32, 5 )\
xxx(MaxBackpressureErrorsBeforeSuicide, ui32, 1000 )\
\
xxx(GenerateBlobsReleaseCollectBarrierTimeout, \
debnatkh marked this conversation as resolved.
Show resolved Hide resolved
TDuration, \
TDuration::Seconds(10) )\
// FILESTORE_STORAGE_CONFIG

#define FILESTORE_DECLARE_CONFIG(name, type, value) \
Expand Down
3 changes: 3 additions & 0 deletions cloud/filestore/libs/storage/core/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ class TStorageConfig
NCloud::NProto::EAuthorizationMode GetAuthorizationMode() const;

bool GetTwoStageReadEnabled() const;
bool GetTwoStageWriteEnabled() const;
TDuration GetEntryTimeout() const;
TDuration GetNegativeEntryTimeout() const;
TDuration GetAttrTimeout() const;
Expand All @@ -185,6 +186,8 @@ class TStorageConfig

ui32 GetMaxBackpressureErrorsBeforeSuicide() const;

TDuration GetGenerateBlobsReleaseCollectBarrierTimeout() const;

void Dump(IOutputStream& out) const;
void DumpHtml(IOutputStream& out) const;
void DumpOverridesHtml(IOutputStream& out) const;
Expand Down
10 changes: 10 additions & 0 deletions cloud/filestore/libs/storage/model/block_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ class TBlockBuffer final
return { ptr, ByteRange.BlockSize };
}

ui32 GetBlockSize() const override
{
return ByteRange.BlockSize;
}

void SetBlock(size_t index, TStringBuf block) override
{
Y_ABORT_UNLESS(block.size() == ByteRange.BlockSize);
Expand Down Expand Up @@ -107,6 +112,11 @@ class TLazyBlockBuffer final
return block;
}

ui32 GetBlockSize() const override
{
return ByteRange.BlockSize;
}

void SetBlock(size_t index, TStringBuf block) override
{
Y_ABORT_UNLESS(block.size() == ByteRange.BlockSize);
Expand Down
1 change: 1 addition & 0 deletions cloud/filestore/libs/storage/model/block_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ struct IBlockBuffer

virtual TStringBuf GetUnalignedHead() = 0;
virtual TStringBuf GetBlock(size_t index) = 0;
virtual ui32 GetBlockSize() const = 0;
virtual TStringBuf GetUnalignedTail() = 0;
virtual void SetBlock(size_t index, TStringBuf block) = 0;
virtual void ClearBlock(size_t index) = 0;
Expand Down
12 changes: 7 additions & 5 deletions cloud/filestore/libs/storage/tablet/model/blob_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,18 @@ void TMergedBlobBuilder::Accept(
const TBlock& block,
ui32 blocksCount,
ui32 blockOffset,
IBlockBuffer& buffer)
IBlockBuffer& buffer,
bool shouldFillBlobContent)
debnatkh marked this conversation as resolved.
Show resolved Hide resolved
{
TString blobContent;
blobContent.reserve(blocksCount * BlockSize);

for (size_t i = 0; i < blocksCount; ++i) {
auto blockData = buffer.GetBlock(blockOffset + i);
Y_ABORT_UNLESS(blockData.size() == BlockSize);

blobContent.append(blockData);
Y_ABORT_UNLESS(buffer.GetBlockSize() == BlockSize);
debnatkh marked this conversation as resolved.
Show resolved Hide resolved
if (shouldFillBlobContent) {
auto blockData = buffer.GetBlock(blockOffset + i);
blobContent.append(blockData);
}
}

BlocksCount += blocksCount;
Expand Down
3 changes: 2 additions & 1 deletion cloud/filestore/libs/storage/tablet/model/blob_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ class TMergedBlobBuilder
const TBlock& block,
ui32 blocksCount,
ui32 blockOffset,
IBlockBuffer& buffer);
IBlockBuffer& buffer,
bool shouldFillBlobContent);

TVector<TMergedBlob> Finish();

Expand Down
13 changes: 11 additions & 2 deletions cloud/filestore/libs/storage/tablet/model/garbage_queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,14 @@ void TGarbageQueue::AcquireCollectBarrier(ui64 commitId)
}
}

void TGarbageQueue::ReleaseCollectBarrier(ui64 commitId)
void TGarbageQueue::ReleaseCollectBarrier(ui64 commitId, bool allowMissing)
debnatkh marked this conversation as resolved.
Show resolved Hide resolved
{
{
auto it = Impl->Barriers.find(commitId);
Y_ABORT_UNLESS(it != Impl->Barriers.end());
Y_ABORT_UNLESS(it != Impl->Barriers.end() || allowMissing);
if (it == Impl->Barriers.end()) {
return;
}

auto& barrier = const_cast<TBarrier&>(*it);

Expand All @@ -210,6 +213,12 @@ void TGarbageQueue::ReleaseCollectBarrier(ui64 commitId)
}
}

bool TGarbageQueue::IsCollectBarrierAcquired(ui64 commitId) const
{
auto it = Impl->Barriers.find(commitId);
return it != Impl->Barriers.end() && it->RefCount > 0;
qkrorlqr marked this conversation as resolved.
Show resolved Hide resolved
}

ui64 TGarbageQueue::GetCollectCommitId() const
{
if (Impl->Barriers) {
Expand Down
7 changes: 6 additions & 1 deletion cloud/filestore/libs/storage/tablet/model/garbage_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ class TGarbageQueue
//

void AcquireCollectBarrier(ui64 commitId);
void ReleaseCollectBarrier(ui64 commitId);
/**
* @param allowMissing If true, there will not be an abort if the barrier is
* missing.
*/
void ReleaseCollectBarrier(ui64 commitId, bool allowMissing);
bool IsCollectBarrierAcquired(ui64 commitId) const;

ui64 GetCollectCommitId() const;
};
Expand Down
7 changes: 7 additions & 0 deletions cloud/filestore/libs/storage/tablet/tablet_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@ STFUNC(TIndexTabletActor::StateBoot)
IgnoreFunc(TEvLocal::TEvTabletMetrics);
IgnoreFunc(TEvIndexTabletPrivate::TEvUpdateCounters);
IgnoreFunc(TEvIndexTabletPrivate::TEvUpdateLeakyBucketCounters);
IgnoreFunc(TEvIndexTabletPrivate::TEvReleaseCollectBarrier);

IgnoreFunc(TEvHiveProxy::TEvReassignTabletResponse);

Expand All @@ -515,6 +516,7 @@ STFUNC(TIndexTabletActor::StateInit)
HFunc(TEvFileStore::TEvUpdateConfig, HandleUpdateConfig);
HFunc(TEvIndexTabletPrivate::TEvUpdateCounters, HandleUpdateCounters);
HFunc(TEvIndexTabletPrivate::TEvUpdateLeakyBucketCounters, HandleUpdateLeakyBucketCounters);
HFunc(TEvIndexTabletPrivate::TEvReleaseCollectBarrier, HandleReleaseCollectBarrier);

FILESTORE_HANDLE_REQUEST(WaitReady, TEvIndexTablet)

Expand Down Expand Up @@ -542,6 +544,8 @@ STFUNC(TIndexTabletActor::StateWork)
HFunc(TEvIndexTabletPrivate::TEvUpdateCounters, HandleUpdateCounters);
HFunc(TEvIndexTabletPrivate::TEvUpdateLeakyBucketCounters, HandleUpdateLeakyBucketCounters);

HFunc(TEvIndexTabletPrivate::TEvReleaseCollectBarrier, HandleReleaseCollectBarrier);

HFunc(TEvents::TEvWakeup, HandleWakeup);
HFunc(TEvents::TEvPoisonPill, HandlePoisonPill);

Expand Down Expand Up @@ -579,6 +583,8 @@ STFUNC(TIndexTabletActor::StateZombie)
IgnoreFunc(TEvIndexTabletPrivate::TEvUpdateCounters);
IgnoreFunc(TEvIndexTabletPrivate::TEvUpdateLeakyBucketCounters);

IgnoreFunc(TEvIndexTabletPrivate::TEvReleaseCollectBarrier);

IgnoreFunc(TEvIndexTabletPrivate::TEvReadDataCompleted);
IgnoreFunc(TEvIndexTabletPrivate::TEvWriteDataCompleted);

Expand All @@ -604,6 +610,7 @@ STFUNC(TIndexTabletActor::StateBroken)
switch (ev->GetTypeRewrite()) {
IgnoreFunc(TEvIndexTabletPrivate::TEvUpdateCounters);
IgnoreFunc(TEvIndexTabletPrivate::TEvUpdateLeakyBucketCounters);
IgnoreFunc(TEvIndexTabletPrivate::TEvReleaseCollectBarrier);

HFunc(TEvents::TEvPoisonPill, HandlePoisonPill);
HFunc(TEvTablet::TEvTabletDead, HandleTabletDead);
Expand Down
4 changes: 4 additions & 0 deletions cloud/filestore/libs/storage/tablet/tablet_actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,10 @@ class TIndexTabletActor final
const TEvIndexTabletPrivate::TEvUpdateLeakyBucketCounters::TPtr& ev,
const NActors::TActorContext& ctx);

void HandleReleaseCollectBarrier(
const TEvIndexTabletPrivate::TEvReleaseCollectBarrier::TPtr& ev,
const NActors::TActorContext& ctx);

void HandleReadDataCompleted(
const TEvIndexTabletPrivate::TEvReadDataCompleted::TPtr& ev,
const NActors::TActorContext& ctx);
Expand Down
Loading
Loading