simd-json icon indicating copy to clipboard operation
simd-json copied to clipboard

Serializer and Deserialize derives

Open Licenser opened this issue 5 years ago • 3 comments

It might be worth looking into making more performant versions of the serialize and deserialize macro. Serde's implementation factors in different formats and by that comes with different tradeoffs if we focus on JSON it is likely that we can be significantly faster matching at least DOM object serialization speeds and improving deserialization speed further.

Licenser avatar Apr 13 '20 13:04 Licenser

I am wondering why doesn't struct outperform DOM since the details is available upfront and the compiler is able to optimize the code based on how it was structured, maybe because of the number of allocations needed?

pickfire avatar Apr 13 '20 16:04 pickfire

The Derive's serde have are generic over different formats, that greatly reduces the number of optimizations you can do and increases the number of indirection's required.

As a simple example field names in serde have to be escaped for every invocation since different encoders will need different encoding rules. A JSON specific serialisercan cache those names and reduce the needed interaction to a simple memcopy of "<encoded-field-name>": instead of having 4 writes and a encoding step

Licenser avatar Apr 13 '20 16:04 Licenser

Some first results on a serializer: image

Licenser avatar Apr 15 '20 21:04 Licenser

there is now simd-json-derive

Licenser avatar Sep 23 '23 15:09 Licenser