-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider fast-path deserialization logic in JSON source generator #55043
Comments
Tagging subscribers to this area: @eiriktsarpalis, @layomia Issue DetailsIn #51945, we addressed a mode in the JSON source generator that generates optimized serialization logic using
|
|
Could be worth investigating IMHO but I am sure there subtleties to the deserialization problem that makes it hard to create a one size fits all generated version. Perhaps there is value to generate a version that works in many use cases but also allow the metadata driven version when flexibility is required. From my testing the overhead when using a static deserializer fell significantly but as the JSON parsing process itself takes sometime the overall performance gain is not as good. |
Consider honoring |
Quite often we have project requirements of consuming external API's where data is provided as JSON strings, so we don't have the luxury of serializing our own data for better downstream performance. Some community driven projects seem to indicate that there are further possibilities of improving deserialization performance from JSON string data. Below are some benchmarks using very simple data. Some of these community driven projects have since been abandoned or don't handle new types so SystemTextJson is always the safest option but it would be nice to have improved performance. BenchmarkDotNet=v0.13.5, OS=Windows 11 (10.0.22621.1265/22H2/2022Update/SunValley2)
SourceGenTest.csproj:
Program.cs:
|
In #51945, we addressed a mode in the JSON source generator that generates optimized serialization logic using
Utf8JsonWriter
directly. We should consider a similar mode for deserialization usingUtf8JsonReader
directly.The text was updated successfully, but these errors were encountered: