A new week, a new JSON performance improvement

It’s been a few weeks since I last wrote about the aeson library for working with JSON in Haskell, but this isn’t because I’ve been idle. In fact, just tonight I put out a new release. Where the previous releases focused on parsing performance, this one focuses on encoding performance.

And the performance news is good: on real-world data, I’ve improved encoding performance by about a factor of 4. Why don’t we let the graphs do the talking.

Encoding performance

Enjoy!

Posted in haskell, open source
5 comments on “A new week, a new JSON performance improvement
  1. Holger says:

    Thanks for the amazing work.
    Unfortunately, there seems to be a bug in the new version. If I enter “encode $ Number 200″ the result is “0D”, where the old version correctly returned “200”.

  2. Holger, oops! You’re right. I swapped a “quot” and a “rem” by accident. I’ve released 0.3.2.1 and added a QuickCheck test suite, so this shouldn’t happen again :-)

  3. Simon Meier says:

    Thats a very nice improvement. As you’re using the blaze-builder library, I had a go at converting your string encoding to use the ‘Write’ construction:

    https://github.com/meiersi/aeson/commit/328777ef0ad1e1e9d7a730bd16753384db5f5ec0

    Together with a function for efficiently serializing Text values using the internals of your Fusion framework, which I just exported in a local dev version

    https://github.com/meiersi/aeson/commit/1bcd9f7605cf61abe2faf7ff53b1f8aa91fd3f48

    this results in another 50% speedup on your newly released aeson-0.3.2.0 library:

    https://gist.github.com/881389

    The current code is not as nice as it could be, as it defines functions that were better provided by the ‘text’ or ‘blaze-builder’ libraries. Especially, for the second patch, I’m not sure, if it should be included in aeson right now. The integration of the ‘blaze-builder’ work into ‘bytestring’ will solve these issues. However, progress is steady but not all too fast on that side.

  4. Simon, those performance improvements look great!

    I think that the fromWriteText function would be best in blaze-builder, as I can’t add it to text due to the dependency it would add on a non-platform library.

    Let me know when you release a new blaze-builder with that addition, as the added performance would be fabulous to have. What version of GHC are you benchmarking with, by the way?

  5. Simon Meier says:

    Hi Bryan,

    I’m benchmarking on a Core 2 Duo 2.2 GHz using GHC 7.0.2.

    The problem with the ‘fromWriteText’ function is that it depends on the hidden ‘Text.Fusion’ module. Hence, I first need an updated version of the ‘text’ library. Once, you expose this module, I’ll add it to blaze-builder.

    The ‘hex’ functions will have to wait with respect to blaze-builder. The plan is to incorporate them only in the new ‘bytestring’ library. Otherwise, my forces are getting spread too thin.

    BTW: Could you send me a mail when you respond? I was hoping your blogging system would do that automatically, but it is not.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>