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

Fix/performance #1622

Merged
merged 10 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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: 0 additions & 4 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ jobs:
toolchain: 1.77.0
override: true
components: rustfmt, clippy
- name: Cargo update
uses: actions-rs/cargo@v1
with:
command: update
- name: Run benchmark (Unix)
run: |
set -o pipefail
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test_python_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ jobs:
with:
python-version: ${{ matrix.python }}
cache: 'pip'
- name: Flip raphtory-arrow in Cargo.toml
run: python ./scripts/flip_ra.py Cargo.toml
- name: Activate raphtory-arrow in Cargo.toml
run: python ./scripts/activate_private_arrow.py Cargo.toml
- name: Run Maturin develop
uses: PyO3/maturin-action@v1
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test_rust_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ jobs:
name: Cargo cache
with:
cache-all-crates: true
- name: Flip raphtory-arrow in Cargo.toml
run: python ./scripts/flip_ra.py
- name: Activate raphtory-arrow in Cargo.toml
run: python ./scripts/activate_private_arrow.py
- name: Install bininstall
uses: cargo-bins/cargo-binstall@main
- name: Install nextest
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "raphtory-arrow-private"]
path = raphtory-arrow-private
url = [email protected]:Pometry/raphtory-arrow.git
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ inherits = "release"
debug = true

[workspace.dependencies]
#[public-arrow]
raphtory-arrow = { version = "0.8.1", path = "raphtory-arrow" }
#[private-arrow]
# raphtory-arrow = { path = "raphtory-arrow-private", package = "raphtory-arrow-private" }
async-graphql = { version = "6.0.11", features = ["dynamic-schema"] }
async-graphql-poem = "6.0.11"
dynamic-graphql = "0.8.1"
Expand Down
18 changes: 16 additions & 2 deletions examples/rust/src/bin/hulongbay/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@
#![allow(dead_code)]
use itertools::Itertools;
use raphtory::{
algorithms::{components::weakly_connected_components, motifs::triangle_count::triangle_count},
algorithms::{
components::weakly_connected_components,
motifs::{
global_temporal_three_node_motifs::global_temporal_three_node_motif,
triangle_count::triangle_count,
},
},
graph_loader::source::csv_loader::CsvLoader,
prelude::*,
};
Expand Down Expand Up @@ -207,8 +213,16 @@ fn try_main_bm() -> Result<(), Box<dyn Error>> {
Ok(())
}

fn try_motif() -> Result<(), Box<dyn Error>> {
let args: Vec<String> = env::args().collect();
let data_dir = Path::new(args.get(1).ok_or(MissingArgumentError)?);
let graph = loader(data_dir)?;
global_temporal_three_node_motif(&graph, 3600, None);
Ok(())
}

fn main() {
if let Err(e) = try_main_bm() {
if let Err(e) = try_motif() {
eprintln!("Failed: {}", e);
std::process::exit(1)
}
Expand Down
1 change: 1 addition & 0 deletions raphtory-arrow-private
Submodule raphtory-arrow-private added at 78f231
2 changes: 1 addition & 1 deletion raphtory-benchmark/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ edition = "2021"
criterion = { workspace = true }
raphtory = { path = "../raphtory", features = ["io"] }
raphtory-graphql = { path = "../raphtory-graphql", version = "0.8.1" }
raphtory-arrow = { path = "../raphtory-arrow", version = "0.8.1" }
raphtory-arrow.workspace = true
sorted_vector_map = { workspace = true }
rand = { workspace = true }
rayon = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion raphtory-cypher/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ edition.workspace = true

[dependencies]
raphtory = { path = "../raphtory" }
raphtory-arrow = { path = "../raphtory-arrow", optional = true, version = "0.8.1"}
raphtory-arrow = { workspace = true, optional = true }
arrow.workspace = true
arrow-buffer.workspace = true
arrow-schema.workspace = true
Expand Down
4 changes: 2 additions & 2 deletions raphtory/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ homepage.workspace = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
raphtory-api = { path = "../raphtory-api", version="0.8.1" }
raphtory-api = { path = "../raphtory-api", version = "0.8.1" }
bincode = { workspace = true }
chrono = { workspace = true }
itertools = { workspace = true }
Expand Down Expand Up @@ -74,7 +74,7 @@ tempfile = { workspace = true, optional = true }
bytemuck = { workspace = true, optional = true }
rpds = { workspace = true, optional = true }
thread_local = { workspace = true, optional = true }
raphtory-arrow = { path = "../raphtory-arrow", version="0.8.1", optional = true }
raphtory-arrow = { workspace = true, optional = true }

[dev-dependencies]
csv = { workspace = true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
compute_state::ComputeStateVec,
},
db::{
api::view::{GraphViewOps, NodeViewOps, *},
api::view::*,
graph::views::node_subgraph::NodeSubgraph,
task::{
context::Context,
Expand All @@ -23,15 +23,11 @@ use std::collections::HashMap;

///////////////////////////////////////////////////////

pub fn star_motif_count<G>(
graph: &G,
evv: &EvalNodeView<G, ()>,
deltas: Vec<i64>,
) -> Vec<[usize; 32]>
pub fn star_motif_count<G>(evv: &EvalNodeView<G, ()>, deltas: Vec<i64>) -> Vec<[usize; 32]>
where
G: StaticGraphViewOps,
{
let two_n_c = twonode_motif_count(graph, evv, deltas.clone());
let two_n_c = twonode_motif_count(evv, deltas.clone());
let neigh_map: HashMap<u64, usize> = evv
.neighbours()
.into_iter()
Expand Down Expand Up @@ -75,20 +71,16 @@ where

///////////////////////////////////////////////////////

pub fn twonode_motif_count<G>(
graph: &G,
evv: &EvalNodeView<G, ()>,
deltas: Vec<i64>,
) -> Vec<[usize; 8]>
pub fn twonode_motif_count<G>(evv: &EvalNodeView<G, ()>, deltas: Vec<i64>) -> Vec<[usize; 8]>
where
G: StaticGraphViewOps,
{
let mut results = deltas.iter().map(|_| [0; 8]).collect::<Vec<[usize; 8]>>();

for nb in evv.neighbours().into_iter() {
let nb_id = nb.id();
let out = graph.edge(evv.id(), nb_id);
let inc = graph.edge(nb_id, evv.id());
let out = evv.graph().edge(evv.id(), nb_id);
let inc = evv.graph().edge(nb_id, evv.id());
let events: Vec<TwoNodeEvent> = out
.iter()
.flat_map(|e| e.explode())
Expand Down Expand Up @@ -181,7 +173,8 @@ where
.sorted()
.permutations(2)
.flat_map(|e| {
g.edge(*e.first().unwrap(), *e.get(1).unwrap())
u.graph()
.edge(*e.first().unwrap(), *e.get(1).unwrap())
.iter()
.flat_map(|edge| edge.explode())
.collect::<Vec<_>>()
Expand Down Expand Up @@ -265,8 +258,7 @@ where
let out1 = triangle_motifs(g, deltas.clone(), threads);

let step1 = ATask::new(move |evv: &mut EvalNodeView<G, _>| {
let g = evv.graph();
let star_nodes = star_motif_count(g, evv, deltas.clone());
let star_nodes = star_motif_count(evv, deltas.clone());
for (i, star) in star_nodes.iter().enumerate() {
evv.global_update(&star_mc[i], *star);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ where
///////////////////////////////////////////////////////

pub fn twonode_motif_count<'a, 'b, G, GH>(
graph: &'a G,
evv: &'a EvalNodeView<'b, '_, G, MotifCounter, GH>,
deltas: Vec<i64>,
) -> Vec<[usize; 8]>
Expand All @@ -144,8 +143,8 @@ where

for nb in evv.neighbours().into_iter() {
let nb_id = nb.id();
let out = graph.edge(evv.id(), nb_id);
let inc = graph.edge(nb_id, evv.id());
let out = evv.graph().edge(evv.id(), nb_id);
let inc = evv.graph().edge(nb_id, evv.id());
let events: Vec<TwoNodeEvent> = out
.iter()
.flat_map(|e| e.explode())
Expand Down Expand Up @@ -337,8 +336,7 @@ where
let out1 = triangle_motifs(g, deltas.clone(), motifs_counter, threads);

let step1 = ATask::new(move |evv: &mut EvalNodeView<G, MotifCounter>| {
let g = evv.graph();
let two_nodes = twonode_motif_count(g, evv, deltas.clone());
let two_nodes = twonode_motif_count(evv, deltas.clone());
let star_nodes = star_motif_count(evv, deltas.clone());

*evv.get_mut() = MotifCounter::new(
Expand Down
18 changes: 9 additions & 9 deletions raphtory/src/arrow/graph_impl/core_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use crate::{
};
use itertools::Itertools;
use polars_arrow::datatypes::ArrowDataType;
use raphtory_arrow::{properties::Properties, GID};
use raphtory_arrow::{properties::Properties, GidRef, GID};
use rayon::prelude::*;
impl CoreGraphOps for ArrowGraph {
fn unfiltered_num_nodes(&self) -> usize {
Expand Down Expand Up @@ -97,17 +97,17 @@ impl CoreGraphOps for ArrowGraph {

fn node_id(&self, v: VID) -> u64 {
match self.inner.node_gid(v).unwrap() {
GID::U64(n) => n,
GID::I64(n) => n as u64,
GID::Str(s) => s.id(),
GidRef::U64(n) => n,
GidRef::I64(n) => n as u64,
GidRef::Str(s) => s.id(),
}
}

fn node_name(&self, v: VID) -> String {
match self.inner.node_gid(v).unwrap() {
GID::U64(n) => n.to_string(),
GID::I64(n) => n.to_string(),
GID::Str(s) => s,
GidRef::U64(n) => n.to_string(),
GidRef::I64(n) => n.to_string(),
GidRef::Str(s) => s.to_owned(),
}
}

Expand Down Expand Up @@ -200,15 +200,15 @@ impl CoreGraphOps for ArrowGraph {
}

fn core_nodes(&self) -> NodesStorage {
NodesStorage::Arrow(ArrowNodesOwned::new(&self.inner))
NodesStorage::Arrow(ArrowNodesOwned::new(self.inner.clone()))
}

fn core_node_entry(&self, vid: VID) -> NodeStorageEntry {
NodeStorageEntry::Arrow(ArrowNode::new(&self.inner, vid))
}

fn core_node_arc(&self, vid: VID) -> NodeOwnedEntry {
NodeOwnedEntry::Arrow(ArrowOwnedNode::new(&self.inner, vid))
NodeOwnedEntry::Arrow(ArrowOwnedNode::new(self.inner.clone(), vid))
}

fn core_edge_arc(&self, eid: ELID) -> EdgeOwnedEntry {
Expand Down
Loading
Loading