Skip to content

perf: look up parent package initializers by prefix in dead-code reachability - #139

Merged
chio-labs-delivery[bot] merged 1 commit into
mainfrom
perf/dead-code-reachability
Nov 16, 2026
Merged

chio-labs-delivery[bot] merged 1 commit into
mainfrom
perf/dead-code-reachability

Conversation

@kvlonge

@kvlonge kvlonge commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Why

Dead-code reachability linked each module to the initializers of its parent packages by comparing it with every other module and formatting a prefix string per pair. That is quadratic in the module count, so large projects pay a growing share of fensu check time in this one loop.

Changes

  • extract() in dead_code/_helpers/graph.rs builds a set of initializer module names once, and each module looks up only its own dotted prefixes in it.
  • The edges are the same set as before (strict dotted prefixes that are initializers). Edges go into per-node sets and the references are sorted afterwards, so the output order is unchanged.

Verification

  • make check-ci passes (ruff, ty, fensu check, cargo fmt --check, clippy, Rust self-check); cargo test -p fensu-facts passes, including the nested-initializer reachability cases.
  • Same machine, release profile, synthetic package trees, 3 alternating runs each, median extract() time for 2k / 4k / 8k / 16k modules:
    • before: 20.5 / 55.5 / 142.6 / 408.9 ms
    • after: 18.6 / 43.4 / 94.8 / 200.7 ms
    • 4k to 16k growth falls from 7.4x to 4.6x.

…hability

Linking each module to the initializers of its parent packages compared every
module with every other one and formatted a prefix string per pair, which grows
quadratically with the module count. Each module now looks up its own dotted
prefixes in a set of initializer names.
@chio-labs-delivery
chio-labs-delivery Bot enabled auto-merge (squash) November 16, 2026 07:10
@chio-labs-delivery
chio-labs-delivery Bot merged commit 55d83a0 into main Nov 16, 2026
53 checks passed
@chio-labs-delivery
chio-labs-delivery Bot deleted the perf/dead-code-reachability branch November 16, 2026 07:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant