|
Boost : |
Subject: Re: [boost] C++ Networking Library Release 0.5
From: Edouard A. (edouard_at_[hidden])
Date: 2010-02-02 03:56:04
>Coroutines could work, though I doubt the complexity (e.g. using yielding
>iterators with Spirit) or performance will be any better than simply using
a
>FSM-based parser.
Yesterday I tried to switch our server's custom parser to Spirit. Our custom
parser is extremely fast and does 0 allocation, but I was ready to take a
moderate performance hit to gain in readability and maintainability.
The problem we have is that if we want to add more features to our custom
commands - note, this is not a web server, this is something much more
simpler - it will make the code more complex whereas in Spirit it will just
be a matter of adding new rules without adding any new dependencies (we
already use boost, so the library is in our build and release chain).
In addition, I love the way Spirit tackles the problem.
Unfortunately, I forgot I spent a certain amount of time optimizing our
custom parser to be a zero-copy, zero-allocation parser (not to mention a
fair deal of mpl to have basically very little code at runtime). Basically,
the current parser spits out a pair of read-only pointers for each block you
want to work on when with Spirit the straightforward way implies creating a
string, which means in many case making a dreaded memory allocation (yes, I
have a problem with this :p).
Maybe MSM is more suited for that kind of tasks. I also want to mention that
I'm a noob when it comes to Spirit so perhaps with more magic one could
achieve results closer to our custom parser. When our version one is
released, I will work more on that custom parser vs MSM vs Spirit thingy and
let you know.
Generally speaking I think it is worth spending some time with Spirit
because writing a grammar to parse input is an order of magnitude easier to
maintain than writing a custom parser. I'd also want to point out that MSM
will soon land in Boost and it is a viable alternative for this kind of
problems.
-Edouard
__________ Information from ESET NOD32 Antivirus, version of virus signature
database 4826 (20100202) __________
The message was checked by ESET NOD32 Antivirus.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk