[web-devel] Issues with aeson encoding performance
Gregory Collins
greg at gregorycollins.net
Tue Aug 30 14:17:54 CEST 2011
On Mon, Aug 29, 2011 at 5:08 PM, Chris Smith <cdsmith at gmail.com> wrote:
> I know a lot of you use aeson for JSON encoding, and I get the feeling
> I'm doing something wrong here, so if you can give me some kind of a
> hint, I'd appreciate it.
>
> The aeson package description talks about getting up to around 40K
> messages per second from the encoding, but I'm pegging the CPU at 100%
> just trying to send 10 messages per second. Profiling (which is a REAL
> pain to reproduce, since the GHC API is involved... but I locally
> butchered a copy of the code enough to route around that) shows JSON
> serialization taking 98% of the CPU and doing 99.8% of allocations (on
> the order of 5 GB of total allocation if I leave it running for 15
> seconds). Heap profiling also shows the vast majority of the heap
> occupied by aeson's types (Value, Number, etc), and with huge spikes.
Dumb question: are the values you're encoding forced before you call
the JSON serialization function? If you have unevaluated thunks in
there, it could cause the profiler to misattribute the time to aeson.
G
--
Gregory Collins <greg at gregorycollins.net>
More information about the web-devel
mailing list