Closed
bazel/deps: Fix attribution performance and robustness in reachability aspect#1119
Conversation
Signed-off-by: Ryan Northey <ryan@synca.io>
Co-authored-by: phlax <454682+phlax@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Improve performance and robustness of reachability aspect
bazel/deps: Fix attribution performance and robustness in reachability aspect
Aug 24, 2026
phlax
force-pushed
the
bazel-deps-matrix
branch
3 times, most recently
from
August 25, 2026 13:28
67a14cb to
856fee9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
attribution_patternsfeature added per-nodedict(repo → depset(package))propagation through the aspect, causing quadratic-class allocation and unguardedNonedereferences oninfo.repos/info.attributed_packages.Issue 2 — Per-node dict-of-depsets eliminated
attributed_packagesprovider field changes fromdict(repo → depset(package))to a flatdepset(struct(package=..., repo=...)). Three helpers deleted:_append_repo_package_depsets— copied key lists into a fresh dict at every node for every dep_add_repo_package— built dict entries at matching nodes_materialize_repo_packages— constructed per-repo depsets at every nodeTransitive pairs from deps now flow up untouched via
transitive=[info.attributed_packages, ...]. The rule impl (which already flattens once per root per config for edges) inverts the flat pair list into therepo → packagesmapping at that point:Issue 3 — None guards on attribution fields
info.repos,info.production_repos,info.attributed_packages, andinfo.production_attributed_packageswere appended unconditionally. They areNonewhen attribution is disabled. Safe today because_ATTRIBUTION_PATTERNS_SETTINGis uniform across the split, but a latent crash otherwise. Explicitif info.repos != None:guards added.Issue 1 — Documented, not eliminable
The
.to_list()at matching nodes cannot be removed in a pure bottom-up aspect without shipping a semantically wrong approximation. Attribution requires pairing each matching package with all repos in its transitive closure, but ancestors haven't been visited yet during bottom-up traversal. The cross-product-at-root alternative (propagatematching_packagesandreposas independent depsets, multiply at the rule) incorrectly attributes package B to repo R1 whenever any other matching package A also reaches R1, even if B has no path to R1. The flatten is kept but bounded to nodes whose package actually matchesattribution_patterns— a detailed comment explains the constraint.