Skip to content

Commit

Permalink
Use degree to size adjacency lists (#115)
Browse files Browse the repository at this point in the history
```
adjacency_list_all_targets/large_Outgoing_Unsorted
                        time:   [14.010 ms 14.154 ms 14.305 ms]
                        change: [-36.246% -35.180% -34.199%] (p = 0.00 < 0.05)
                        Performance has improved.
```
  • Loading branch information
s1ck authored Nov 3, 2023
1 parent 23e805a commit e6dfb1f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions crates/builder/src/graph/adj_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,14 @@ where
(edge_list, node_count, direction, csr_layout): (&'_ E, NI, Direction, CsrLayout),
) -> Self {
let start = Instant::now();
let mut thread_safe_vec = Vec::with_capacity(node_count.index());
thread_safe_vec.resize_with(node_count.index(), || Mutex::new(Vec::new()));
let thread_safe_vec = thread_safe_vec;
let thread_safe_vec = edge_list
.degrees(node_count, direction)
.into_par_iter()
.map(|degree| Mutex::new(Vec::with_capacity(degree.into_inner().index())))
.collect::<Vec<_>>();
info!("Initialized adjacency list in {:?}", start.elapsed());

let start = Instant::now();
edge_list.edges().for_each(|(s, t, v)| {
if matches!(direction, Direction::Outgoing | Direction::Undirected) {
thread_safe_vec[s.index()]
Expand Down

0 comments on commit e6dfb1f

Please sign in to comment.