Jan 12

Stephan Menzel wrote today on the Boost developer mailing list (see here):

Lacking boost.log we created or own logging class which is basically an as-simple-as-possible Syslog client. (I like to process and accumulate there). It used to be boost.format to assemble the messages which proved slower than log4cxx. With Spirit 2.1 in 1.41 however we changed to use a Karma message generator for this purpose which improved speed dramatically.

Thanks Stephan! We are happy to hear that!

If you have other success stories while using Spirit, we would love to hear about your experience. Just leave a comment below, we happily will write about it.

5 Responses to “Karma ‘dramatically faster than boost::format’”

  1. Viet says:

    Hi Hartmut, congrats on good news and wider adoption of Boost.Spirit. May I ask you:

    1. Has Spirit 2.1 addressed code bloating?
    2. How much speed improvement since V2.0 and earlier version? I read some feedback on StackOverflow.com and decided to use Yard Parser by Chris Diggins.

    I like Spirit very much and would love to hear from you on compilation size and performance of the parser. Thank you very much!

    • Hartmut Kaiser says:


      1) I believe Spirit has never exposed any large code bloat besides the ‘normal’ template related issues. In fact we did some tests a while ago (with admittedly small grammars) showing code sizes near to the optimum. We have no concrete results comparing Spirit code with equivalent hand written code, though.

      2) Speedwise I can confirm Spirit V2 to be a lot faster than Spirit Classic. We have reports from different people confirming our own test results. I’d suggest to look through the mailing list archives looking for these reports (see here for an example: http://boost-spirit.com/home/2009/11/19/the-spirit2-advantage/). Others have posted about this on the web as well (see for instance: http://alexott.blogspot.com/2010/01/boostspirit2-vs-atoi.html). It would be interesting to see how Spirit performs compared to Yard today.

      Regards Hartmut

  2. Stephan says:

    Hi Hartmut,

    thanks for noticing. We do indeed have quite a few success stories in connection with karma and qi so far.
    The Log class being one of the last we transformed. Here, the topic of code bloat was interesting to witness. When we started we were facing a whole lot of boost.format based lines. All different, printing different formats depending on what the input structure had in terms of optional data. This was easy to understand but quite bloaty and also slow.

    After transforming this to karma it became faster (I recall factor 7 in release builds) and surprisingly enough the code became even less due to the wonders of boost.optional in connection with karma. It’s not as easy to understand anymore though but after I transformed our whole network protocol layer I just assume my reader to understand the basics. So that’s not as important anymore.



Leave a Reply

preload preload preload