Skip to content
  • Matthias Männich's avatar
    Ninja: Improve performance with deeply-dependent custom targets · ed19e813
    Matthias Männich authored and Brad King's avatar Brad King committed
    The commit v3.7.0-rc1~339^2 (Ninja: Fix inter-target order-only
    dependencies of custom command, 2016-07-20) might cause performance
    degradations for larger projects.  Especially when using custom
    commands as an input for each compilation rule (e.g. generated headers).
    
    For reference in the following I am referring to
      Source/cmGlobalNinjaGenerator.cxx:
        -> cmGlobalNinjaGenerator::AppendTargetDependsClosure
        -> cmGlobalNinjaGenerator::ComputeTargetDependsClosure
    
    It turned out that the mentioned commit is doing (indirectly) some
    redundant work that might impact performance when generating large
    projects.
    
    Imagine the dependency tree of custom targets:
    
        A
         \
          C - D - E
         /
        B
    
    For each target the transitive closure is calculated recursively, but as
    the TargetDependsClosures are only cached on the top most level, everything
    downstream has to be recalculated. I.e.
    
        A->C->D->E
        B->C->D->E
    
    This ultimately leads to ...
    ed19e813