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

[Blazor WASM] - Investigate 6% size regression in System.Collections.dll.br #51572

Closed
SamMonoRT opened this issue Apr 20, 2021 · 5 comments · Fixed by #51717
Closed

[Blazor WASM] - Investigate 6% size regression in System.Collections.dll.br #51572

SamMonoRT opened this issue Apr 20, 2021 · 5 comments · Fixed by #51717
Assignees
Milestone

Comments

@SamMonoRT
Copy link
Member

Size increase in System.Collections.dll.br as observed in https://msit.powerbi.com/groups/me/apps/54e0e83f-07bc-45bf-87b7-a7677ff3af2a/dashboards/fa051820-ff60-4d40-8a08-bdcc1b47b1d0

image

cc @CoffeeFlux - is this worth investigating ?

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label Apr 20, 2021
@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@GrabYourPitchforks
Copy link
Member

Likely related to #51571. Seeing lots of infrastructure to support SortedDictionary and SortedSet coming back into the assembly. Will track down the callers.

image

@GrabYourPitchforks
Copy link
Member

I believe the code path below is responsible for this regression.

public bool Remove(string propertyName)
{
if (propertyName == null)
{
throw new ArgumentNullException(nameof(propertyName));
}
if (!Dictionary.TryGetValue(propertyName, out JsonNode? item))
{
return false;
}
bool success = Dictionary.Remove(propertyName);
Debug.Assert(success);
DetachParent(item);
return true;
}

In particular, on line 120, there's a call to Dictionary.Remove(string). However, the Dictionary property getter is typed as IDictionary<,>, backed by an IDictionary<,> field. This means that the linker needs to keep every possible implementation of IDictionary<,>.Remove around, and in the case of SortedDictionary<,> that means also keeping much of the SortedSet<> infrastructure around as well.

If the Dictionary property getter is changed to be a strongly-typed Dictionary<,> rather than an interface IDictionary<,> I believe this might resolve the issue, since the target method will now be statically known rather than a virtual dispatch.

@ghost
Copy link

ghost commented Apr 21, 2021

Tagging subscribers to this area: @eiriktsarpalis, @layomia
See info in area-owners.md if you want to be subscribed.

Issue Details

Size increase in System.Collections.dll.br as observed in https://msit.powerbi.com/groups/me/apps/54e0e83f-07bc-45bf-87b7-a7677ff3af2a/dashboards/fa051820-ff60-4d40-8a08-bdcc1b47b1d0

image

cc @CoffeeFlux - is this worth investigating ?

Author: SamMonoRT
Assignees: -
Labels:

area-System.Text.Json, untriaged

Milestone: -

@layomia
Copy link
Contributor

layomia commented Apr 21, 2021

cc @steveharter. This overlaps with the effort to use a strongly-typed sorted dictionary to store JsonObject values (to preserve insertion order when enumerating over the object).


That aside, this is related to #51311 and my comment here #51571 (comment).

@layomia layomia removed the untriaged New issue has not been triaged by the area owner label Apr 21, 2021
@layomia layomia added this to the 6.0.0 milestone Apr 21, 2021
@steveharter steveharter self-assigned this Apr 21, 2021
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Apr 22, 2021
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Apr 28, 2021
@ghost ghost locked as resolved and limited conversation to collaborators May 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants