Is there a way to query the rule graph from rules?...
# development
f
Is there a way to query the rule graph from rules? Like to ask what rules might run from a Get from one type to another? The reason I’m asking is because I’ve identified that a lot of the memory and CPU usage we’re seeing in larger repositories is a result of intermediate results used in resolving transitive targets. Even in cases where this info is cached it needs to be threaded through the runtime graph before it is memoized. I suspect there are optimizations available here if we can find some information that allows us storing some results under a much coarser grained cache key
What I’m thinking is that nearly all dependencies are depend almost entirely on the content of the source target being scanned. There’s a few exceptions like conftest in Python. But anyways if we can understand what potential inputs there might be to this whole section of the graph we might be able to skip it more aggressively in many cases
a
There's definitely a debug option that will dump out a graphviz file that will show you the rule graph for a target
I can go digging for it if that would help
f
I think I wanted to programmatically analyze the rule graph from within a rule, with the aim of finding all possible external inputs. Not sure if that’s even possible
a
I don't believe a rule can get that context… but @witty-crayon-22786 would be the person to ask here.
f
Cool. I’m going to make an issue in the next few days describing in detail what I’d like to do and maybe we can refine it into something that actually works or can work in Pants as it is implemented
b
I think
pants help-advanced
can take a type or maybe a rule to show some of this info, maybe not all
f
I’ll look at how that is implemented to see Joe I can hook into this