25 Feb
2019
25 Feb
'19
3:18 p.m.
https://github.com/pdimov/variant2/blob/develop/benchmark/benchmark1.md
John Elvind Helset reports (via Slack) that using -DBOOST_VARIANT_VISITATION_UNROLLING_LIMIT=1 with Boost.Variant results in significant runtime improvement on both g++ and Clang, to the point where Boost.Variant consistently outperforms both variant2 and std::variant on this specific benchmark. Looking at the code, it seems to me that the switch statement is always unrolled to the default of 20 even when the variant doesn't have as many alternatives, which causes Clang to refuse to inline the visitation and results in a performance loss.