Skip to content

Conversation

@marek-safar
Copy link
Contributor

@marek-safar marek-safar commented Jul 9, 2020

Example of size reduction on SPC with the most minimalistic Hello
World console sample.

System.Private.CoreLib Size (kB) Delta
Trimmed Before 1358 kB
Trimmed After 1271 kB -87 kB

Trimming the CarChecker app with this change results in

CarChecker Size Delta
Trimmed Before 3,584,512 bytes
Trimmed After 3,474,432 bytes -108 kB
Trimmed After with removing CompilerGenerated 3,453,952 bytes -128 kB

@eerhardt @vitek-karas

Example of size reduction on SPC with the most minimalistic Hello
World sample.

| System.Private.CoreLib | Size (kB) | Delta |
|-|-|-|
| Original | 1358 kB | - |
| Trimmed | 1271 kB | - 87 kB |
@Dotnet-GitSync-Bot
Copy link
Collaborator

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

@marek-safar marek-safar added arch-wasm WebAssembly architecture area-CoreLib-mono labels Jul 9, 2020
</type>
<type fullname="System.Runtime.CompilerServices.CompilerGeneratedAttribute">
<attribute internal="RemoveAttributeInstances" />
</type>
Copy link
Member

Choose a reason for hiding this comment

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

CompilerGenerated is checked by StackTrace.ToString, so this will affect Exception.StackTrace/ToString(), for example.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, that's ugly. Looking at the code it looks like CompilerGeneratedAttribute usage there is optimization like check.

We could remove the check or if it's really needed we could remove this attribute under Debug.IsEnabled condition only.

Copy link
Member

Choose a reason for hiding this comment

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

Should we remove this one and add it with the rest of the Debug-only attributes under the Debugger.IsSupported feature switch?

Examples of the Debug-only attributes that can be removed are:

  • DebuggerTypeProxyAttribute
  • DebuggerDisplayAttribute

Copy link
Member

Choose a reason for hiding this comment

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

Looking at the code it looks like CompilerGeneratedAttribute usage there is optimization like check.

I think it's more there in case the types in question were implemented by someone manually; it's trying to only remove the relevant frames when they're on compiler generated types for async and iterators. It may be over protective, but I'm hesitant to remove it for the purposes of this PR.

Should we remove this one and add it with the rest of the Debug-only attributes under the Debugger.IsSupported feature switch?

That sounds reasonable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed it to be conditional

Copy link
Member

Choose a reason for hiding this comment

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

just to make sure I understand: in cases where debugger is disabled the StackTrace would now include the compiler-generated frames?

Copy link
Member

@stephentoub stephentoub Jul 10, 2020

Choose a reason for hiding this comment

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

Correct: the code looking for the attribute wouldn't find it, and so wouldn't skip the frames.

Add ExcludeFromCodeCoverageAttribute.
eerhardt and others added 2 commits July 9, 2020 17:43
Add note about Obsolete.
Only use assembly fullname="*" for compiler generated attributes.
</type>
<type fullname="System.Runtime.CompilerServices.CompilerGeneratedAttribute" feature="System.Diagnostics.Debugger.IsSupported" featurevalue="false">
<!--
The attribute is used during pretty stack trace printing
Copy link
Member

Choose a reason for hiding this comment

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

StackTraceHidden is used for the same purpose. You can add it with the same condition.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, there is a bunch of others which should be added as conditional (e.g. whole ETW). I'd prefer to add them in follow up PRs

@eerhardt eerhardt added the NO-MERGE The PR is not ready for merge yet (see discussion for detailed reasons) label Jul 10, 2020
@eerhardt
Copy link
Member

Setting No Merge on this PR because as soon as we do, it will break publishing any Blazor application until dotnet/linker#1341 is fixed.

@eerhardt eerhardt added the blocked Issue/PR is blocked on something - see comments label Jul 10, 2020
@eerhardt eerhardt removed NO-MERGE The PR is not ready for merge yet (see discussion for detailed reasons) blocked Issue/PR is blocked on something - see comments labels Jul 10, 2020
@eerhardt
Copy link
Member

Removing the No Merge label now that the fix for dotnet/linker#1341 has been merged into dotnet/sdk.

Copy link
Member

@eerhardt eerhardt left a comment

Choose a reason for hiding this comment

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

I think this is ready to be merged. Any other feedback?

@ghost
Copy link

ghost commented Jul 13, 2020

Hello @eerhardt!

Because this pull request has the auto-merge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ghost ghost merged commit c21a387 into dotnet:master Jul 13, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 8, 2020
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

arch-wasm WebAssembly architecture

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants