Zaid-Ajaj / Fable.Remoting

Type-safe communication layer (RPC-style) for F# featuring Fable and .NET Apps
https://zaid-ajaj.github.io/Fable.Remoting/
MIT License
273 stars 55 forks source link

performance: add a cache for UnionCaseInfo #128

Closed 0x53A closed 5 years ago

0x53A commented 5 years ago

closes https://github.com/Zaid-Ajaj/Fable.Remoting/issues/127

based on https://github.com/0x53A/FableRemotingSerializationTest/commit/a28e01203a518164367769ef4b4983c741ceb743

image

Question: Is using just a Dictionary safe, or could the instance be shared between Threads?

Edit: Answer: one instance is shared, so need to use ConcurrentDictionary

0x53A commented 5 years ago

huh, good thing you have tests. It seems the type-based caching doesn't work with struct unions, because all cases share one type.

0x53A commented 5 years ago

Same for union cases without fields.

0x53A commented 5 years ago

Ok locally tests are green and my use case is still fast:

image (https://github.com/0x53A/FableRemotingSerializationTest/commit/108a274e1b7b76b1b17a810441d472cb5dc389e2)

Zaid-Ajaj commented 5 years ago

Mind blown by these numbers :rocket: really awesome work @0x53A ❤️

Zaid-Ajaj commented 5 years ago

Updated and published all (server side) packages, should be available soon on nuget :smile:

0x53A commented 5 years ago

Thanks! I updated my app:

image

image

Now it is 44% processing, 54% serialization. Total time is maybe a second or so.

This is really good - for reference, this loads about a days worth of data.


And I think this is as good as it can get with Newtonsoft.Json, I couldn't find anything obvious:

image

So if performance were still an issue (it isn't for me), you could investigate System.Text.Json.

Zaid-Ajaj commented 5 years ago

Wohhoo awesome results! I doubt we will get a perf issue any time soon if it can handle so much data at once! Although I wonder what one could squeeze out the new JSON APIs