From 3e99ee0bab208666e74b1371ff342ea4321ca27c Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 22 May 2026 17:37:54 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=20Bolt:=20[performance=20improvement]?= =?UTF-8?q?=20Defer=20PathBuf=20allocations=20in=20Tarjan's=20SCC=20DFS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaces `v.to_path_buf()` with a borrowed `&Path` reference `v` when looking up indices and lowlinks in `tarjan_dfs`. This eliminates heap allocations (O(E)) during graph traversals while searching for strongly connected components in the dependency invalidator graph. Co-authored-by: bashandbone <89049923+bashandbone@users.noreply.github.com> --- crates/flow/src/incremental/invalidation.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/flow/src/incremental/invalidation.rs b/crates/flow/src/incremental/invalidation.rs index da9ac9c..eac784f 100644 --- a/crates/flow/src/incremental/invalidation.rs +++ b/crates/flow/src/incremental/invalidation.rs @@ -358,19 +358,19 @@ impl InvalidationDetector { // Update lowlink let w_lowlink = *state.lowlinks.get(dep).unwrap(); - let v_lowlink = state.lowlinks.get_mut(&v.to_path_buf()).unwrap(); + let v_lowlink = state.lowlinks.get_mut(v).unwrap(); *v_lowlink = (*v_lowlink).min(w_lowlink); } else if state.on_stack.contains(dep) { // Successor is on stack (part of current SCC) let w_index = *state.indices.get(dep).unwrap(); - let v_lowlink = state.lowlinks.get_mut(&v.to_path_buf()).unwrap(); + let v_lowlink = state.lowlinks.get_mut(v).unwrap(); *v_lowlink = (*v_lowlink).min(w_index); } } // If v is a root node, pop the stack to create an SCC - let v_index = *state.indices.get(&v.to_path_buf()).unwrap(); - let v_lowlink = *state.lowlinks.get(&v.to_path_buf()).unwrap(); + let v_index = *state.indices.get(v).unwrap(); + let v_lowlink = *state.lowlinks.get(v).unwrap(); if v_lowlink == v_index { let mut scc = Vec::new();