microsoft / STL

MSVC's implementation of the C++ Standard Library.
Other
9.94k stars 1.46k forks source link

benchmark: it is built with `/Ob1`, so vector algorithm dispatcher is noticeable #4496

Open AlexGuteniev opened 4 months ago

AlexGuteniev commented 4 months ago

Noticed while working #4495 . When I decided to use sized if constexpr dispatch, instead of using the same version for all element sizes, I observed significant perf degradation for small element sizes. A part of it is due to not inlining the dispatcher.

The benchmark is built with /Ob1. Looks like it is implied due to CMake RelWithDebugInfo configuration, as opposed to Release.

What are our takeaways?


I see the following options:

StephanTLavavej commented 3 months ago

We talked about this at the weekly maintainer meeting and @barcharcraz had a suggestion - build as Release, but then add compiler options (e.g. /Zi) to generate debug info.

https://github.com/microsoft/STL/blob/8e2d724cc1072b4052b14d8c5f81a830b8f1d8cb/benchmarks/CMakeLists.txt#L62-L65

Charlie was additionally concerned that we shouldn't be trying to force the build type here - it would be better to provide a default that can be overridden when building the benchmarks, if a contributor temporarily wants something different. We don't immediately know the proper incantations for that.