-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Blazor Wasm - Size regression in System.Text.Json.dll #51311
Comments
Tagging subscribers to 'arch-wasm': @lewing Issue DetailsSystem.Json.Text.dll,br has a big spike in last two days as observed in https://msit.powerbi.com/groups/me/apps/54e0e83f-07bc-45bf-87b7-a7677ff3af2a/dashboards/fa051820-ff60-4d40-8a08-bdcc1b47b1d0
|
@eerhardt suggested that these 2 changes are possible offenders |
These two changes are primarily The JSON source generator will help reduce size for apps that use the new overloads that take pre-generated metadata (#51300). The converters for these features will be trimmed out if not needed in an app, and if the new serializer methods are used instead of the existing ones. I don't expect the size regression here to be reversed until the JSON serialization logic within Blazor assemblies is refactored to use the new serializer methods. See these commits for an early attempt. Happy to help with this effort. |
Thanks @layomia - do we know if there is any tracking issue for the refactoring work ? |
cc @mkArtakMSFT - is this on your team ? |
Want to put this note out, to make it very clear - We don't expect any changes from dotnet/aspnetcore#31877 to be backported to Preview 4. But we need to make sure the necessary work has a timeline to make it in quickly. |
One potential path to reduce size as new features (and converters) are added is to initialize internal class MyCustomContext : JsonSerializerContext
{
public MyCustomContext(JsonSerializerOptions options) : base(options) { }
// Also possible to cache\expose the JsonTypeInfos here...
}
JsonSerializerOptions options = new JsonSerializerOptions;
options.Converters.Add(JsonConverters.String);
options.Converters.Add(JsonConverters.Int32);
options.Converters.Add(JsonConverters.JsonNodeConverterFactory);
// etc
var context = new MyCustomContext(options);
JsonNode node = ...
JsonSerializer.Serialize(node, context); |
Assigning to @layomia for tracking based on additional work building over the JSON SourceGenerator work |
Following up on offline discussions on email, I'm noting on this issue that the path to reducing the regression here will not be about Blazor fully adopting the JSON source generator internally and in the default template (dotnet/aspnetcore#31877). Size is important for Blazor, but it was discussed that the generator should focus on trim safety (already supported), and improve (de)serialization throughput (in progress with #51945). For mitigating the size regression here, this issue will instead focus on internal System.Text.Json changes to reduce the assembly size when source gen is not used:
cc @SamMonoRT @CoffeeFlux @eerhardt @steveharter @ericstj @SteveSandersonMS @pranavkm @jkotas |
Is there any remaining .NET6 work here? |
I believe there's no work left here for 6.0 given the above plan #51311 (comment). cc @eerhardt |
I think we can close this issue now? |
System.Text.Json.dll.br has a big spike in last two days as observed in https://msit.powerbi.com/groups/me/apps/54e0e83f-07bc-45bf-87b7-a7677ff3af2a/dashboards/fa051820-ff60-4d40-8a08-bdcc1b47b1d0
@eerhardt @CoffeeFlux
The text was updated successfully, but these errors were encountered: