Skip to content

cmGlobalNinjaGenerator: Optimize target depends closure

Rewrite AppendTargetDependsClosure method to only cache local target outputs, not including outputs from dependencies.

Caching all recursive target outputs causes much time to be spent merging sets that have many elements in common (from targets that are included through multiple dependency paths).
For instance, in the large CMake project I'm working with, I've measured that almost 99% of values added to AppendTargetDependsClosure's outputs parameter were already present, leaving the set unchanged after the insertion.

Here is the performance improvement:

Total Generate time
Without change 512s
With change 344s

I haven't measured the impact on other CMake projects, but I'm rather confident this will be an improvement because it's especially helpful when widely-included dependencies produce many outputs, which seems like a common case.

Merge request reports