Closed bklop closed 3 years ago
This is really cool @bklop 🔥 the code looks good too!
Will try to merge and publish soon 😄
Thanks! But take your time to review it for correctness 😄. I tested it on a proprietary application + I made sure all tests pass (obviously).
I made a benchmark project just for this, check it out here
The performance is insane 🔥 🔥 🔥
I made a large union (500 cases) and a large record (200 fields of type Map<LargeUnion, string>
) and tested the JSON handling against the current JSON library and your implementation:
$ dotnet run
Running operations 10 time(s)
Old (Serialization): 2335L ms on average
New (Serialization): 425L ms on average
Old (Deserialization): 87517L ms on average
New (Deserialization): 4L ms on average
Old (Full convertion): 81919L ms on average
New (Full convertion): 2L ms on average
PR merged and has been published into Fable.Remoting.Json v2.17 and all downstream packages that depend on it. Thanks a lot @bklop for the awesome contribution ❤️
Hi Zaid! I recently identified a performance issue when serializing one of our F# domain models. The performance issue was caused by many repeated reflection calls at runtime in the FableConverter.
The "worst case" seems to be large DUs as keys in a Map, with many items in the Map. Our model looks something like this:
I've made some performance improvements which basically boil down to:
For our domain model (basically the code structure mentioned above) we saw serialization time decrease from
450ms
to1.5ms
, which we're pretty happy with!