Skip to content

Ninja: Use more efficient data structures to collect outputs

Nicolas van Kempen requested to merge (removed):performance into master

Use unordered_* for cmNinjaOuts.

I am benchmarking this change by generating Ninja build files for LLVM. I perform one warmup run so that the configure step is minimal in the benchmark. Running with a profiler, it looks like ~17% of cycles are spent in cmGlobalNinjaGenerator::AppendTargetDependsClosure pre-change, and only ~10% after the change, which represents about a second saved.

[~] hyperfine                                                                                                      \
    --warmup 1                                                                                                     \
    -L version vanilla,test                                                                                        \
    '~/cmake/build/{version}/bin/cmake ~/llvm-project/llvm -G Ninja -B /tmp/experiment -DCMAKE_BUILD_TYPE=Release' \
    --cleanup 'rm -rf /tmp/experiment'                                                                             \
    --export-markdown results.md
Command Mean [s] Min [s] Max [s] Relative
~/cmake/build/vanilla/bin/cmake ~/llvm-project/llvm -G Ninja -B /tmp/experiment -DCMAKE_BUILD_TYPE=Release 12.774 ± 0.113 12.591 12.928 1.10 ± 0.01
~/cmake/build/test/bin/cmake ~/llvm-project/llvm -G Ninja -B /tmp/experiment -DCMAKE_BUILD_TYPE=Release 11.635 ± 0.084 11.469 11.729 1.00

Topic-rename: ninja-performance

Edited by Brad King

Merge request reports

Loading