Skip to content

Commit

Permalink
[Filestore] Implement a tool which replays filestore-vhost's profilel…
Browse files Browse the repository at this point in the history
…og - part0: prepare (ydb-platform#2095)

* [Filestore] Implement a tool which replays filestore-vhost's profile log - part0: prepare
  • Loading branch information
proller committed Sep 27, 2024
1 parent a8fbc7d commit 3232f63
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 11 deletions.
1 change: 1 addition & 0 deletions cloud/filestore/libs/diagnostics/events/profile_events.ev
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ message TProfileLogNodeInfo {
optional string NewNodeName = 4;
optional uint32 Flags = 5;
optional uint32 Mode = 6;
optional uint32 Type = 10;

// from response
optional uint64 NodeId = 7;
Expand Down
14 changes: 14 additions & 0 deletions cloud/filestore/libs/diagnostics/profile_log_events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,20 @@ void InitProfileLogRequestInfo(
auto* nodeInfo = profileLogRequest.MutableNodeInfo();
nodeInfo->SetNewParentNodeId(request.GetNodeId());
nodeInfo->SetNewNodeName(request.GetName());

if (request.HasFile()) {
nodeInfo->SetType(NProto::E_REGULAR_NODE);
} else if (request.HasDirectory()) {
nodeInfo->SetType(NProto::E_DIRECTORY_NODE);
} else if (request.HasLink()) {
nodeInfo->SetType(NProto::E_LINK_NODE);
} else if (request.HasSocket()) {
nodeInfo->SetType(NProto::E_SOCK_NODE);
} else if (request.HasSymLink()) {
nodeInfo->SetType(NProto::E_SYMLINK_NODE);
} else {
nodeInfo->SetType(NProto::E_INVALID_NODE);
}
}

template <>
Expand Down
11 changes: 7 additions & 4 deletions cloud/filestore/libs/diagnostics/profile_log_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ TString NodeInfoToString(const NProto::TProfileLogNodeInfo& nodeInfo)
<< "," << nodeInfo.GetMode()
<< "," << nodeInfo.GetNodeId()
<< "," << nodeInfo.GetHandle()
<< "," << nodeInfo.GetSize();
<< "," << nodeInfo.GetSize()
<< "," << nodeInfo.GetType();
}

TString LockInfoToString(const NProto::TProfileLogLockInfo& lockInfo)
Expand Down Expand Up @@ -196,7 +197,8 @@ struct TRequestInfoBuilder
ui32 mode,
ui64 nodeId,
ui64 handle,
ui64 size)
ui64 size,
ui32 type)
{
auto nodeInfo = R.MutableNodeInfo();
nodeInfo->SetParentNodeId(parentNodeId);
Expand All @@ -208,6 +210,7 @@ struct TRequestInfoBuilder
nodeInfo->SetNodeId(nodeId);
nodeInfo->SetHandle(handle);
nodeInfo->SetSize(size);
nodeInfo->SetType(type);
return *this;
}

Expand Down Expand Up @@ -308,7 +311,7 @@ Y_UNIT_TEST_SUITE(TProfileLogTest)
.SetDuration(TDuration::MilliSeconds(800))
.SetRequestType(11)
.SetError(1)
.AddNodeInfo(1, "node", 2, "new_node", 3, 7, 12, 123, 32)
.AddNodeInfo(1, "node", 2, "new_node", 3, 7, 12, 123, 32, 2)
.Build()
});

Expand Down Expand Up @@ -340,7 +343,7 @@ Y_UNIT_TEST_SUITE(TProfileLogTest)
EventProcessor.FlatMessages[2]
);
UNIT_ASSERT_VALUES_EQUAL(
"fs2\t4000000\t11\t800000\t1\t1,node,2,new_node,3,7,12,123,32",
"fs2\t4000000\t11\t800000\t1\t1,node,2,new_node,3,7,12,123,32,2",
EventProcessor.FlatMessages[3]
);
UNIT_ASSERT_VALUES_EQUAL(
Expand Down
1 change: 1 addition & 0 deletions cloud/filestore/public/api/protos/node.proto
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ enum ENodeType
E_DIRECTORY_NODE = 2;
E_LINK_NODE = 3;
E_SOCK_NODE = 4;
E_SYMLINK_NODE = 5;
}

////////////////////////////////////////////////////////////////////////////////
Expand Down
10 changes: 10 additions & 0 deletions cloud/filestore/tools/analytics/libs/event-log/request_printer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ TString PrintNodeInfo(
TStringBuf nodeIdLabel,
TStringBuf handleLabel,
TStringBuf sizeLabel,
TStringBuf typeLabel,
const NProto::TProfileLogNodeInfo& nodeInfo)
{
TStringBuilder out;
Expand Down Expand Up @@ -144,6 +145,9 @@ TString PrintNodeInfo(
if (nodeInfo.HasSize()) {
out << PrintValue(sizeLabel, nodeInfo.GetSize()) << ", ";
}
if (nodeInfo.HasType()) {
out << PrintValue(typeLabel, nodeInfo.GetType()) << ", ";
}

if (out.empty()) {
out << "no_node_info";
Expand Down Expand Up @@ -302,6 +306,7 @@ class TDefaultRequestPrinter
"node_id",
"handle",
"size",
"type",
request.GetNodeInfo()) << "\t";
}

Expand Down Expand Up @@ -365,6 +370,7 @@ class TAccessNodeRequestPrinter
"node_id",
"",
"",
"",
request.GetNodeInfo());
}

