apache / buildstream

BuildStream, the software integration tool
https://buildstream.build/
Apache License 2.0
85 stars 28 forks source link

Cache key doesn't change despite some changes in the dependency graph #1893

Open abderrahim opened 9 months ago

abderrahim commented 9 months ago

Let's consider this example. Element A.bst build-depends on two unrelated elements B.bst and C.bst.

Now if I add a runtime-depends on C.bst to B.bst, the cache keys don't change. B's cache key doesn't take into account runtime dependencies, and A's cache key only takes into account the list of build dependencies, which hasn't changed (it's still B and C, plus whatever runtime dependencies they had).

The issue here is that A does have access to the dependency graph, not only the list of dependencies. So self.dependencies(recurse=False) would return B and C, and calling dependencies() on B will reveal the new dependency.

Most plugins don't go looking into the dependency graph, but for those that do this leads to the same cache key (and the element not getting rebuilt) even though the result would be different.

gtristan commented 9 months ago

I see.

So you are saying that the plugins experience can change, with the same cache key.

This is an interesting corner case, presumably if B were to instead add a runtime dependency on unrelated D, then the cache key of A would change correct ?

This needs some thought…

abderrahim commented 9 months ago

presumably if B were to instead add a runtime dependency on unrelated D, then the cache key of A would change correct ?

Right. In this case, D would be added to the cache key.