Faster Than Ninja

(build2.org)

29 points | by elasticdog 1 hour ago

2 comments

  • evmar 3 minutes ago
    [Ninja author here] Nice post, cool to see the deep dive! I also appreciate the details on how they produced their numbers.

    As they observe, Ninja gets to be fast mostly by cheating: it avoids a lot of work by saying many things are just out of scope for Ninja to do, and that means it is a useful a target to race against. (Funny thing: when I wrote Ninja I was misremembering how fast an earlier build system was so I kept trying to make it faster. So don't treat it as a lower bound, I just made it up!)

    I comment here to say I find the explanation for 'why' in this post unsatisfying. They mention three design decisions.

    The first one is a criticism of CMake, not Ninja (?), so I don't think it can be why. I might have misunderstood?

    The second reason given is doing some work like header dependencies in multiple threads. This is the most plausible reason to me but it still feels unlikely. It's a very small amount of work: the post mentions 300 compiles, so maybe parsing 300 small text files?

    The third is that they run the compiler up front an additional time to gather headers, which is strictly more work than Ninja. There is some hand waving about file access patterns but I am skeptical; if the end-to-end build time is 3 seconds then the project is small enough to all fit in kernel caches. They also mention doing other things like invoking the compiler to get version information. This seems like it would dwarf any performance gain from number 2.

    Maybe it's just my own curiosity, I think this post would be better if it had a better explanation for the reason. I'm not disputing the result, I just think the result should make you suspicious that something else is going on, and you might learn something from that! You could for example explore whether it's the header dependency thing by profiling the Ninja invocation and seeing if it's waiting for CPU or waiting for tasks to execute.

    (If I had to guess without looking at any of the involved code, I would predict it's something about how CMake generates the build, like it introduces serialization in a place where build2 is parallel, or it adds some extra build steps like gathering the current git hash into a header file or something.)

  • ladams 41 minutes ago
    > And now we are 2.2% faster than Ninja!

    This claim isn't supported by the author's measurements?

    • boris 3 minutes ago
      At least you know it was written by a fallible human. But if you point out my mistake, I will be happy to fix it.
    • karen_arutyunov 9 minutes ago
      1 - 3.355/3.429 = 0.021581 = 2,2%

      no?