This change improves cold compilation of best's test suite from 8.296s to 6.030s on my machine, representing a 37% speedup. //best/container:span_test, my primary micro-benchmark whose timings I used to find optimization opportunities, went from 6.5s to 4.0s seconds as measured by Bazel.
To effect this change, I've made several optimizations that fall into the following categories:
Stop including unnecessary STL headers where possible.
Add special cases to best::pun, best::choice, and best::row to more quickly instantiate common specializations.
Move common BestFmt specializations into format.cc.
Stop using option::map() in helper functions used by lots of callers, especially in constexpr.
Hoist code out of templates that was not using all of that template's arguments. This brought big speedups for best::format().
There is probably more, but I'm satisfied for now. NB: I used bazel build --subcommands to extract a single clang call of interest, then ran time <clang command> -ftime-trace -ftime-trace-granularity=1 to get a flame graph of compilation time expenditure.
This change improves cold compilation of
best
's test suite from 8.296s to 6.030s on my machine, representing a 37% speedup.//best/container:span_test
, my primary micro-benchmark whose timings I used to find optimization opportunities, went from 6.5s to 4.0s seconds as measured by Bazel.To effect this change, I've made several optimizations that fall into the following categories:
best::pun
,best::choice
, andbest::row
to more quickly instantiate common specializations.BestFmt
specializations intoformat.cc
.option::map()
in helper functions used by lots of callers, especially in constexpr.best::format()
.There is probably more, but I'm satisfied for now. NB: I used
bazel build --subcommands
to extract a single clang call of interest, then rantime <clang command> -ftime-trace -ftime-trace-granularity=1
to get a flame graph of compilation time expenditure.