-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Potential size reduction opportunities in System.Text.Json NativeAOT #80917
Comments
Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis Issue DetailsThe PR in #80755 attempted to reduce the size of System.Text.Json components in trimmed NativeAOT binaries. The per-namespace breakdown in #80755 (comment) shows that there might be opportunity to further reduce application size in the
|
Tagging subscribers to 'size-reduction': @eerhardt, @SamMonoRT, @marek-safar Issue DetailsThe PR in #80755 attempted to reduce the size of System.Text.Json components in trimmed NativeAOT binaries. The per-namespace breakdown in #80755 (comment) shows that there might be opportunity to further reduce application size in the
|
Shouldn't the split into source-gen/reflection help eventually? I'd assume if you use source-gen all ReflectionJsonTypeInfo should get trimmed away (and reverse). Should we strive into that actually happening if it's not currently? |
Other option we can move all the reflection logic to DefaultJsonTypeInfoResolver and keep JsonTypeInfo clean. That should achieve same effect and might actually be easier to achieve |
The derived types aren't necessary and because they are generic they contribute to a linear increase of application size in NativeAOT apps. There should eventually be one sealed |
The PR in #80755 attempted to reduce the size of System.Text.Json components in trimmed NativeAOT binaries. The per-namespace breakdown in #80755 (comment) shows that there might be opportunity to further reduce application size in the
System.Text.Json.Serialization.Metadata
namespace, which currently occupies approximately 600k in the Golidlocks app. More specifically, the metadata layer introduces overhead in a couple of ways:JsonTypeInfo<T>
implementations for source gen and reflection. This segregation largely exists for historical reasons and it could be removed, decouplingJsonTypeInfo<T>
metadata from contract resolution behavior.JsonTypeInfo
metadata using theJsonMetadataServices
APIs as a proxy. This happens because the source generator predates the public APIs onJsonTypeInfo
itself. The proxy API introduces a number of generic classes such asJsonCollectionInfoValues<T>
,JsonObjectInfoValues<T>
andJsonPropertyInfoValues<T>
. All these types could be trimmed if we updated the source generator to call into theJsonTypeInfo
APIs directly. Note that this is currently blocked by Add support for parameterized constructors in System.Text.Json contract customization (converters) #71944, the only remaining configuration point available inJsonMetadataServices
but not yet present inJsonTypeInfo<T>
.cc @eerhardt @krwq @layomia
The text was updated successfully, but these errors were encountered: