jdegoes/blueeyes — pull request #121 by non (2013-05-09 18:44:12+00:00)
Title: Fix major problems in the AsyncParser design.

The async parser was introduced to handle a very specific use case:
parsing a (whitespace delimited) stream of relatively small (<1M) JSON
objects. Its design, buffering strategy, and strategy for resuming
parsing were all based on this scenario. In scenarios where the user
wanted to use many small chunks to parse a much larger value (i.e. 60M)
parser performance would degrate horribly compared to the synchronous
(all-at-once) parser.

Furthermore, the error-recovery strategy was based around similar
assumptions, and was not reliable in general (without frim commitments
from the user about delimiters and escaping it is hard to see how it
could be).

This commit does several things:

1. Fix the major performance problems seen when async parsing one
large value. While this is still not an ideal situation,
performance is now roughly on-par with the equivalent sync parser.

2. Remove the error-recovery option for the AsyncParser. It didn't
work reliably and was not being relied on by anyone.

3. Create 3 different async parsing modes:

a. Streaming: This is the existing behavior (returning a collection
of whitespace-delimited JSON values).

b. Json: This mode expects the input to be a single well-formed
JSON value. In the future this should become the default
behavior.

c. Unwrapping: This mode is like (b) but if the JSON value is an
array, the parser will instead parse the contents of the array
as a stream and return those values, rather than the outer
array.

Mode (c) is especially exciting, since for situations where users
need to parse very large arrays of values. Unlike the sync parser
(or the async parser in modes (a) and (b)) unwrapping means that
the parser itself does not need to accumulate and store all the
parsed objects itself.

4. The commit adds some additional tests and benchmarks to measure the
performance of these parsers.

None of the synchronous parsers should be affected by these changes.