Skip to content
This repository has been archived by the owner on Dec 1, 2022. It is now read-only.

Commit

Permalink
add encode for benchmark resp, update benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
critical27 committed Aug 11, 2020
1 parent 8c7d48f commit 104dfb9
Showing 1 changed file with 128 additions and 31 deletions.
159 changes: 128 additions & 31 deletions src/storage/test/GetNeighborsBenchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ void setUp(const char* path, EdgeRanking maxRank) {
} // namespace storage
} // namespace nebula

std::string encode(const nebula::storage::cpp2::GetNeighborsResponse &resp) {
std::string val;
apache::thrift::CompactSerializer::serialize(resp, &val);
return val;
}

void initContext(std::unique_ptr<nebula::storage::PlanContext>& planCtx,
nebula::storage::EdgeContext& edgeContext,
const std::vector<std::string>& serveProps) {
Expand Down Expand Up @@ -94,7 +100,8 @@ void go(int32_t iters,
auto fut = processor->getFuture();
processor->process(req);
auto resp = std::move(fut).get();
folly::doNotOptimizeAway(resp);
auto encoded = encode(resp);
folly::doNotOptimizeAway(encoded);
}
}

Expand Down Expand Up @@ -124,7 +131,8 @@ void goFilter(int32_t iters,
auto fut = processor->getFuture();
processor->process(req);
auto resp = std::move(fut).get();
folly::doNotOptimizeAway(resp);
auto encoded = encode(resp);
folly::doNotOptimizeAway(encoded);
}
}

Expand All @@ -144,6 +152,7 @@ void goEdgeNode(int32_t iters,
}
auto totalParts = gCluster->getTotalParts();
for (decltype(iters) i = 0; i < iters; i++) {
nebula::storage::cpp2::GetNeighborsResponse resp;
nebula::DataSet resultDataSet;
std::hash<std::string> hash;
for (const auto& vId : vertex) {
Expand Down Expand Up @@ -175,6 +184,11 @@ void goEdgeNode(int32_t iters,
resultDataSet.rows.emplace_back(std::move(row));
}
CHECK_EQ(vertex.size(), resultDataSet.rowSize());
nebula::storage::cpp2::ResponseCommon result;
resp.set_result(std::move(result));
resp.set_vertices(std::move(resultDataSet));
auto encoded = encode(resp);
folly::doNotOptimizeAway(encoded);
}
}

