Subject: Re: [boost] [xpressive] Performance Tuning?
From: Stewart, Robert (Robert.Stewart_at_[hidden])
Date: 2009-07-27 15:34:10
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:
I have not supplied any build files as our local build system is unique and I don't know bjam.
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?)
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()
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 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.
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.
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!
Rob Stewart robert.stewart_at_[hidden]
Software Engineer, Core Software using std::disclaimer;
Susquehanna International Group, LLP http://www.sig.com
IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk