Skip to content

Commit

Permalink
increase sample size in graph_ops bench and fix earliest_time
Browse files Browse the repository at this point in the history
  • Loading branch information
fabianmurariu committed Jun 18, 2024
1 parent 2ae5d80 commit 736086a
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 7 deletions.
8 changes: 4 additions & 4 deletions raphtory-benchmark/benches/graph_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub fn graph(c: &mut Criterion) {
let group_name = "analysis_graph_window_100";
let make_graph = || graph.window(i64::MIN, i64::MAX);
let mut graph_window_group_100 = c.benchmark_group(group_name);
graph_window_group_100.sample_size(10);
// graph_window_group_100.sample_size(10);
run_analysis_benchmarks(&mut graph_window_group_100, make_graph, None);
graph_window_group_100.finish();

Expand All @@ -38,7 +38,7 @@ pub fn graph(c: &mut Criterion) {
let latest = graph.latest_time().expect("non-empty graph");
let earliest = graph.earliest_time().expect("non-empty graph");
let start = latest - (latest - earliest) / 10;
graph_window_group_10.sample_size(10);
// graph_window_group_10.sample_size(10);
let make_graph = || graph.window(start, latest + 1);
run_analysis_benchmarks(&mut graph_window_group_10, make_graph, None);
graph_window_group_10.finish();
Expand All @@ -56,7 +56,7 @@ pub fn graph(c: &mut Criterion) {
let subgraph = graph.subgraph(nodes);
let group_name = "analysis_subgraph_10pc";
let mut subgraph_10 = c.benchmark_group(group_name);
subgraph_10.sample_size(10);
// subgraph_10.sample_size(10);

let make_graph = || subgraph.clone();
run_analysis_benchmarks(&mut subgraph_10, make_graph, None);
Expand All @@ -66,7 +66,7 @@ pub fn graph(c: &mut Criterion) {
// subgraph windowed
let group_name = "analysis_subgraph_10pc_windowed";
let mut subgraph_10_windowed = c.benchmark_group(group_name);
subgraph_10_windowed.sample_size(10);
// subgraph_10_windowed.sample_size(10);

let make_graph = || subgraph.window(start, latest + 1);
run_analysis_benchmarks(&mut subgraph_10_windowed, make_graph, None);
Expand Down
1 change: 1 addition & 0 deletions raphtory/src/db/api/storage/storage_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ impl GraphStorage {
}
}

#[inline(always)]
pub fn node(&self, vid: VID) -> NodeStorageEntry {
match self {
GraphStorage::Mem(storage) => NodeStorageEntry::Mem(storage.nodes.get(vid)),
Expand Down
50 changes: 47 additions & 3 deletions raphtory/src/db/graph/views/deletion_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,15 @@ impl TimeSemantics for PersistentGraph {
}

fn earliest_time_window(&self, start: i64, end: i64) -> Option<i64> {
self.0.earliest_time_window(start, end)
self.earliest_time_global()
.map(|t| t.max(start))
.filter(|&t| t < end)
}

fn latest_time_window(&self, start: i64, end: i64) -> Option<i64> {
self.0.latest_time_window(start, end)
self.latest_time_global()
.map(|t| t.min(end.saturating_sub(1)))
.filter(|&t| t > start)
}

fn node_earliest_time_window(&self, v: VID, start: i64, end: i64) -> Option<i64> {
Expand Down Expand Up @@ -685,7 +689,9 @@ mod test_deletions {
db::{
api::view::time::internal::InternalTimeOps,
graph::{
edge::EdgeView, graph::assert_graph_equal, views::deletion_graph::PersistentGraph,
edge::EdgeView,
graph::assert_graph_equal,
views::deletion_graph::{PersistentGraph, TimeSemantics},
},
},
prelude::*,
Expand Down Expand Up @@ -848,6 +854,44 @@ mod test_deletions {
assert_graph_equal(&gm, &g.window(3, 5))
}

#[test]
fn test_materialize_window_earliest_time() {
let g = PersistentGraph::new();
g.add_edge(0, 1, 2, NO_PROPS, None).unwrap();
g.delete_edge(10, 1, 2, None).unwrap();

let ltg = g.latest_time_global();
assert_eq!(ltg, Some(10));

let wg = g.window(3, 5);

let e = wg.edge(1, 2).unwrap();
assert_eq!(e.earliest_time(), Some(3));
assert_eq!(e.latest_time(), Some(4));
let n1 = wg.node(1).unwrap();
assert_eq!(n1.earliest_time(), Some(3));
assert_eq!(n1.latest_time(), Some(4));
let n2 = wg.node(2).unwrap();
assert_eq!(n2.earliest_time(), Some(3));
assert_eq!(n2.latest_time(), Some(4));

let actual_lt = wg.latest_time();
assert_eq!(actual_lt, Some(4));

let actual_et = wg.earliest_time();
assert_eq!(actual_et, Some(3));

let gm = g
.window(3, 5)
.materialize()
.unwrap()
.into_persistent()
.unwrap();

let expected_et = gm.earliest_time();
assert_eq!(actual_et, expected_et);
}

#[test]
fn test_exploded_latest_time() {
let g = PersistentGraph::new();
Expand Down

0 comments on commit 736086a

Please sign in to comment.