Review: Latent Dependencies #22241
Replies: 8 comments 5 replies
-
cc @Bocete |
Beta Was this translation helpful? Give feedback.
-
cc @jgrave3 |
Beta Was this translation helpful? Give feedback.
-
One limitation was brought to my attention: as it is, the above design makes it possible for a latent dependency to be materialized at any point in its reverse transitive closure, which makes it impossible for Bazel to determine when it will not be used anymore, and thus reclaim its memory use if need be. Technically, this could be solved by walking the Java object graph of the providers a given configured target produces and noting every With this in mind, I propose the following alternative:
This way, Bazel can tell when a latent dep is guaranteed not to be needed anymore. |
Beta Was this translation helpful? Give feedback.
-
Surfacing a concern that I have in this comment, I fear that this adds yet another advanced knob to the Starlark APIs that makes Bazel 1) harder to learn and 2) harder to reason about.
This is also conceptually similar to a select statement (as pointed out by @gregestren), which could also confuse people even more. What makes this different to structuring the build graph in a way that instead of wherever you apply the aspect materializer function, you transition a config object down that could be used for a select statement further down the graph to analyze the selected attribute branch there and then? Can we simplify? |
Beta Was this translation helpful? Give feedback.
-
Yes, the increase in API surface are is definitely real, but I don't see any obvious way to make this simpler while keeping all the benefits. In particular, I don't think configuration transitions are an adequate replacement. Here are the reasons, roughly from weakest to strongest, taking the dependency injection use case as an example:
I thought a bit about how this could be achieved in way that's less powerful, but I haven't been able to come up with anything other than the "run a periodic cleanup process in the repository" idea which I'm pretty sure would be worse overall. |
Beta Was this translation helpful? Give feedback.
-
Update: this is now approved by @meisterT @jin and @haxorz . All that now remains is the minor detail of implementing it! |
Beta Was this translation helpful? Give feedback.
-
Update: I implemented this, played with it then found some pretty significant holes. Namely, in this design, the decision about what to materialize can depend on any configured target, which means that in order to compute the full configured target graph, one may need to do arbitrary analysis. This would in turn mean that one couldn't be sure that a given configured target is not needed anymore, ever which interferes with our future plans to reclaim RAM. I have some ideas about how to fix this and I have a prototype almost ready. Once it's ready, I'll write it up and send the updated design for discussion and notify this thread. |
Beta Was this translation helpful? Give feedback.
-
The new design doc is here . |
Beta Was this translation helpful? Give feedback.
-
Hey there,
This is the review for the proposal "Latent Dependencies: user logic to choose whether a dependency is analyzed". (here)
The short summary is that dependency injection frameworks frequently ignore large parts of the dependency graph, thereby wasting loading and analysis work. This proposal makes it possible for Bazel to ignore such unnecessary dependencies, thereby eliminating the above waste.
Beta Was this translation helpful? Give feedback.
All reactions