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
3 changes: 3 additions & 0 deletions .jules/bolt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 2026-06-07 - Python loop overhead in graph traversal
**Learning:** In highly connected graphs within a static analysis engine, looping over sets in Python (`for mod in callers: if mod not in closure: ...`) can introduce significant bytecode execution overhead.
**Action:** Replace Python loops checking membership with fast C-level set operations (e.g., `callers - closure`) and use list-based stacks instead of intermediate set constructions for graph frontiers. This avoids O(N) Python iteration in hot paths.
20 changes: 10 additions & 10 deletions src/wardline/scanner/taint/reverse_edge_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ def callers_of(self, callee_module: str) -> frozenset[str]:
def transitive_callers(self, seeds: frozenset[str]) -> frozenset[str]:
"""``seeds`` plus every transitively-reverse-reachable module."""
closure: set[str] = set(seeds)
frontier: set[str] = set(seeds)
frontier: list[str] = list(seeds)
get_callers = self._reverse.get

while frontier:
next_frontier: set[str] = set()
for mod in frontier:
if mod not in self._reverse:
continue
for caller_mod in self._reverse[mod]:
if caller_mod not in closure:
closure.add(caller_mod)
next_frontier.add(caller_mod)
frontier = next_frontier
mod = frontier.pop()
callers = get_callers(mod)
if callers:
new_callers = callers - closure
if new_callers:
closure.update(new_callers)
frontier.extend(new_callers)
return frozenset(closure)
Loading