Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use pagerank_local_parallel rather than pagerank_local for better performance #2945

Merged
merged 1 commit into from
Jun 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions analytical_engine/test/run_vy_app.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include "lcc/lcc.h"
#include "pagerank/pagerank.h"
#include "pagerank/pagerank_auto.h"
#include "pagerank/pagerank_local.h"
#include "pagerank/pagerank_local_parallel.h"
#include "sssp/sssp.h"
#include "wcc/wcc.h"

Expand Down Expand Up @@ -321,7 +321,7 @@ void RunProjectedPR(std::shared_ptr<ProjectedFragmentType> fragment,
const std::string& out_prefix) {
// using AppType = grape::PageRankAuto<ProjectedFragmentType>;
using AppType = grape::PageRank<ProjectedFragmentType>;
// using AppType = grape::PageRankLocal<ProjectedFragmentType>;
// using AppType = grape::PageRankLocalParallel<ProjectedFragmentType>;
auto app = std::make_shared<AppType>();
auto worker = AppType::CreateWorker(app, fragment);
auto spec = grape::DefaultParallelEngineSpec();
Expand Down
4 changes: 2 additions & 2 deletions coordinator/gscoordinator/builtin/app/.gs_conf.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
app:
- algo: pagerank
type: cpp_pie
class_name: grape::PageRankLocal
src: pagerank/pagerank_local.h
class_name: grape::PageRankLocalParallel
src: pagerank/pagerank_local_parallel.h
compatible_graph:
- grape::ImmutableEdgecutFragment
- gs::ArrowProjectedFragment
Expand Down
12 changes: 12 additions & 0 deletions python/graphscope/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,18 @@ def pagerank_local_result():
yield ret


@pytest.fixture(scope="module")
def pagerank_local_parallel_result():
ret = {}
ret["directed"] = np.loadtxt(
"{}/ldbc/p2p-31-PR-LOCAL-PARALLEL-directed".format(property_dir), dtype=float
)
ret["undirected"] = np.loadtxt(
"{}/ldbc/p2p-31-PR-LOCAL-PARALLEL".format(property_dir), dtype=float
)
yield ret


@pytest.fixture(scope="module")
def hits_result():
ret = {}
Expand Down
23 changes: 12 additions & 11 deletions python/graphscope/tests/unittest/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def test_run_app_on_pandas_graph(p2p_graph_from_pandas, sssp_result):
def test_run_app_on_directed_graph(
p2p_project_directed_graph,
sssp_result,
pagerank_local_result,
pagerank_local_parallel_result,
hits_result,
bfs_result,
clustering_result,
Expand Down Expand Up @@ -133,7 +133,7 @@ def test_run_app_on_directed_graph(
.sort_values(by=["node"])
.to_numpy(dtype=float)
)
assert np.allclose(ret_pr, pagerank_local_result["directed"])
assert np.allclose(ret_pr, pagerank_local_parallel_result["directed"])

# hits
ctx_hits = hits(p2p_project_directed_graph, tolerance=0.001)
Expand Down Expand Up @@ -224,7 +224,7 @@ def test_run_app_on_directed_graph(
def test_app_on_undirected_graph(
p2p_project_undirected_graph,
sssp_result,
pagerank_local_result,
pagerank_local_parallel_result,
bfs_result,
wcc_result,
lpa_result,
Expand Down Expand Up @@ -262,14 +262,14 @@ def test_app_on_undirected_graph(
.sort_values(by=["node"])
.to_numpy(dtype=float)
)
assert np.allclose(r2, pagerank_local_result["undirected"])
assert np.allclose(r2, pagerank_local_parallel_result["undirected"])
ctx3 = pagerank(p2p_project_undirected_graph, 0.85, 10)
r3 = (
ctx3.to_dataframe({"node": "v.id", "r": "r"})
.sort_values(by=["node"])
.to_numpy(dtype=float)
)
assert np.allclose(r3, pagerank_local_result["undirected"])
assert np.allclose(r3, pagerank_local_parallel_result["undirected"])
# r4 = pagerank(arrow_project_graph, 10, 0.85) # check max_round=10
# assert r4 is not None
ctx5 = pagerank(p2p_project_undirected_graph, "0.85", "10")
Expand All @@ -278,29 +278,30 @@ def test_app_on_undirected_graph(
.sort_values(by=["node"])
.to_numpy(dtype=float)
)
assert np.allclose(r5, pagerank_local_result["undirected"])
assert np.allclose(r5, pagerank_local_parallel_result["undirected"])
ctx6 = pagerank(p2p_project_undirected_graph)
r6 = (
ctx6.to_dataframe({"node": "v.id", "r": "r"})
.sort_values(by=["node"])
.to_numpy(dtype=float)
)
assert np.allclose(r6, pagerank_local_result["undirected"])
assert np.allclose(r6, pagerank_local_parallel_result["undirected"])
assert np.allclose(
ctx6.to_dataframe(
{"node": "v.id", "r": "r"}, vertex_range={"begin": 1, "end": 4}
)
.sort_values(by=["node"])
.to_numpy(),
[
[1.0, 3.851369917786616],
[2.0, 5.808207281313435],
[3.0, 1.0284419953876565],
[1.0, 1.598779010550939e10],
[2.0, 2.117875105210911e10],
[3.0, 5.720363611374399e09],
],
)

assert np.allclose(
sorted(ctx6.to_numpy("r", vertex_range={"begin": 1, "end": 4})),
sorted([3.851369917786616, 5.808207281313435, 1.0284419953876565]),
sorted([1.598779010550939e10, 2.117875105210911e10, 5.720363611374399e09]),
)

# bfs
Expand Down