Skip to content

Commit

Permalink
[Filestore] Add actual read bytes to profile log (#2712)
Browse files Browse the repository at this point in the history
  • Loading branch information
proller authored Dec 17, 2024
1 parent b384e3e commit 4b53fd0
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 1 deletion.
5 changes: 5 additions & 0 deletions cloud/filestore/libs/diagnostics/events/profile_events.ev
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ message TProfileLogBlockRange {
optional uint64 NodeId = 1;
optional uint64 Handle = 2;
optional uint64 Offset = 3;

// Request bytes
optional uint64 Bytes = 4;

// Response bytes
optional uint64 ActualBytes = 5;
};

message TProfileLogNodeInfo {
Expand Down
13 changes: 12 additions & 1 deletion cloud/filestore/libs/diagnostics/profile_log_events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,6 @@ void InitProfileLogRequestInfo(
IMPLEMENT_DEFAULT_METHOD(DestroyHandle, NProto)
IMPLEMENT_DEFAULT_METHOD(AcquireLock, NProto)
IMPLEMENT_DEFAULT_METHOD(ReleaseLock, NProto)
IMPLEMENT_DEFAULT_METHOD(ReadData, NProto)
IMPLEMENT_DEFAULT_METHOD(WriteData, NProto)
IMPLEMENT_DEFAULT_METHOD(AllocateData, NProto)
IMPLEMENT_DEFAULT_METHOD(StartEndpoint, NProto)
Expand Down Expand Up @@ -614,4 +613,16 @@ void FinalizeProfileLogRequestInfo(
nodeInfo->SetSize(response.GetNames().size());
}

template <>
void FinalizeProfileLogRequestInfo(
NProto::TProfileLogRequestInfo& profileLogRequest,
const NProto::TReadDataResponse& response)
{
if (profileLogRequest.RangesSize() == 0) {
profileLogRequest.AddRanges();
}
auto* rangeInfo = profileLogRequest.MutableRanges(0);
rangeInfo->SetActualBytes(response.GetBuffer().size());
}

} // namespace NCloud::NFileStore
14 changes: 14 additions & 0 deletions cloud/filestore/libs/diagnostics/profile_log_events_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,20 @@ Y_UNIT_TEST_SUITE(TProfileLogEventsTest)
UNIT_ASSERT_VALUES_EQUAL(names.size(), nodeInfo.GetSize());
}

Y_UNIT_TEST(ShouldReadDataResponseInitializeFieldsCorrectly)
{
NProto::TReadDataResponse res;
constexpr auto Size = 42;
TString data{Size, ' '};
res.SetBuffer(data);

NProto::TProfileLogRequestInfo profileLogRequest;
FinalizeProfileLogRequestInfo(profileLogRequest, res);
UNIT_ASSERT_VALUES_EQUAL(
Size,
profileLogRequest.GetRanges(0).GetActualBytes());
}

Y_UNIT_TEST(ShouldGetCorrectFuseRequestName)
{
UNIT_ASSERT_VALUES_EQUAL(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ TString PrintRanges(
TStringBuf handleLabel,
TStringBuf offsetLabel,
TStringBuf bytesLabel,
TStringBuf actualBytesLabel,
const google::protobuf::RepeatedPtrField<NProto::TProfileLogBlockRange>& ranges)
{
TStringBuilder out;
Expand All @@ -188,6 +189,9 @@ TString PrintRanges(
if (range.HasBytes()) {
currentRange << PrintValue(bytesLabel, range.GetBytes()) << ", ";
}
if (range.HasActualBytes()) {
currentRange << PrintValue(actualBytesLabel, range.GetActualBytes()) << ", ";
}

if (currentRange.empty()) {
currentRange << "no_range_info";
Expand Down Expand Up @@ -227,6 +231,7 @@ TString PrintBlobsInfo(
"handle",
"offset",
"bytes",
"actual_bytes",
blob.GetRanges())
<< '\t';
}
Expand Down Expand Up @@ -337,6 +342,7 @@ class TDefaultRequestPrinter
"handle",
"offset",
"bytes",
"actual_bytes",
request.GetRanges()) << "\t";
}

Expand Down Expand Up @@ -507,6 +513,7 @@ class TCollectGarbageRequestPrinter
"last_collect_commit_id",
"new_blobs",
"garbage_blobs",
"",
request.GetRanges());
}

Expand All @@ -528,6 +535,7 @@ class TDeleteGarbageRequestPrinter
"",
"new_blobs",
"garbage_blobs",
"",
request.GetRanges());
}

Expand All @@ -549,6 +557,7 @@ class TReadWriteBlobRequestPrinter
"",
"offset",
"bytes",
"actual_bytes",
request.GetRanges());
}

Expand Down

0 comments on commit 4b53fd0

Please sign in to comment.