simd-lite / simd-json-derive

high performance Serialize and Deserialize derives
Apache License 2.0
32 stars 7 forks source link

Clarification: simd_json & serde-with compatibility #78

Closed JosiahParry closed 2 months ago

JosiahParry commented 8 months ago

I'm trying to take advantage of simd_json's support of serde compatible structs. However, I'm finding that there is no performance gains when using simd_json::serde::from_str or the slice equivalent.

Having seen the existence of this crate, I'm wondering if my use of serde_as and serde_with macros (example below) are causing simd_json serde to use the "unoptimized fallback implementation."

Would this be the case and would simd_json_derive assist here?

https://github.com/JosiahParry/serde_esri/blob/b36fb538c4f34fa4357acda0f8a756aac08f711f/src/features.rs#L51

JosiahParry commented 8 months ago

Reviewing other issues...I think it might be due to the lack of const generic support https://github.com/simd-lite/simd-json-derive/issues/52

Licenser commented 7 months ago

Puh that's quite hard to answer without a lot of context. There are a few general things to consider, and in some situations, simd_json isn't always faster than serve.

1) the size of the JSON might be so small that it makes no difference 2) parsing isn't what dominates the time, for example, if the conversion to a struct is more "expensive" than parsing (especially since serde_derive is somewhat expensive) 3) there are lots of floats their parsing is very expensive, and the algorithm between simd_json and serde isn't that different in performance

Generally you can't mix serde_derive and simd-json-derive (if you plan that), they are not compatible since they work very differently.