From 4b53fd088e4c717d9e30a1f62b5b0549d034a381 Mon Sep 17 00:00:00 2001 From: proller Date: Tue, 17 Dec 2024 18:01:21 +0100 Subject: [PATCH] [Filestore] Add actual read bytes to profile log (#2712) --- .../libs/diagnostics/events/profile_events.ev | 5 +++++ .../libs/diagnostics/profile_log_events.cpp | 13 ++++++++++++- .../libs/diagnostics/profile_log_events_ut.cpp | 14 ++++++++++++++ .../analytics/libs/event-log/request_printer.cpp | 9 +++++++++ 4 files changed, 40 insertions(+), 1 deletion(-) diff --git a/cloud/filestore/libs/diagnostics/events/profile_events.ev b/cloud/filestore/libs/diagnostics/events/profile_events.ev index d0f21628994..358de8466ee 100644 --- a/cloud/filestore/libs/diagnostics/events/profile_events.ev +++ b/cloud/filestore/libs/diagnostics/events/profile_events.ev @@ -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 { diff --git a/cloud/filestore/libs/diagnostics/profile_log_events.cpp b/cloud/filestore/libs/diagnostics/profile_log_events.cpp index 14d68f8fe25..0de6a0fc103 100644 --- a/cloud/filestore/libs/diagnostics/profile_log_events.cpp +++ b/cloud/filestore/libs/diagnostics/profile_log_events.cpp @@ -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) @@ -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 diff --git a/cloud/filestore/libs/diagnostics/profile_log_events_ut.cpp b/cloud/filestore/libs/diagnostics/profile_log_events_ut.cpp index 8004112187d..cc5a8925ca0 100644 --- a/cloud/filestore/libs/diagnostics/profile_log_events_ut.cpp +++ b/cloud/filestore/libs/diagnostics/profile_log_events_ut.cpp @@ -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( diff --git a/cloud/filestore/tools/analytics/libs/event-log/request_printer.cpp b/cloud/filestore/tools/analytics/libs/event-log/request_printer.cpp index 38fa442c055..e57fe88077c 100644 --- a/cloud/filestore/tools/analytics/libs/event-log/request_printer.cpp +++ b/cloud/filestore/tools/analytics/libs/event-log/request_printer.cpp @@ -166,6 +166,7 @@ TString PrintRanges( TStringBuf handleLabel, TStringBuf offsetLabel, TStringBuf bytesLabel, + TStringBuf actualBytesLabel, const google::protobuf::RepeatedPtrField& ranges) { TStringBuilder out; @@ -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"; @@ -227,6 +231,7 @@ TString PrintBlobsInfo( "handle", "offset", "bytes", + "actual_bytes", blob.GetRanges()) << '\t'; } @@ -337,6 +342,7 @@ class TDefaultRequestPrinter "handle", "offset", "bytes", + "actual_bytes", request.GetRanges()) << "\t"; } @@ -507,6 +513,7 @@ class TCollectGarbageRequestPrinter "last_collect_commit_id", "new_blobs", "garbage_blobs", + "", request.GetRanges()); } @@ -528,6 +535,7 @@ class TDeleteGarbageRequestPrinter "", "new_blobs", "garbage_blobs", + "", request.GetRanges()); } @@ -549,6 +557,7 @@ class TReadWriteBlobRequestPrinter "", "offset", "bytes", + "actual_bytes", request.GetRanges()); }