
Zach Laine wrote:
I'm shocked too. That's really crazy. Believe me, I'm not interested in merging something with orders of magnitude of perf overhead into Boost. I will be getting to the bottom of this long before a merge could take place.
My profiler (VS2022) says that the top performance problem is the construction of a stringstream here https://github.com/tzlaine/parser/blob/f99ae3b94ad0acef0cc92166d5108aade41da... This constructs a std::locale, which is apparently very slow. When I fix it diff --git a/include/boost/parser/detail/printing.hpp b/include/boost/parser/detail/printing.hpp index 1e204796..6cbec059 100644 --- a/include/boost/parser/detail/printing.hpp +++ b/include/boost/parser/detail/printing.hpp @@ -621,11 +621,19 @@ namespace boost { namespace parser { namespace detail { flags f, Attribute const & attr) { - std::stringstream oss; if (detail::do_trace(f)) + { + std::stringstream oss; detail::print_parser(context, parser, oss); - return scoped_trace_t<Iter, Sentinel, Context, Attribute>( - first, last, context, f, attr, oss.str()); + + return scoped_trace_t<Iter, Sentinel, Context, Attribute>( + first, last, context, f, attr, oss.str()); + } + else + { + return scoped_trace_t<Iter, Sentinel, Context, Attribute>( + first, last, context, f, attr, {}); + } } template<typename Context, typename Attribute> the top function becomes the constructor of scoped_trace_t. (It's probably not getting inlined.) Looks like the tracing functionality costs a lot even when off.