Boost logo

Boost :

Subject: Re: [boost] [xpressive] Performance Tuning?
From: OvermindDL1 (overminddl1_at_[hidden])
Date: 2009-07-27 20:17:54


On Mon, Jul 27, 2009 at 1:34 PM, Stewart, Robert<Robert.Stewart_at_[hidden]> wrote:
> Joel de Guzman wrote:
>> Stewart, Robert wrote:
>>
>> > When* I have the opportunity, I will extract the code that
>> > exists in different files and libraries, and craft a custom
>> > version of the scaffolding necessary to make my Xpressive and
>> > custom code compile and which will reflect what I was
>> > actually running when I gave comparative results.
>>
>> Thank you, Robert.
>
> Alright folks.  I've finally extracted all of the necessary pieces and assembled them into a single main.cpp plus test inputs file.  You can find them here:
>
>   http://tinyurl.com/price-parsing-7z

Awesome. I will integrate my Spirit2.1 version into it and run the
test and all so forth as well. Once I confirm that my Spirit2.1
version tests correct then I will run the timings.

On Mon, Jul 27, 2009 at 1:34 PM, Stewart, Robert<Robert.Stewart_at_[hidden]> wrote:
>
> I have not supplied any build files as our local build system is unique and I don't know bjam.

I will just dump it all into Visual Studio and let it munch on it.

On Mon, Jul 27, 2009 at 1:34 PM, Stewart, Robert<Robert.Stewart_at_[hidden]> wrote:
> The structure of main.cpp is as follows, with each section delimited by comments with lots of vertical pipes:
>
>  0. A hopefully portable definition of int64_t extracted from boost/cstdint.hpp (is there a better option for this that I missed?)

That is what is supposed to be used for multi-platform integers with
64-bit width. :)

On Mon, Jul 27, 2009 at 1:34 PM, Stewart, Robert<Robert.Stewart_at_[hidden]> wrote:
>  1. Forward declarations of the three parse functions (with functors to permit injecting the parse functions into the run_test function template)
>
>  2. Some core and testing namespace forward declarations for main()
>
>  3. main()
>
>  4. More core declarations needed for the custom string and Xpressive variants
>
>  5. core and testing namespace function definitions
>
>  6. Custom string parser implementation
>
>  7. Xpressive parser implementation
>
>  8. Spirit parser stub

I will duplicate the spirit stub three times so I can put in all three
version I made for proper comparison.

On Mon, Jul 27, 2009 at 1:34 PM, Stewart, Robert<Robert.Stewart_at_[hidden]> wrote:
> I put include directives needed for main(), the test harness, and the core namespace at the top.  Others, peculiar to a particular parser appear in that parser's section of the file.
>
> The custom, string parser and my final Xpressive parser are included.  Note that xpressive_parsing::match_s is commented out and that xpressive_parsing::parse()'s match_s is a function local static because I don't have Boost.Threads built locally.  Remove the function local static and uncomment the match_s lines to use TLS for match_s, a necessary condition for a fair test.
>
> I have not supplied a Spirit v2 implementation.  Someone else will need to provide that.  Note that the code must be reentrant.  When I was working this problem, I was constrained to use Boost 1.37.  It would be useful to know if there is a performance difference between Boost 1.37 and 1.39 for Xpressive and Spirit v2.

I will supply the Spirit2.1 implementation, due note that regardless
of your version of boost, it will require that you pull Spirit out of
the boost trunk, but Spirit2.1 pulled out of trunk should work fine
with Boost 1.37 and up. If you wish I could bcp it out though, but
that would add a ton of files to this simple test. :)

On Mon, Jul 27, 2009 at 1:34 PM, Stewart, Robert<Robert.Stewart_at_[hidden]> wrote:
> main() takes two arguments: the pathname of the test inputs and the number of times to run through the inputs.  On my system, parsing all of the inputs once took less than a second.  When I ran my code, with 100 iterations, the Xpressive version, with the function local static match_s, was 9X slower than the custom code.  That is worse than I saw in my more trivial tests previously.

I might also duplicate the xpressive test too, one for threadsafe, one
not. I do not know xpressive well though so it will be a mostly
simple copy.

I am curious to see how well Spirit2.1 handles this.

On Mon, Jul 27, 2009 at 1:34 PM, Stewart, Robert<Robert.Stewart_at_[hidden]> wrote:
> The test inputs are arranged one test to a line, with the input to parse quoted and whitespace separated from the expected int64_t result.
>
> Let the optimizing begin!

Hear hear!

I should be able to get to it tonight after work.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk