Skip to content
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

Developers can safely trim their apps which use System.Text.Json to reduce the size of their apps #45441

Closed
1 task
layomia opened this issue Dec 1, 2020 · 3 comments
Assignees
Labels
area-System.Text.Json Priority:1 Work that is critical for the release, but we could probably ship without Team:Libraries tracking This issue is tracking the completion of other related issues. User Story A single user-facing feature. Can be grouped under an epic.
Milestone

Comments

@layomia
Copy link
Contributor

layomia commented Dec 1, 2020

There's an ongoing effort (#1568) to use the C# source generator feature to improve start-up performance and reduce private bytes usage during JSON serialization. This same effort can help the linker trim more of System.Text.Json.dll, when used in an application, than it can today. This should reduce the total app size and is important for standalone apps and Blazor client.

Work

@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added area-System.Text.Json untriaged New issue has not been triaged by the area owner labels Dec 1, 2020
@layomia layomia removed the untriaged New issue has not been triaged by the area owner label Dec 1, 2020
@layomia layomia added this to the 6.0.0 milestone Dec 1, 2020
@layomia layomia added User Story A single user-facing feature. Can be grouped under an epic. tracking This issue is tracking the completion of other related issues. labels Dec 1, 2020
@danmoseley danmoseley added the Priority:1 Work that is critical for the release, but we could probably ship without label Dec 4, 2020
@layomia layomia self-assigned this Jan 24, 2021
@danmoseley
Copy link
Member

@layomia I changed this from Proposed to In progress. Hopefully that's correct. It's certainly committed.

@layomia
Copy link
Contributor Author

layomia commented Feb 16, 2021

@danmoseley - yup it's in progress, and we've started to get some numbers on potential size savings due to having source generation for JSON.

Now that we can generate code that statically references metadata on input object graphs, we can, based on a prototype linker feature switch (e.g. this snippet):

Size savings

This gives us some size savings, based on a simple console app.

Before: https://github.com/layomia/JsonSourceGenPerf/tree/main/SizeOpts/ConsoleBefore

After: https://github.com/layomia/JsonSourceGenPerf/tree/main/SizeOpts/ConsoleAfter

Pre-trimmed STJ.dll (KB) Trimmed STJ.dll (KB) Pre-trimmed App (MB) Trimmed App (MB) Pre-trimmed Application .dll (KB) Trimmed Application .dll (KB)
.NET 6 - S.T.J (Before) 866 (crossgen'd) 251 63.5 17.5 5 5
.NET 6 - S.T.J (After) 349 173 63.0 17.2 7 7
Summary
  • 78K savings to STJ dll size
  • 300K savings to app size

The major scenario we care about for size is Blazor applications. @tannergooding is helping take measurements and perform analysis for Blazor using the source generator.

@layomia
Copy link
Contributor Author

layomia commented Jul 23, 2021

With the JSON source generator checked in, we can consider this work done. Please see "Try the new System.Text.Json source generator" for an end-to-end overview of how the generator works and its benefits.

@layomia layomia closed this as completed Jul 23, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Aug 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Text.Json Priority:1 Work that is critical for the release, but we could probably ship without Team:Libraries tracking This issue is tracking the completion of other related issues. User Story A single user-facing feature. Can be grouped under an epic.
Projects
None yet
Development

No branches or pull requests

3 participants