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

Merge to stable 23 3 #257

Merged
merged 2 commits into from
Jan 26, 2024
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
2 changes: 2 additions & 0 deletions cloud/blockstore/libs/storage/api/volume.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ struct TEvVolume
struct TDiskRegistryBasedPartitionCounters
{
TPartitionDiskCountersPtr DiskCounters;
ui64 NetworkBytes = 0;
TDuration CpuUsage;

TDiskRegistryBasedPartitionCounters(
TPartitionDiskCountersPtr diskCounters)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ void TCopyRangeActor::Done(const TActorContext& ctx)
ReadDuration,
WriteStartTs,
WriteDuration,
std::move(AffectedBlockInfos)
std::move(AffectedBlockInfos),
RequestInfo->GetExecCycles()
);

LWTRACK(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,9 @@ void TMirrorRequestActor<TMethod>::Done(const NActors::TActorContext& ctx)
using TCompletion =
TEvNonreplPartitionPrivate::TEvWriteOrZeroCompleted;
auto completion =
std::make_unique<TCompletion>(NonreplicatedRequestCounter);
std::make_unique<TCompletion>(
NonreplicatedRequestCounter,
RequestInfo->GetTotalCycles());

NCloud::Send(ctx, ParentActorId, std::move(completion));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ class TMirrorPartitionActor final

TDeque<TPartitionDiskCountersPtr> ReplicaCounters;
bool UpdateCountersScheduled = false;
ui64 NetworkBytes = 0;
TDuration CpuUsage;

TRequestsInProgress<ui64> RequestsInProgress{EAllowedRequests::ReadWrite};
TDrainActorCompanion DrainActorCompanion{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ void TMirrorPartitionActor::HandlePartCounters(

if (i < ReplicaCounters.size()) {
ReplicaCounters[i] = std::move(msg->DiskCounters);
NetworkBytes += msg->NetworkBytes;
CpuUsage += CpuUsage;
} else {
LOG_INFO(ctx, TBlockStoreComponents::PARTITION,
"Partition %s for disk %s counters not found",
Expand Down Expand Up @@ -64,6 +66,11 @@ void TMirrorPartitionActor::SendStats(const TActorContext& ctx)
MakeIntrusive<TCallContext>(),
std::move(stats));

request->NetworkBytes = NetworkBytes;
request->CpuUsage = CpuUsage;
NetworkBytes = 0;
CpuUsage = {};

NCloud::Send(
ctx,
StatActorId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ class TMirrorPartitionResyncActor final

TPartitionDiskCountersPtr MirrorCounters;
bool UpdateCountersScheduled = false;
ui64 NetworkBytes = 0;
TDuration CpuUsage;

bool ResyncFinished = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ void TMirrorPartitionResyncActor::HandlePartCounters(

if (ev->Sender == MirrorActorId) {
MirrorCounters = std::move(msg->DiskCounters);
NetworkBytes = msg->NetworkBytes;
CpuUsage = msg->CpuUsage;
} else {
LOG_INFO(ctx, TBlockStoreComponents::PARTITION,
"Partition %s for disk %s counters not found",
Expand All @@ -41,6 +43,9 @@ void TMirrorPartitionResyncActor::SendStats(const TActorContext& ctx)
MakeIntrusive<TCallContext>(),
std::move(stats));

request->NetworkBytes = NetworkBytes;
request->CpuUsage = CpuUsage;

NCloud::Send(ctx, StatActorId, std::move(request));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ class TNonreplicatedPartitionActor final

bool UpdateCountersScheduled = false;
TPartitionDiskCountersPtr PartCounters;
ui64 NetworkBytes = 0;
TDuration CpuUsage;

TRequestInfoPtr Poisoner;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ void TDiskAgentChecksumActor::Done(
counters.SetBlocksCount(blocks);
completion->Failed = failed;

completion->ExecCycles = RequestInfo->GetExecCycles();

NCloud::Send(
ctx,
Part,
Expand Down Expand Up @@ -334,6 +336,8 @@ void TNonreplicatedPartitionActor::HandleChecksumBlocksCompleted(
* PartConfig->GetBlockSize();
const auto time = CyclesToDurationSafe(msg->TotalCycles).MicroSeconds();
PartCounters->RequestCounters.ChecksumBlocks.AddRequest(time, requestBytes);
NetworkBytes += requestBytes;
CpuUsage += CyclesToDurationSafe(msg->ExecCycles);

RequestsInProgress.RemoveRequest(ev->Sender);
if (!msg->Failed) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ void TDiskAgentReadActor::Done(
}
counters.SetBlocksCount(blocks);
completion->Failed = failed;
completion->ExecCycles = RequestInfo->GetExecCycles();

NCloud::Send(
ctx,
Expand Down Expand Up @@ -337,6 +338,8 @@ void TNonreplicatedPartitionActor::HandleReadBlocksCompleted(
* PartConfig->GetBlockSize();
const auto time = CyclesToDurationSafe(msg->TotalCycles).MicroSeconds();
PartCounters->RequestCounters.ReadBlocks.AddRequest(time, requestBytes);
NetworkBytes += requestBytes;
CpuUsage += CyclesToDurationSafe(msg->ExecCycles);

RequestsInProgress.RemoveRequest(ev->Sender);
if (!msg->Failed) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ void TDiskAgentReadActor::Done(
counters.SetBlocksCount(blocks);
completion->Failed = failed;

completion->ExecCycles = RequestInfo->GetExecCycles();

NCloud::Send(
ctx,
Part,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ void TNonreplicatedPartitionActor::SendStats(const TActorContext& ctx)
MakeIntrusive<TCallContext>(),
std::move(PartCounters));

request->NetworkBytes = NetworkBytes;
request->CpuUsage = CpuUsage;
NetworkBytes = 0;
CpuUsage = {};

PartCounters =
CreatePartitionDiskCounters(EPublishingPolicy::DiskRegistryBased);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ void TDiskAgentWriteActor::Done(
}
counters.SetBlocksCount(blocks);
completion->Failed = failed;
completion->ExecCycles = RequestInfo->GetExecCycles();

NCloud::Send(
ctx,
Expand Down Expand Up @@ -469,6 +470,8 @@ void TNonreplicatedPartitionActor::HandleWriteBlocksCompleted(
* PartConfig->GetBlockSize();
const auto time = CyclesToDurationSafe(msg->TotalCycles).MicroSeconds();
PartCounters->RequestCounters.WriteBlocks.AddRequest(time, requestBytes);
NetworkBytes += requestBytes;
CpuUsage += CyclesToDurationSafe(msg->ExecCycles);

RequestsInProgress.RemoveRequest(ev->Sender);
if (!msg->Failed) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ void TDiskAgentZeroActor::Done(
}
counters.SetBlocksCount(blocks);
completion->Failed = failed;
completion->ExecCycles = RequestInfo->GetExecCycles();

NCloud::Send(
ctx,
Expand Down Expand Up @@ -330,6 +331,8 @@ void TNonreplicatedPartitionActor::HandleZeroBlocksCompleted(
* PartConfig->GetBlockSize();
const auto time = CyclesToDurationSafe(msg->TotalCycles).MicroSeconds();
PartCounters->RequestCounters.ZeroBlocks.AddRequest(time, requestBytes);
NetworkBytes += requestBytes;
CpuUsage += CyclesToDurationSafe(msg->ExecCycles);

RequestsInProgress.RemoveRequest(ev->Sender);
if (!msg->Failed) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,23 @@ struct TEvNonreplPartitionPrivate
TInstant WriteStartTs;
TDuration WriteDuration;
TVector<IProfileLog::TBlockInfo> AffectedBlockInfos;
ui64 ExecCycles;

TRangeMigrated(
TBlockRange64 range,
TInstant readStartTs,
TDuration readDuration,
TInstant writeStartTs,
TDuration writeDuration,
TVector<IProfileLog::TBlockInfo> affectedBlockInfos)
TVector<IProfileLog::TBlockInfo> affectedBlockInfos,
ui64 execCycles)
: Range(std::move(range))
, ReadStartTs(readStartTs)
, ReadDuration(readDuration)
, WriteStartTs(writeStartTs)
, WriteDuration(writeDuration)
, AffectedBlockInfos(std::move(affectedBlockInfos))
, ExecCycles(execCycles)
{
}
};
Expand All @@ -76,9 +79,13 @@ struct TEvNonreplPartitionPrivate
struct TWriteOrZeroCompleted
{
ui64 RequestCounter;
ui64 TotalCycles;

TWriteOrZeroCompleted(ui64 requestCounter)
TWriteOrZeroCompleted(
ui64 requestCounter,
ui64 totalCycles)
: RequestCounter(requestCounter)
, TotalCycles(totalCycles)
{
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ class TNonreplicatedPartitionMigrationActor final
NActors::TActorId DstActorId;
TPartitionDiskCountersPtr SrcCounters;
TPartitionDiskCountersPtr DstCounters;
ui64 NetworkBytes = 0;
TDuration CpuUsage;

bool UpdateCountersScheduled = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ void TNonreplicatedPartitionMigrationActor::HandleRangeMigrated(

auto* msg = ev->Get();

NetworkBytes += 2 * msg->Range.Size() * SrcConfig->GetBlockSize();
CpuUsage += CyclesToDurationSafe(msg->ExecCycles);

ProfileLog->Write({
.DiskId = SrcConfig->GetName(),
.Ts = msg->ReadStartTs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ void TNonreplicatedPartitionMigrationActor::HandlePartCounters(

Y_DEBUG_ABORT_UNLESS(0);
}
NetworkBytes += msg->NetworkBytes;
CpuUsage += msg->CpuUsage;
}

////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -58,6 +60,11 @@ void TNonreplicatedPartitionMigrationActor::SendStats(const TActorContext& ctx)
MakeIntrusive<TCallContext>(),
std::move(stats));

request->NetworkBytes = NetworkBytes;
request->CpuUsage = CpuUsage;
NetworkBytes = 0;
CpuUsage = {};

NCloud::Send(ctx, StatActorId, std::move(request));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,8 @@ void TNonreplicatedPartitionRdmaActor::HandleReadBlocksCompleted(
* PartConfig->GetBlockSize();
const auto time = CyclesToDurationSafe(msg->TotalCycles).MicroSeconds();
PartCounters->RequestCounters.ReadBlocks.AddRequest(time, requestBytes);
NetworkBytes += requestBytes;
CpuUsage += CyclesToDurationSafe(msg->ExecCycles);

const auto requestId = ev->Cookie;
RequestsInProgress.RemoveRequest(requestId);
Expand All @@ -334,6 +336,8 @@ void TNonreplicatedPartitionRdmaActor::HandleWriteBlocksCompleted(
* PartConfig->GetBlockSize();
const auto time = CyclesToDurationSafe(msg->TotalCycles).MicroSeconds();
PartCounters->RequestCounters.WriteBlocks.AddRequest(time, requestBytes);
NetworkBytes += requestBytes;
CpuUsage += CyclesToDurationSafe(msg->ExecCycles);

const auto requestId = ev->Cookie;
RequestsInProgress.RemoveRequest(requestId);
Expand All @@ -359,6 +363,8 @@ void TNonreplicatedPartitionRdmaActor::HandleZeroBlocksCompleted(
* PartConfig->GetBlockSize();
const auto time = CyclesToDurationSafe(msg->TotalCycles).MicroSeconds();
PartCounters->RequestCounters.ZeroBlocks.AddRequest(time, requestBytes);
NetworkBytes += requestBytes;
CpuUsage += CyclesToDurationSafe(msg->ExecCycles);

const auto requestId = ev->Cookie;
RequestsInProgress.RemoveRequest(requestId);
Expand All @@ -385,6 +391,8 @@ void TNonreplicatedPartitionRdmaActor::HandleChecksumBlocksCompleted(
const auto time = CyclesToDurationSafe(msg->TotalCycles).MicroSeconds();
PartCounters->RequestCounters.ChecksumBlocks.AddRequest(time, requestBytes);

CpuUsage += CyclesToDurationSafe(msg->ExecCycles);

const auto requestId = ev->Cookie;
RequestsInProgress.RemoveRequest(requestId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ class TNonreplicatedPartitionRdmaActor final

bool UpdateCountersScheduled = false;
TPartitionDiskCountersPtr PartCounters;
ui64 NetworkBytes = 0;
TDuration CpuUsage;

using TEndpointFuture = NThreading::TFuture<NRdma::IClientEndpointPtr>;
THashMap<TString, TEndpointFuture> AgentId2EndpointFuture;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ class TRdmaRequestContext: public NRdma::IClientHandler
ui32 status,
size_t responseBytes) override
{
TRequestScope timer(*RequestInfo);

auto guard = Guard(Lock);

auto* dc =
Expand Down Expand Up @@ -143,6 +145,9 @@ class TRdmaRequestContext: public NRdma::IClientHandler
auto& counters = *completion->Stats.MutableSysChecksumCounters();
completion->TotalCycles = RequestInfo->GetTotalCycles();

timer.Finish();
completion->ExecCycles = RequestInfo->GetExecCycles();

counters.SetBlocksCount(RequestBlockCount);
auto completionEvent = std::make_unique<IEventHandle>(
ParentActorId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ class TRdmaRequestContext: public NRdma::IClientHandler
, ParentActorId(parentActorId)
, RequestId(requestId)
{
TRequestScope timer(*RequestInfo);

auto& buffers = *Response.MutableBlocks()->MutableBuffers();
buffers.Reserve(blockCount);
for (ui32 i = 0; i < blockCount; ++i) {
Expand Down Expand Up @@ -105,6 +107,8 @@ class TRdmaRequestContext: public NRdma::IClientHandler
ui32 status,
size_t responseBytes) override
{
TRequestScope timer(*RequestInfo);

auto guard = Guard(Lock);

auto* dr = static_cast<TDeviceReadRequestContext*>(req->Context.get());
Expand Down Expand Up @@ -147,6 +151,9 @@ class TRdmaRequestContext: public NRdma::IClientHandler
auto& counters = *completion->Stats.MutableUserReadCounters();
completion->TotalCycles = RequestInfo->GetTotalCycles();

timer.Finish();
completion->ExecCycles = RequestInfo->GetExecCycles();

counters.SetBlocksCount(blocks);
auto completionEvent = std::make_unique<IEventHandle>(
ParentActorId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ class TRdmaRequestContext: public NRdma::IClientHandler
ui32 status,
size_t responseBytes) override
{
TRequestScope timer(*RequestInfo);

auto guard = Guard(Lock);

auto* dr = static_cast<TDeviceReadRequestContext*>(req->Context.get());
Expand Down Expand Up @@ -139,6 +141,9 @@ class TRdmaRequestContext: public NRdma::IClientHandler
auto& counters = *completion->Stats.MutableUserReadCounters();
completion->TotalCycles = RequestInfo->GetTotalCycles();

timer.Finish();
completion->ExecCycles = RequestInfo->GetExecCycles();

counters.SetBlocksCount(RequestBlockCount);
auto completionEvent = std::make_unique<IEventHandle>(
ParentActorId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ void TNonreplicatedPartitionRdmaActor::SendStats(const TActorContext& ctx)
MakeIntrusive<TCallContext>(),
std::move(PartCounters));

request->NetworkBytes = NetworkBytes;
request->CpuUsage = CpuUsage;
NetworkBytes = 0;
CpuUsage = {};

PartCounters =
CreatePartitionDiskCounters(EPublishingPolicy::DiskRegistryBased);

Expand Down
Loading
Loading