Skip to content

Commit 72c6691

Browse files
committed
perf(diffctx): pass file_cache to edge builder discovery
Thread file_cache dict through discover_all_related_files → edge builders. PythonEdgeBuilder._build_import_index now reads from cache instead of disk. Add **kwargs to all 43 discover_related_files overrides to support optional cache parameter. Eliminates ~3500 redundant file reads per invocation on large Python repos.
1 parent b674080 commit 72c6691

46 files changed

Lines changed: 63 additions & 9 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/treemapper/diffctx/edges/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,11 @@ def discover_all_related_files(
7171
changed_files: list[Path],
7272
all_candidate_files: list[Path],
7373
repo_root: Path | None = None,
74+
file_cache: dict[Path, str] | None = None,
7475
) -> list[Path]:
7576
discovered: set[Path] = set()
7677
for builder in get_all_builders():
77-
for f in builder.discover_related_files(changed_files, all_candidate_files, repo_root):
78+
for f in builder.discover_related_files(changed_files, all_candidate_files, repo_root, file_cache=file_cache):
7879
discovered.add(f)
7980
return list(discovered)
8081

src/treemapper/diffctx/edges/base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ def discover_related_files(
181181
changed_files: list[Path],
182182
all_candidate_files: list[Path],
183183
repo_root: Path | None = None,
184+
**kwargs: object,
184185
) -> list[Path]:
185186
return []
186187

src/treemapper/diffctx/edges/config/build.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ def discover_related_files(
9595
changed_files: list[Path],
9696
all_candidate_files: list[Path],
9797
repo_root: Path | None = None,
98+
**kwargs: object,
9899
) -> list[Path]:
99100
make_files = [f for f in changed_files if _is_makefile(f)]
100101
cmake_files = [f for f in changed_files if _is_cmake(f)]

src/treemapper/diffctx/edges/config/cicd.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ def discover_related_files(
264264
changed_files: list[Path],
265265
all_candidate_files: list[Path],
266266
repo_root: Path | None = None,
267+
**kwargs: object,
267268
) -> list[Path]:
268269
ci_files = [f for f in changed_files if _is_ci_file(f)]
269270
if not ci_files:

src/treemapper/diffctx/edges/config/docker.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ def discover_related_files(
9191
changed_files: list[Path],
9292
all_candidate_files: list[Path],
9393
repo_root: Path | None = None,
94+
**kwargs: object,
9495
) -> list[Path]:
9596
docker_files = [f for f in changed_files if _is_dockerfile(f) or _is_compose_file(f)]
9697
if not docker_files:

src/treemapper/diffctx/edges/config/generic.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ def discover_related_files(
123123
changed_files: list[Path],
124124
all_candidate_files: list[Path],
125125
repo_root: Path | None = None,
126+
**kwargs: object,
126127
) -> list[Path]:
127128
config_changed = [f for f in changed_files if _is_config_file(f)]
128129
if not config_changed:

src/treemapper/diffctx/edges/config/helm.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ def discover_related_files(
8888
changed_files: list[Path],
8989
all_candidate_files: list[Path],
9090
repo_root: Path | None = None,
91+
**kwargs: object,
9192
) -> list[Path]:
9293
templates = [f for f in changed_files if _is_helm_template(f)]
9394
values = [f for f in changed_files if _is_helm_values(f)]

src/treemapper/diffctx/edges/config/kubernetes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ def discover_related_files(
181181
changed_files: list[Path],
182182
all_candidate_files: list[Path],
183183
repo_root: Path | None = None,
184+
**kwargs: object,
184185
) -> list[Path]:
185186
k8s_files = _find_k8s_files(changed_files)
186187
if not k8s_files:

src/treemapper/diffctx/edges/config/terraform.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ def discover_related_files(
200200
changed_files: list[Path],
201201
all_candidate_files: list[Path],
202202
repo_root: Path | None = None,
203+
**kwargs: object,
203204
) -> list[Path]:
204205
tf_files = [f for f in changed_files if _is_terraform_file(f)]
205206
if not tf_files:

src/treemapper/diffctx/edges/semantic/ansible.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ def discover_related_files(
104104
changed_files: list[Path],
105105
all_candidate_files: list[Path],
106106
repo_root: Path | None = None,
107+
**kwargs: object,
107108
) -> list[Path]:
108109
ansible_changed = [f for f in changed_files if _is_ansible_file(f)]
109110
if not ansible_changed:

0 commit comments

Comments
 (0)