Subscribe to
Posts
Comments

I’ve spent some time over the past few weeks improving the performance of the attoparsec parsing library, and of the aeson JSON library. Since they’ve now reached a new plateau of performance and stability, I thought this would be a good time to release new versions.

The major advance in the new version of aeson is a considerable speed improvement.

Performance improvement

The datasets I’m using are Twitter search results, from the Twitter JSON search API. For mostly-English results, 0.2.0.0 is up to 30% faster than before, while on Japanese data (which makes heavy use of Unicode escapes), I’ve bumped performance by more than 50%.

To see how well aeson performs compared to JSON parsers for other languages, I compared it against the json module in Python 2.7. That module’s JSON parser is written in C, so it’s very fast indeed, and the amount of actual Python being executed in my microbenchmark is tiny. How do we fare?

JSON parsing performance

On mostly-English data, aeson is actually faster than Python’s native-code json parser. Nice! And on Japanese data, we’re a little slower, but still very competitive.

What if you’ve been using the Haskell json package, which was the first open source Haskell JSON parser to be published? Well, I do think that aeson is easier to use, but it’s also 3x faster than the json package:

aeson vs json

The new version of aeson introduces some other useful improvements.

  • There’s a new Generic module, which lets you convert almost any instance of the Data typeclass to and from JSON without writing boilerplate code. (Be warned: generics are slow. If performance is important to you, write that boilerplate!)
  • We introduce a Number type that represents integers to full accuracy, and which handles floating point numbers efficiently.
  • Instead of parsing via the Applicative typeclass, we now use a custom parsing monad, improving both ease of use and performance.

I’m delighted to say that after a couple of years of a break from the startup world (which I’ve inhabited for most of the past decade), I’ve decided to throw my hat back into the ring. Together with Bethanye Blount, I’ve started a company named MailRank. We’re working on helping people to manage the all-too-common problem of email overload. You can read a little more about what we’re up to in our initial announcement, and we’ll have more details to share soon.

Since I’ve spent the past two decades in the world of open source, of course I have goodies to show off:

  • A fast, powerful library for working with the Riak decentralized data store (mailrank/riak-haskell-client on github). I think it’s the best Riak client library available for any programming language :-)
  • An efficient, easy to use JSON library for Haskell (mailrank/aeson on github). Twice as fast as the competition.
  • I’m excited to be working with Bethanye once again, and thrilled that we’re going to have our first employee join in ten days.
  • text 0.10.0.0 is here

    Peter Seibel (the man behind Practical Common Lisp) is launching a new publication, Code Quarterly, which looks intriguing to me. He’s hoping to run a coding challenge in each issue, and I know this is the sort of fun dear to many a coder’s heart. The first coding challenge has been up for a couple of weeks, and it involves implementing a parser for Markup, a lightweight markup language similar to Markdown and reStructuredText.

    Peter writes:

    In fact the idea for this code challenge came to me when I was implementing this code myself (in Common Lisp) and I started thinking about how I’d like to try writing it in Haskell and then I thought what I’d really like is to see how someone who knows what they’re doing would write it in Haskell.

    If coding competitions are your thing, toss your hat into the ring and enjoy! I’m looking forward to seeing how Code Quarterly shapes up. I suspect there’s plenty of appetite out there for hacking-related articles of a length and depth somewhere between a blog posting and a book chapter. Best of luck to Peter with what I think is a fine idea.

    « Prev - Next »