Skip to content
Open
Show file tree
Hide file tree
Changes from all 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: 4 additions & 0 deletions .github/workflows/claude.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ jobs:
label_trigger: claude
base_branch: staging
max_turns: "30"
allowed_bots: "Copilot"
allowed_tools: &allowed_tools |
mcp__context7__resolve-library-id
mcp__context7__get-library-docs
Expand Down Expand Up @@ -111,6 +112,7 @@ jobs:
label_trigger: claude
base_branch: staging
max_turns: "30"
allowed_bots: "Copilot"
allowed_tools: *allowed_tools
mcp_config: *mcp_config
direct_prompt: |
Expand All @@ -134,6 +136,7 @@ jobs:
mode: agent
base_branch: staging
max_turns: "30"
allowed_bots: "Copilot"
allowed_tools: *allowed_tools
mcp_config: *mcp_config
direct_prompt: |
Expand All @@ -157,6 +160,7 @@ jobs:
label_trigger: claude
base_branch: staging
max_turns: "30"
allowed_bots: "Copilot"
allowed_tools: *allowed_tools
mcp_config: *mcp_config
direct_prompt: |
Expand Down
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions crates/flow/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ name = "d1_profiling"
harness = false
name = "load_test"

[[bench]]
harness = false
name = "bench_graph_traversal"

[dependencies]
async-trait = { workspace = true }
base64 = "0.22"
Expand Down Expand Up @@ -103,6 +107,7 @@ rusqlite = { version = "0.32.1", features = ["bundled"] }
tempfile = "3.13"
testcontainers = "0.27.1"
testcontainers-modules = { version = "0.15.0", features = ["postgres"] }
thread-utilities.workspace = true
tokio-postgres = "0.7"

[features]
Expand Down
43 changes: 43 additions & 0 deletions crates/flow/benches/bench_graph_traversal.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
use std::path::PathBuf;
use thread_flow::incremental::graph::DependencyGraph;
use thread_flow::incremental::types::{DependencyEdge, DependencyType};
use thread_utilities::RapidSet;

use std::hint::black_box;
use criterion::{Criterion, criterion_group, criterion_main};

fn bench_find_affected_files(c: &mut Criterion) {
let mut graph = DependencyGraph::new();
let num_files = 10000;
let deps_per_file = 10;

// Create nodes
for i in 0..num_files {
graph.add_node(&PathBuf::from(format!("file_{}.rs", i)));
}

// Create edges (linear chain with some random deps)
for i in 0..num_files {
for j in 1..=deps_per_file {
let dep_idx = (i + j) % num_files;
graph.add_edge(DependencyEdge::new(
PathBuf::from(format!("file_{}.rs", i)),
PathBuf::from(format!("file_{}.rs", dep_idx)),
DependencyType::Import,
));
}
}

let changed_files: RapidSet<PathBuf> = (0..10)
.map(|i| PathBuf::from(format!("file_{}.rs", i)))
.collect();

c.bench_function("find_affected_files_10000_nodes", |b| {
b.iter(|| {
let _affected = graph.find_affected_files(black_box(&changed_files));
})
});
}

criterion_group!(benches, bench_find_affected_files);
criterion_main!(benches);
20 changes: 8 additions & 12 deletions crates/flow/src/incremental/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,21 +267,17 @@ impl DependencyGraph {
/// assert!(affected.contains(&PathBuf::from("C")));
/// ```
pub fn find_affected_files(&self, changed_files: &RapidSet<PathBuf>) -> RapidSet<PathBuf> {
let mut affected = thread_utilities::get_set();
let mut visited = thread_utilities::get_set();
let mut queue: VecDeque<PathBuf> = changed_files.iter().cloned().collect();
let mut affected = changed_files.clone();
let mut queue: VecDeque<&PathBuf> = changed_files.iter().collect();
Comment on lines +270 to +271
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cloning changed_files clones the entire set backing storage up-front. If RapidSet is large (or if thread_utilities::get_set() is intended to reuse thread-local allocations), consider allocating affected via get_set() and populating it via extend(changed_files.iter().cloned()) (or reserving appropriately) to avoid cloning the hash table structure.

Copilot uses AI. Check for mistakes.

while let Some(file) = queue.pop_front() {
if !visited.insert(file.clone()) {
continue;
}

affected.insert(file.clone());

// Follow reverse edges (files that depend on this file)
for edge in self.get_dependents(&file) {
if edge.effective_strength() == DependencyStrength::Strong {
queue.push_back(edge.from.clone());
for edge in self.get_dependents(file) {
if edge.effective_strength() == DependencyStrength::Strong
&& !affected.contains(&edge.from)
{
affected.insert(edge.from.clone());
queue.push_back(&edge.from);
}
}
Comment on lines +275 to 282
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

affected.contains(...) followed by affected.insert(...) performs two hash lookups. You can do this in one lookup by relying on insert’s boolean return (e.g., if affected.insert(edge.from.clone()) { ... }). This keeps the same behavior and further tightens the inner loop.

Copilot uses AI. Check for mistakes.
}
Expand Down
6 changes: 3 additions & 3 deletions crates/language/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1721,17 +1721,17 @@ pub fn from_extension(path: &Path) -> Option<SupportLang> {
}

// Handle extensionless files or files with unknown extensions
if let Some(_file_name) = path.file_name().and_then(|n| n.to_str()) {
if let Some(file_name) = path.file_name().and_then(|n| n.to_str()) {
// 1. Check if the full filename matches a known extension (e.g. .bashrc)
#[cfg(any(feature = "bash", feature = "all-parsers"))]
if constants::BASH_EXTS.contains(&_file_name) {
if constants::BASH_EXTS.contains(&file_name) {
return Some(SupportLang::Bash);
}

// 2. Check known extensionless file names
#[cfg(any(feature = "bash", feature = "all-parsers", feature = "ruby"))]
for (name, lang) in constants::LANG_RELATIONSHIPS_WITH_NO_EXTENSION {
if *name == _file_name {
if *name == file_name {
return Some(*lang);
}
}
Expand Down
Loading