reflex-frp / reflex-platform

A curated package set and set of tools that let you build Haskell packages so they can run on a variety of platforms. reflex-platform is built on top of the nix package manager.
https://reflex-frp.org
BSD 3-Clause "New" or "Revised" License
719 stars 164 forks source link

Recommend GHCJS serialization library #547

Open johannesgerer opened 4 years ago

johannesgerer commented 4 years ago

Could reflex-platform devs/users share their experiences with different serialization libraries?

Is there a clear winner?

Thanks

3noch commented 4 years ago

That's a bit hard to answer as is. What kind of serialization use case do you have in mind?

johannesgerer commented 4 years ago

For example a Haskell REST Api serving Haskell data structures to a GHCJS powered client.

johannesgerer commented 4 years ago

I settled for persist after consulting this benchmark, and excluding platform-dependent encoding and flat which could not be compiled on reflex-platform's GHCJS out-of-the-box.

I also tested browsers JSON.parse followed by fromJSVal_aeson, but only saw 2x speedup and ended up preferring the non-FFI solution.

I see significant 10x speedups in my usecase where GHCJS-compiled JS requests Haskell Values generated on and to be serialized by a Haskell server and de-serializes it back into Haskell values.

Deserialization time went from 4s using Aeson (4MB serialized JSON) down to 0.4s when using Persist (3MB serialized).

3noch commented 4 years ago

Wonderful data! Thanks!

3noch commented 4 years ago

To clarify, you found that persist was fastest but persist uses a binary format. You mention that your usecase uses JSON. I don't understand how persist helps here.

johannesgerer commented 4 years ago

You are right, see my updated response