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

Use PooledByteBufferWriter to save 1K in trimmed System.Memory.dll #51896

Merged
merged 1 commit into from
Apr 27, 2021

Conversation

steveharter
Copy link
Member

Fixes #51571

Per that issue there was a ~1K regression.

Benchmark | Baseline | Test | Test/Base | Baseline IR | Compare IR | IR Ratio | Baseline ETL | Compare ETL
-- | -- | -- | -- | -- | -- | -- | -- | --
SOD - New Blazor Template - Publish - pub/wwwroot/_framework/System.Memory.dll.gz | 8.59 KB | 9.26 KB | 1.08
-- | -- | -- | --

Verified the ~1K savings locally (in self-contained trimmed console app):

Before: 35,840 bytes
After: 34,816 bytes

@ghost
Copy link

ghost commented Apr 26, 2021

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

Issue Details

Fixes #51571

Per that issue there was a ~1K regression.

Benchmark | Baseline | Test | Test/Base | Baseline IR | Compare IR | IR Ratio | Baseline ETL | Compare ETL
-- | -- | -- | -- | -- | -- | -- | -- | --
SOD - New Blazor Template - Publish - pub/wwwroot/_framework/System.Memory.dll.gz | 8.59 KB | 9.26 KB | 1.08
-- | -- | -- | --

Verified the ~1K savings locally (in self-contained trimmed console app):

Before: 35,840 bytes
After: 34,816 bytes
Author: steveharter
Assignees: steveharter
Labels:

area-System.Text.Json

Milestone: -

@@ -14,12 +12,15 @@ public abstract partial class JsonNode
/// <returns>JSON representation of current instance.</returns>
public string ToJsonString(JsonSerializerOptions? options = null)
{
var output = new ArrayBufferWriter<byte>();
using (var writer = new Utf8JsonWriter(output, options == null ? default(JsonWriterOptions) : options.GetWriterOptions()))
using (var output = new PooledByteBufferWriter(JsonSerializerOptions.BufferSizeDefault))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: the outer using statement can be written with the using var syntax to avoid one degree of nestedness.

@steveharter steveharter merged commit abdb7ed into dotnet:main Apr 27, 2021
@steveharter steveharter deleted the CollectionsSize branch April 27, 2021 17:59
@karelz karelz added this to the 6.0.0 milestone May 20, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Jun 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Blazor WASM] - Investigate 8% size regression in System.Memory.dll.br
4 participants