Expand All @@ -391,6 +397,7 @@ class TGetSetNodeXAttrRequestPrinter
"node_id",
"",
"version",
"",
request.GetNodeInfo());
}

Expand All @@ -417,6 +424,7 @@ class TRemoveNodeXAttrRequestPrinter
"",
"",
"",
"",
request.GetNodeInfo());
}

Expand All @@ -443,6 +451,7 @@ class TCreateDestroyCheckpointRequestPrinter
"node_id",
"",
"",
"",
request.GetNodeInfo());
}

Expand All @@ -469,6 +478,7 @@ class TFlushFsyncRequestPrinter
"node_id",
"handle",
"",
"",
request.GetNodeInfo());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,19 @@ Y_UNIT_TEST_SUITE(TRequestPrinterTest)
nodeInfo->SetNodeId(30);
nodeInfo->SetHandle(40);
nodeInfo->SetSize(50);
nodeInfo->SetType(2);

UNIT_ASSERT_VALUES_EQUAL(
"{parent_node_id=10, node_name=name_1, new_parent_node_id=20, "
"new_node_name=name_2, flags=5, mode=7, node_id=30, handle=40, size=50}",
"new_node_name=name_2, flags=5, mode=7, node_id=30, handle=40, size=50, type=2}",
printer->DumpInfo(Request));

nodeInfo->ClearNewParentNodeId();
nodeInfo->ClearNewNodeName();

UNIT_ASSERT_VALUES_EQUAL(
"{parent_node_id=10, node_name=name_1, flags=5, mode=7, node_id=30, "
"handle=40, size=50}",
"handle=40, size=50, type=2}",
printer->DumpInfo(Request));

auto* lockInfo = Request.MutableLockInfo();
Expand All @@ -82,7 +83,7 @@ Y_UNIT_TEST_SUITE(TRequestPrinterTest)

UNIT_ASSERT_VALUES_EQUAL(
"{parent_node_id=10, node_name=name_1, flags=5, mode=7, node_id=30, "
"handle=40, size=50}\t{node_id=100, handle=110, owner=120, offset=130, "
"handle=40, size=50, type=2}\t{node_id=100, handle=110, owner=120, offset=130, "
"length=140, type=E_SHARED, conflicted_owner=220, conflicted_offset=230, "
"conflicted_length=240}",
printer->DumpInfo(Request));
Expand All @@ -95,7 +96,7 @@ Y_UNIT_TEST_SUITE(TRequestPrinterTest)

UNIT_ASSERT_VALUES_EQUAL(
"{parent_node_id=10, node_name=name_1, flags=5, mode=7, node_id=30, "
"handle=40, size=50}\t{node_id=100, handle=110, offset=130, length=140, "
"handle=40, size=50, type=2}\t{node_id=100, handle=110, offset=130, length=140, "
"type=E_EXCLUSIVE}",
printer->DumpInfo(Request));

Expand All @@ -110,7 +111,7 @@ Y_UNIT_TEST_SUITE(TRequestPrinterTest)

UNIT_ASSERT_VALUES_EQUAL(
"{parent_node_id=10, node_name=name_1, flags=5, mode=7, node_id=30, "
"handle=40, size=50}\t{node_id=100, handle=110, offset=130, length=140, "
"handle=40, size=50, type=2}\t{node_id=100, handle=110, offset=130, length=140, "
"type=Unknown}\t[{node_id=300, handle=305, offset=310, bytes=315}, "
"{node_id=301, handle=306, offset=311, bytes=316}]",
printer->DumpInfo(Request));
Expand All @@ -119,15 +120,15 @@ Y_UNIT_TEST_SUITE(TRequestPrinterTest)

UNIT_ASSERT_VALUES_EQUAL(
"{parent_node_id=10, node_name=name_1, flags=5, mode=7, node_id=30, "
"handle=40, size=50}\t{node_id=100, handle=110, offset=130, length=140, "
"handle=40, size=50, type=2}\t{node_id=100, handle=110, offset=130, length=140, "
"type=Unknown}\t[{node_id=300, handle=305, offset=310, bytes=315}]",
printer->DumpInfo(Request));

Request.ClearLockInfo();

UNIT_ASSERT_VALUES_EQUAL(
"{parent_node_id=10, node_name=name_1, flags=5, mode=7, node_id=30, "
"handle=40, size=50}\t[{node_id=300, handle=305, offset=310, bytes=315}]",
"handle=40, size=50, type=2}\t[{node_id=300, handle=305, offset=310, bytes=315}]",
printer->DumpInfo(Request));

Request.ClearNodeInfo();
Expand Down

0 comments on commit 3232f63

Please sign in to comment.