Expand All @@ -188,6 +202,9 @@ void prefix(int32_t iters,
initContext(planCtx, edgeContext, serveProps);
}
for (decltype(iters) i = 0; i < iters; i++) {
nebula::storage::cpp2::GetNeighborsResponse resp;
nebula::DataSet resultDataSet;

nebula::GraphSpaceID spaceId = 1;
nebula::TagID player = 1;
nebula::EdgeType serve = 101;
Expand All @@ -209,9 +226,7 @@ void prefix(int32_t iters,
CHECK(!edgeSchemaIter->second.empty());
auto* edgeSchema = &(edgeSchemaIter->second);

nebula::DataSet resultDataSet;
nebula::RowReaderWrapper reader;

for (const auto& vId : vertex) {
nebula::PartitionID partId = (hash(vId) % totalParts) + 1;
std::vector<nebula::Value> row;
Expand Down Expand Up @@ -262,9 +277,46 @@ void prefix(int32_t iters,
resultDataSet.rows.emplace_back(std::move(row));
}
CHECK_EQ(vertex.size(), resultDataSet.rowSize());
nebula::storage::cpp2::ResponseCommon result;
resp.set_result(std::move(result));
resp.set_vertices(std::move(resultDataSet));
auto encoded = encode(resp);
folly::doNotOptimizeAway(encoded);
}
}

void encodeBench(int32_t iters,
const std::vector<nebula::VertexID>& vertex,
const std::vector<std::string>& playerProps,
const std::vector<std::string>& serveProps) {
nebula::storage::cpp2::GetNeighborsResponse resp;
BENCHMARK_SUSPEND {
auto* env = gCluster->storageEnv_.get();
auto req = nebula::storage::buildRequest(vertex, playerProps, serveProps);
auto* processor = nebula::storage::GetNeighborsProcessor::instance(env, nullptr, nullptr);
auto fut = processor->getFuture();
processor->process(req);
resp = std::move(fut).get();
}
for (decltype(iters) i = 0; i < iters; i++) {
auto encoded = encode(resp);
folly::doNotOptimizeAway(encoded);
}
}

BENCHMARK(EncodeOneProperty, iters) {
encodeBench(iters, {"Tim Duncan"}, {"name"}, {"teamName"});
}
BENCHMARK_RELATIVE(EncodeThreeProperty, iters) {
encodeBench(iters, {"Tim Duncan"}, {"name"}, {"teamName", "startYear", "endYear"});
}
BENCHMARK_RELATIVE(EncodeFiveProperty, iters) {
encodeBench(iters, {"Tim Duncan"}, {"name"},
{"teamName", "startYear", "endYear", "teamCareer", "teamGames"});
}

BENCHMARK_DRAW_LINE();

// Players may serve more than one team, the total edges = teamCount * maxRank, which would effect
// the final result, so select some player only serve one team
BENCHMARK(OneVertexOneProperty, iters) {
Expand All @@ -279,6 +331,13 @@ BENCHMARK_RELATIVE(OneVertexOnePropertyOnlyEdgeNode, iters) {
BENCHMARK_RELATIVE(OneVertexOneProperyOnlyKV, iters) {
prefix(iters, {"Tim Duncan"}, {"name"}, {"teamName"});
}
BENCHMARK_RELATIVE(OneVertexThreeProperty, iters) {
go(iters, {"Tim Duncan"}, {"name"}, {"teamName", "startYear", "endYear"});
}
BENCHMARK_RELATIVE(OneVertexFiveProperty, iters) {
go(iters, {"Tim Duncan"}, {"name"},
{"teamName", "startYear", "endYear", "teamCareer", "teamGames"});
}

BENCHMARK_DRAW_LINE();

Expand Down Expand Up @@ -313,6 +372,20 @@ BENCHMARK_RELATIVE(TenVertexOneProperyOnlyKV, iters) {
{"name"},
{"teamName"});
}
BENCHMARK_RELATIVE(TenVertexThreeProperty, iters) {
go(iters,
{"Tim Duncan", "Kobe Bryant", "Stephen Curry", "Manu Ginobili", "Joel Embiid",
"Giannis Antetokounmpo", "Yao Ming", "Damian Lillard", "Dirk Nowitzki", "Klay Thompson"},
{"name"},
{"teamName", "startYear", "endYear"});
}
BENCHMARK_RELATIVE(TenVertexFiveProperty, iters) {
go(iters,
{"Tim Duncan", "Kobe Bryant", "Stephen Curry", "Manu Ginobili", "Joel Embiid",
"Giannis Antetokounmpo", "Yao Ming", "Damian Lillard", "Dirk Nowitzki", "Klay Thompson"},
{"name"},
{"teamName", "startYear", "endYear", "teamCareer", "teamGames"});
}

int main(int argc, char** argv) {
folly::init(&argc, &argv, true);
Expand All @@ -336,46 +409,70 @@ release
--max_rank=1000 --filter_ratio=0.1
============================================================================
/home/doodle.wang/Git/nebula-storage/src/storage/test/GetNeighborsBenchmark.cpprelative time/iter iters/s
GetNeighborsBenchmark.cpprelative time/iter iters/s
============================================================================
OneVertexOneProperty 533.81us 1.87K
OneVertexOnePropertyWithFilter 111.64% 478.15us 2.09K
OneVertexOnePropertyOnlyEdgeNode 108.02% 494.18us 2.02K
OneVertexOneProperyOnlyKV 109.63% 486.93us 2.05K
EncodeOneProperty 63.72us 15.69K
EncodeThreeProperty 50.10% 127.19us 7.86K
EncodeFiveProperty 40.42% 157.64us 6.34K
----------------------------------------------------------------------------
OneVertexOneProperty 436.78us 2.29K
OneVertexOnePropertyWithFilter 90.38% 483.25us 2.07K
OneVertexOnePropertyOnlyEdgeNode 111.10% 393.13us 2.54K
OneVertexOneProperyOnlyKV 113.21% 385.83us 2.59K
OneVertexThreeProperty 58.29% 749.37us 1.33K
OneVertexFiveProperty 45.05% 969.46us 1.03K
----------------------------------------------------------------------------
TenVertexOneProperty 5.33ms 187.70
TenVertexOnePropertyWithFilter 112.74% 4.73ms 211.62
TenVertexOnePropertyOnlyEdgeNode 105.42% 5.05ms 197.88
TenVertexOneProperyOnlyKV 107.75% 4.94ms 202.25
TenVertexOneProperty 4.35ms 229.72
TenVertexOnePropertyWithFilter 90.35% 4.82ms 207.55
TenVertexOnePropertyOnlyEdgeNode 106.32% 4.09ms 244.23
TenVertexOneProperyOnlyKV 110.86% 3.93ms 254.67
TenVertexThreeProperty 57.97% 7.51ms 133.16
TenVertexFiveProperty 44.68% 9.74ms 102.63
============================================================================
--max_rank=1000 --filter_ratio=0.5
============================================================================
/home/doodle.wang/Git/nebula-storage/src/storage/test/GetNeighborsBenchmark.cpprelative time/iter iters/s
GetNeighborsBenchmark.cpprelative time/iter iters/s
============================================================================
OneVertexOneProperty 529.59us 1.89K
OneVertexOnePropertyWithFilter 81.76% 647.75us 1.54K
OneVertexOnePropertyOnlyEdgeNode 107.54% 492.47us 2.03K
OneVertexOneProperyOnlyKV 108.38% 488.65us 2.05K
EncodeOneProperty 62.54us 15.99K
EncodeThreeProperty 48.73% 128.35us 7.79K
EncodeFiveProperty 39.60% 157.92us 6.33K
----------------------------------------------------------------------------
TenVertexOneProperty 5.30ms 188.54
TenVertexOnePropertyWithFilter 81.95% 6.47ms 154.50
TenVertexOnePropertyOnlyEdgeNode 106.09% 5.00ms 200.02
TenVertexOneProperyOnlyKV 108.26% 4.90ms 204.12
OneVertexOneProperty 431.78us 2.32K
OneVertexOnePropertyWithFilter 72.20% 598.04us 1.67K
OneVertexOnePropertyOnlyEdgeNode 110.10% 392.17us 2.55K
OneVertexOneProperyOnlyKV 112.75% 382.95us 2.61K
OneVertexThreeProperty 57.40% 752.17us 1.33K
OneVertexFiveProperty 44.46% 971.13us 1.03K
----------------------------------------------------------------------------
TenVertexOneProperty 4.37ms 228.94
TenVertexOnePropertyWithFilter 72.92% 5.99ms 166.93
TenVertexOnePropertyOnlyEdgeNode 108.45% 4.03ms 248.29
TenVertexOneProperyOnlyKV 111.35% 3.92ms 254.93
TenVertexThreeProperty 58.32% 7.49ms 133.52
TenVertexFiveProperty 44.85% 9.74ms 102.67
============================================================================
--max_rank=1000 --filter_ratio=1
============================================================================
/home/doodle.wang/Git/nebula-storage/src/storage/test/GetNeighborsBenchmark.cpprelative time/iter iters/s
GetNeighborsBenchmark.cpprelative time/iter iters/s
============================================================================
OneVertexOneProperty 522.41us 1.91K
OneVertexOnePropertyWithFilter 62.76% 832.45us 1.20K
OneVertexOnePropertyOnlyEdgeNode 108.25% 482.58us 2.07K
OneVertexOneProperyOnlyKV 107.87% 484.31us 2.06K
EncodeOneProperty 64.95us 15.40K
EncodeThreeProperty 49.47% 131.28us 7.62K
EncodeFiveProperty 40.19% 161.60us 6.19K
----------------------------------------------------------------------------
OneVertexOneProperty 438.58us 2.28K
OneVertexOnePropertyWithFilter 58.77% 746.31us 1.34K
OneVertexOnePropertyOnlyEdgeNode 110.17% 398.08us 2.51K
OneVertexOneProperyOnlyKV 113.19% 387.48us 2.58K
OneVertexThreeProperty 58.42% 750.71us 1.33K
OneVertexFiveProperty 44.99% 974.83us 1.03K
----------------------------------------------------------------------------
TenVertexOneProperty 5.30ms 188.83
TenVertexOnePropertyWithFilter 69.70% 7.60ms 131.62
TenVertexOnePropertyOnlyEdgeNode 119.34% 4.44ms 225.34
TenVertexOneProperyOnlyKV 120.89% 4.38ms 228.27
TenVertexOneProperty 4.41ms 226.78
TenVertexOnePropertyWithFilter 58.92% 7.48ms 133.61
TenVertexOnePropertyOnlyEdgeNode 109.54% 4.03ms 248.42
TenVertexOneProperyOnlyKV 112.36% 3.92ms 254.81
TenVertexThreeProperty 58.57% 7.53ms 132.82
TenVertexFiveProperty 45.23% 9.75ms 102.57
============================================================================
*/

0 comments on commit 104dfb9

Please sign in to comment.