You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was curious what the performance would be with serde_json's in-place deserialization so I created a custom deserializer for parser::Value. I had to duplicate parser::Value to use converted numbers since it wasn't possible to use this library's lazy numeric parser without replicating all of serde_json's parsing code.
The code for the custom deserializer is here. I updated the benchmarks to include this implementation, and also added a test for escaped strings.
Results from my macbook are below. serde_json_custom is the benchmark for the custom deserializer. string_escaped_chars is the benchmark for escaped strings.
string json_deserializer 2^10 time: [63.949 us 64.339 us 64.739 us]
string serde_json 2^10 time: [100.51 us 101.21 us 101.94 us]
string serde_json_custom 2^10 time: [41.162 us 41.491 us 41.923 us]
string simd_json 2^10 time: [25.250 us 25.574 us 25.932 us]
string_escaped_chars json_deserializer 2^10 time: [193.93 us 195.39 us 196.92 us]
string_escaped_chars serde_json 2^10 time: [130.26 us 131.22 us 132.27 us]
string_escaped_chars serde_json_custom 2^10 time: [137.42 us 138.47 us 139.55 us]
string_escaped_chars simd_json 2^10 time: [46.427 us 46.821 us 47.252 us]
I was surprised at the results, especially since nothing stuck out from inspecting the code. So I dug in further and it seems to come to the relatively large match expression in compute_length. Reworking it improved up the numbers:
string json_deserializer 2^10 time: [39.574 us 39.719 us 39.868 us]
string serde_json 2^10 time: [103.74 us 104.84 us 105.99 us]
string serde_json_custom 2^10 time: [46.926 us 48.188 us 49.584 us]
string simd_json 2^10 time: [27.517 us 27.786 us 28.105 us]
string_escaped_chars json_deserializer 2^10 time: [144.19 us 145.30 us 146.43 us]
string_escaped_chars serde_json 2^10 time: [143.75 us 144.64 us 145.52 us]
string_escaped_chars serde_json_custom 2^10 time: [145.71 us 147.09 us 148.73 us]
string_escaped_chars simd_json 2^10 time: [47.152 us 47.652 us 48.162 us]
If you're able to replicate the results and interested in taking the changes can open a PR. Changes are in this branch. Thanks!
The text was updated successfully, but these errors were encountered:
Great comparison and analysis, @ncpenke , very well though through.
interested in taking the changes can open a PR
Yes! That would be awesome!
I think that it would also be valuable to have the code from the branch implementing Deserialize under a serde feature flag. I am thinking doing the same for the trait Value as discussed in #3
Awesome work as usual @jorgecarleitao.
I was curious what the performance would be with serde_json's in-place deserialization so I created a custom deserializer for
parser::Value
. I had to duplicateparser::Value
to use converted numbers since it wasn't possible to use this library's lazy numeric parser without replicating all of serde_json's parsing code.The code for the custom deserializer is here. I updated the benchmarks to include this implementation, and also added a test for escaped strings.
Results from my macbook are below.
serde_json_custom
is the benchmark for the custom deserializer.string_escaped_chars
is the benchmark for escaped strings.I was surprised at the results, especially since nothing stuck out from inspecting the code. So I dug in further and it seems to come to the relatively large match expression in compute_length. Reworking it improved up the numbers:
If you're able to replicate the results and interested in taking the changes can open a PR. Changes are in this branch. Thanks!
The text was updated successfully, but these errors were encountered: