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

System.Xml.XmlCharType size improvements #944

Open
marek-safar opened this issue Feb 22, 2019 · 10 comments
Open

System.Xml.XmlCharType size improvements #944

marek-safar opened this issue Feb 22, 2019 · 10 comments
Labels
area-System.Xml enhancement Product code improvement that does NOT require public API changes/additions size-reduction Issues impacting final app size primary for size sensitive workloads tenet-performance Performance related issue
Milestone

Comments

@marek-safar
Copy link
Contributor

System.Xml.XmlCharType has dependency on 64K big binary blob XmlCharType.bin to do xml characters type detection. This dependency is hard for illinker to remove and also looks like something what could be implement differently.

There are also static methods like IsSurrogate which are just duplicates of char methods implementation and could probably be removed completely.

@danmoseley
Copy link
Member

@marek-safar I imagine there will be many more issues over the next few months relating to linker optimization. How about I create a github project to collect them all.

@marek-safar
Copy link
Contributor Author

@danmosemsft yes, that's very likely. I don't know how you usually do it if via Projects, umbrella issue or something else

@danmoseley
Copy link
Member

OK, added this to a new project. Feel free to put any others there.

@maryamariyan maryamariyan transferred this issue from dotnet/corefx Dec 16, 2019
@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added area-System.Xml untriaged New issue has not been triaged by the area owner labels Dec 16, 2019
@maryamariyan maryamariyan added enhancement Product code improvement that does NOT require public API changes/additions tenet-performance Performance related issue labels Dec 16, 2019
@maryamariyan maryamariyan added this to the Future milestone Dec 16, 2019
@ericstj ericstj added the linkable-framework Issues associated with delivering a linker friendly framework label May 20, 2020
@ericstj ericstj modified the milestones: Future, 5.0 May 20, 2020
@ericstj
Copy link
Member

ericstj commented May 20, 2020

Seems like a good case for using this feature: dotnet/roslyn#24621

EG: dotnet/coreclr#26138

/cc @eerhardt

@ericstj ericstj removed the untriaged New issue has not been triaged by the area owner label May 20, 2020
@vitek-karas
Copy link
Member

I vaguely remember that in the early days of System.Xml we used to generate this table into memory on init. But it turned out to be faster to simply map it from disk.
Anyway, the code to generate it is still there:

The mapping of constants into memory won't help with the size, since we would still need the 64KB array as a constant value in the assembly - basically it would be a nicer way to do the resource thing we're doing today.

For linker we would need to do this via a feature switch and in that case drop the resource and instead use the CPU to generate it on init. Would mean to include the generation code always, but it's really small.

Technically it's possible to not have the 64KB table at all, but it REALLY helps with XML parser perf, so I think we should keep it.

@buyaa-n
Copy link
Contributor

buyaa-n commented Jul 8, 2020

It doesn't seem to we could get it done within 5.0, moving to 6.0

@buyaa-n buyaa-n modified the milestones: 5.0.0, 6.0.0 Jul 8, 2020
@ericstj
Copy link
Member

ericstj commented Jul 9, 2020

@eerhardt is it OK to move this or do we need it for 5.0 browser scenarios?

@vitek-karas I wasn't suggesting a constant: I was suggesting a field that could be trimmed if it wasn't used. My understanding of the issue was that the linker doesn't know how to trim a resource, but it would know how to trim a field. The fact that we can have spans of this gives us good perf on access. Do you think it's ok for perf to regress perf of XML to save 64 KB in this case? I guess it depends on how bad the perf is to generate the table in browser.

@eerhardt
Copy link
Member

eerhardt commented Jul 9, 2020

is it OK to move this or do we need it for 5.0 browser scenarios?

As of right now, System.Xml isn't brought into a Blazor WASM app by default and I don't know of important scenarios that would require XML in Blazor WASM. So I don't feel it is strictly necessary for 5.0, unless someone makes a case for why XML is critical in Blazor WASM. I think it is fine to address this in 6.0.

@vitek-karas
Copy link
Member

@ericstj currently linker can only trim resources "unconditionally" (behind a feature switch), so you're right about that. If it's a field which linker can trim along with its large value that would be much better. Ultimately though (as far as I remember my XML days), pretty much everything in System.Xml will end up accessing this field anyway. So if we want to reduce size of apps using XML generating the table on init would be the ideal solution for size. Performance is obviously a concern - we would have to measure that.

@marek-safar marek-safar added size-reduction Issues impacting final app size primary for size sensitive workloads and removed linkable-framework Issues associated with delivering a linker friendly framework labels Dec 9, 2020
@eerhardt eerhardt modified the milestones: 6.0.0, Future May 11, 2021
@eerhardt
Copy link
Member

Moving to 'Future' as this isn't a high priority for 6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-System.Xml enhancement Product code improvement that does NOT require public API changes/additions size-reduction Issues impacting final app size primary for size sensitive workloads tenet-performance Performance related issue
Projects
No open projects
Development

No branches or pull requests

8 participants