Skip to content

Commit 05ecf8a

Browse files
authored
add plan.svg to benchmark report (#8464)
1 parent 4aa213a commit 05ecf8a

File tree

8 files changed

+19
-5
lines changed

8 files changed

+19
-5
lines changed

ydb/core/fq/libs/compute/common/utils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "utils.h"
2-
#include "plan2svg.h"
2+
#include <ydb/public/lib/ydb_cli/common/plan2svg.h>
33

44
#include <library/cpp/json/json_reader.h>
55
#include <library/cpp/json/json_writer.h>

ydb/core/fq/libs/compute/common/ya.make

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ LIBRARY()
22

33
SRCS(
44
pinger.cpp
5-
plan2svg.cpp
65
run_actor_params.cpp
76
utils.cpp
87
)
@@ -20,6 +19,7 @@ PEERDIR(
2019
ydb/library/yql/providers/generic/connector/api/service/protos
2120
ydb/library/yql/providers/generic/connector/libcpp
2221
ydb/library/yql/providers/s3/actors_factory
22+
ydb/public/lib/ydb_cli/common
2323
)
2424

2525
YQL_LAST_ABI_VERSION()

ydb/public/lib/ydb_cli/commands/ydb_benchmark.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#include "ydb_benchmark.h"
22
#include "benchmark_utils.h"
3-
#include <ydb/public/lib/ydb_cli/common/pretty_table.h>
43
#include <ydb/public/lib/ydb_cli/common/format.h>
4+
#include <ydb/public/lib/ydb_cli/common/plan2svg.h>
5+
#include <ydb/public/lib/ydb_cli/common/pretty_table.h>
56
#include <library/cpp/json/json_writer.h>
67
#include <util/string/printf.h>
78
#include <util/folder/path.h>
@@ -93,7 +94,7 @@ TString TWorkloadCommandBenchmark::PatchQuery(const TStringBuf& original) const
9394

9495
std::vector<TStringBuf> lines;
9596
for (auto& line : StringSplitter(result).Split('\n').SkipEmpty()) {
96-
if (line.StartsWith("--")) {
97+
if (line.StartsWith("--") && !line.StartsWith("--!")) {
9798
continue;
9899
}
99100

@@ -386,6 +387,12 @@ bool TWorkloadCommandBenchmark::RunBench(TClient& client, NYdbWorkload::IWorkloa
386387
TFileOutput out(PlanFileName + ".ast");
387388
out << res.GetPlanAst();
388389
}
390+
{
391+
TPlanVisualizer pv;
392+
pv.LoadPlans(res.GetQueryPlan());
393+
TFileOutput out(PlanFileName + ".svg");
394+
out << pv.PrintSvgSafe();
395+
}
389396
planSaved = true;
390397
}
391398
}

ydb/public/lib/ydb_cli/common/ya.make

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ SRCS(
1313
parameter_stream.cpp
1414
parameters.cpp
1515
pg_dump_parser.cpp
16+
plan2svg.cpp
1617
pretty_table.cpp
1718
print_operation.cpp
1819
print_utils.cpp

ydb/tests/olap/lib/ydb_cli.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@ def get_cli_command() -> list[str]:
2626
return [cli]
2727

2828
class QueuePlan:
29-
def __init__(self, plan: dict | None = None, table: str | None = None, ast: str | None = None) -> None:
29+
def __init__(self, plan: dict | None = None, table: str | None = None, ast: str | None = None, svg: str | None = None) -> None:
3030
self.plan = plan
3131
self.table = table
3232
self.ast = ast
33+
self.svg = svg
3334

3435
class WorkloadRunResult:
3536
def __init__(
@@ -115,6 +116,9 @@ def _try_extract_error_message(stderr: str) -> str:
115116
if (os.path.exists(plan_path + '.ast')):
116117
with open(plan_path + '.ast') as f:
117118
plan.ast = f.read()
119+
if (os.path.exists(plan_path + '.svg')):
120+
with open(plan_path + '.svg') as f:
121+
plan.svg = f.read()
118122

119123
return YdbCliHelper.WorkloadRunResult(
120124
stats=stats,

ydb/tests/olap/load/conftest.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ def _get_duraton(stats, field):
4646
allure.attach(result.plan.table, 'Plan table', attachment_type=allure.attachment_type.TEXT)
4747
if result.plan.ast is not None:
4848
allure.attach(result.plan.ast, 'Plan ast', attachment_type=allure.attachment_type.TEXT)
49+
if result.plan.svg is not None:
50+
allure.attach(result.plan.svg, 'Plan svg', attachment_type=allure.attachment_type.SVG)
4951

5052
if result.stdout is not None:
5153
allure.attach(result.stdout, 'Stdout', attachment_type=allure.attachment_type.TEXT)

0 commit comments

Comments
 (0)