Skip to content

Commit 59d3956

Browse files
committed
Use degree to size adjacency lists
``` 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. ```
1 parent 2bfa5ef commit 59d3956

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

crates/builder/src/graph/adj_list.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,14 @@ where
218218
(edge_list, node_count, direction, csr_layout): (&'_ E, NI, Direction, CsrLayout),
219219
) -> Self {
220220
let start = Instant::now();
221-
let mut thread_safe_vec = Vec::with_capacity(node_count.index());
222-
thread_safe_vec.resize_with(node_count.index(), || Mutex::new(Vec::new()));
223-
let thread_safe_vec = thread_safe_vec;
221+
let thread_safe_vec = edge_list
222+
.degrees(node_count, direction)
223+
.into_par_iter()
224+
.map(|degree| Mutex::new(Vec::with_capacity(degree.into_inner().index())))
225+
.collect::<Vec<_>>();
226+
info!("Initialized adjacency list in {:?}", start.elapsed());
224227

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

0 commit comments

Comments
 (0)