forked from ydb-platform/ydb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reduce throughput on overload special (ydb-platform#13148)
- Loading branch information
1 parent
2e6c0ff
commit ed45656
Showing
9 changed files
with
208 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#include "write_queue.h" | ||
|
||
#include <ydb/core/tx/columnshard/columnshard_impl.h> | ||
#include <ydb/core/tx/columnshard/operations/write_data.h> | ||
#include <ydb/core/tx/data_events/write_data.h> | ||
|
||
namespace NKikimr::NColumnShard { | ||
|
||
bool TWriteTask::Execute(TColumnShard* owner, const TActorContext& ctx) { | ||
auto overloadStatus = owner->CheckOverloadedWait(PathId); | ||
if (overloadStatus != TColumnShard::EOverloadStatus::None) { | ||
AFL_DEBUG(NKikimrServices::TX_COLUMNSHARD_WRITE)("event", "wait_overload")("status", overloadStatus); | ||
return false; | ||
} | ||
|
||
owner->Counters.GetCSCounters().WritingCounters->OnWritingTaskDequeue(TMonotonic::Now() - Created); | ||
owner->OperationsManager->RegisterLock(LockId, owner->Generation()); | ||
auto writeOperation = owner->OperationsManager->RegisterOperation( | ||
PathId, LockId, Cookie, GranuleShardingVersionId, ModificationType, AppDataVerified().FeatureFlags.GetEnableWritePortionsOnInsert()); | ||
|
||
AFL_DEBUG(NKikimrServices::TX_COLUMNSHARD_WRITE)("writing_size", ArrowData->GetSize())("operation_id", writeOperation->GetIdentifier())( | ||
"in_flight", owner->Counters.GetWritesMonitor()->GetWritesInFlight())( | ||
"size_in_flight", owner->Counters.GetWritesMonitor()->GetWritesSizeInFlight()); | ||
|
||
AFL_VERIFY(writeOperation); | ||
writeOperation->SetBehaviour(Behaviour); | ||
NOlap::TWritingContext wContext(owner->TabletID(), owner->SelfId(), Schema, owner->StoragesManager, | ||
owner->Counters.GetIndexationCounters().SplitterCounters, owner->Counters.GetCSCounters().WritingCounters, NOlap::TSnapshot::Max(), | ||
writeOperation->GetActivityChecker()); | ||
ArrowData->SetSeparationPoints(owner->GetIndexAs<NOlap::TColumnEngineForLogs>().GetGranulePtrVerified(PathId)->GetBucketPositions()); | ||
writeOperation->Start(*owner, ArrowData, SourceId, wContext); | ||
return true; | ||
} | ||
|
||
bool TWriteTasksQueue::Drain(const bool onWakeup, const TActorContext& ctx) { | ||
if (onWakeup) { | ||
WriteTasksOverloadCheckerScheduled = false; | ||
} | ||
while (WriteTasks.size() && WriteTasks.front().Execute(Owner, ctx)) { | ||
WriteTasks.pop_front(); | ||
} | ||
if (WriteTasks.size() && !WriteTasksOverloadCheckerScheduled) { | ||
Owner->Schedule(TDuration::MilliSeconds(300), new NActors::TEvents::TEvWakeup(1)); | ||
WriteTasksOverloadCheckerScheduled = true; | ||
AFL_WARN(NKikimrServices::TX_COLUMNSHARD)("event", "queue_on_write")("size", WriteTasks.size()); | ||
} | ||
Owner->Counters.GetCSCounters().WritingCounters->QueueWaitSize->Add((i64)WriteTasks.size() - PredWriteTasksSize); | ||
PredWriteTasksSize = (i64)WriteTasks.size(); | ||
return !WriteTasks.size(); | ||
} | ||
|
||
void TWriteTasksQueue::Enqueue(TWriteTask&& task) { | ||
WriteTasks.emplace_back(std::move(task)); | ||
} | ||
|
||
TWriteTasksQueue::~TWriteTasksQueue() { | ||
Owner->Counters.GetCSCounters().WritingCounters->QueueWaitSize->Sub(PredWriteTasksSize); | ||
} | ||
|
||
} // namespace NKikimr::NColumnShard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#pragma once | ||
#include <ydb/core/tx/columnshard/engines/scheme/versions/abstract_scheme.h> | ||
#include <ydb/core/tx/columnshard/operations/write.h> | ||
#include <ydb/core/tx/data_events/common/modification_type.h> | ||
|
||
namespace NKikimr::NColumnShard { | ||
class TColumnShard; | ||
class TArrowData; | ||
class TWriteTask: TMoveOnly { | ||
private: | ||
std::shared_ptr<TArrowData> ArrowData; | ||
NOlap::ISnapshotSchema::TPtr Schema; | ||
const NActors::TActorId SourceId; | ||
const std::optional<ui32> GranuleShardingVersionId; | ||
const ui64 PathId; | ||
const ui64 Cookie; | ||
const ui64 LockId; | ||
const NEvWrite::EModificationType ModificationType; | ||
const EOperationBehaviour Behaviour; | ||
const TMonotonic Created = TMonotonic::Now(); | ||
|
||
public: | ||
TWriteTask(const std::shared_ptr<TArrowData>& arrowData, const NOlap::ISnapshotSchema::TPtr& schema, const NActors::TActorId sourceId, | ||
const std::optional<ui32>& granuleShardingVersionId, const ui64 pathId, const ui64 cookie, const ui64 lockId, | ||
const NEvWrite::EModificationType modificationType, const EOperationBehaviour behaviour) | ||
: ArrowData(arrowData) | ||
, Schema(schema) | ||
, SourceId(sourceId) | ||
, GranuleShardingVersionId(granuleShardingVersionId) | ||
, PathId(pathId) | ||
, Cookie(cookie) | ||
, LockId(lockId) | ||
, ModificationType(modificationType) | ||
, Behaviour(behaviour) { | ||
} | ||
|
||
const TMonotonic& GetCreatedMonotonic() const { | ||
return Created; | ||
} | ||
|
||
bool Execute(TColumnShard* owner, const TActorContext& ctx); | ||
}; | ||
|
||
class TWriteTasksQueue { | ||
private: | ||
bool WriteTasksOverloadCheckerScheduled = false; | ||
std::deque<TWriteTask> WriteTasks; | ||
i64 PredWriteTasksSize = 0; | ||
TColumnShard* Owner; | ||
|
||
public: | ||
TWriteTasksQueue(TColumnShard* owner) | ||
: Owner(owner) { | ||
} | ||
|
||
~TWriteTasksQueue(); | ||
|
||
void Enqueue(TWriteTask&& task); | ||
bool Drain(const bool onWakeup, const TActorContext& ctx); | ||
}; | ||
|
||
} // namespace NKikimr::NColumnShard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
LIBRARY() | ||
|
||
SRCS( | ||
write_queue.cpp | ||
) | ||
|
||
PEERDIR( | ||
ydb/core/tx/columnshard/hooks/abstract | ||
) | ||
|
||
END() |
Oops, something went wrong.