[Haskell-cafe] Fast JSON validation - reducing allocations
dct25-561bs at mythic-beasts.com
Sat Jul 1 19:07:46 UTC 2017
Just thought I'd follow up now that we've upgraded from GHC 7.10 to GHC
8.0.2 (not 8.2 yet) and are now seeing this code validate the 900-byte
sample document in <8us with <220 bytes of allocation. This is awesome. I'm
not sure what we did to get 8.0.2 to realise it could make the loop this
tight, and I'll look into it some more if I have the time and the
There's been various changes since my OP, although nothing fundamental: a
bug fix, support for insignificant whitespace, and removal of bounds checks
on the arrays. We now pass the test suite from the appendix of
http://seriot.ch/parsing_json.php (except for the ones for bare values - we
only want arrays or objects).
Thanks again for everyone's help.
On 12 May 2017 at 16:47, Ben Gamari <ben at smart-cactus.org> wrote:
> Mikolaj Konarski <mikolaj at well-typed.com> writes:
> > Truly impressive. Amazing.
> > I wonder what style of coding of inner loops
> > leads to such good results in 8.2. Is it easy to describe?
> > Or is the answer "any" or "simplest" or "natural"? If not,
> > can it be captured as some recursion combinators perhaps?
> My fairly unhelpful description would be that carefully-written programs
> that look like they shouldn't allocate will be helped most. Previously
> these program (e.g. probably the one here) would allocate closures due
> to GHC's failure to identify some types of join points. In 8.2 our
> treatment of join points is more robust and consequently this
> unnecessary allocation will be more reliably eliminated.
> - Ben
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe