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

Pack bits in SourceOrdinaryMethodSymbol into an existing bitflag structure we have for all source methods #68132

Merged
merged 11 commits into from
May 10, 2023

Conversation

CyrusNajmabadi
Copy link
Member

Drop 0.8% of memory from:

image

to

image

@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner May 8, 2023 20:38
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels May 8, 2023
{
get { return (_flags & IsVarArgBit) != 0; }
set { ThreadSafeFlagOperations.Set(ref _flags, value ? IsVarArgBit : 0); }
}
Copy link
Member Author

Choose a reason for hiding this comment

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

note: IsVarArg is currently lazily computed. But it woudl be trivial to compute up front in SourceOrdinaryMethod's constructor and just not have to deal with this. But i kept the logic as before.

private readonly bool _isExpressionBodied;
private readonly bool _hasAnyBody;
private readonly RefKind _refKind;
private bool _lazyIsVararg;
Copy link
Member Author

Choose a reason for hiding this comment

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

this was an additional 32bits per method

@@ -12,7 +12,6 @@ namespace Microsoft.CodeAnalysis.CSharp.Symbols
{
internal sealed class SourceConstructorSymbol : SourceConstructorSymbolBase
{
private readonly bool _isExpressionBodied;
private readonly bool _hasThisInitializer;
Copy link
Member Author

Choose a reason for hiding this comment

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

todo: consider adding a flag for this. would take away an unnecessary 32bit in a constructor.

@@ -23,7 +23,6 @@ internal class SourcePropertyAccessorSymbol : SourceMemberMethodSymbol
private ImmutableArray<MethodSymbol> _lazyExplicitInterfaceImplementations;
private string _lazyName;
private readonly bool _isAutoPropertyAccessor;
private readonly bool _isExpressionBodied;
private readonly bool _usesInit;
Copy link
Member Author

Choose a reason for hiding this comment

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

todo: consider bits for these two fields. That would be another 32 bits saved.

@CyrusNajmabadi CyrusNajmabadi requested a review from jaredpar May 8, 2023 20:50
@CyrusNajmabadi
Copy link
Member Author

@jaredpar ptal.

{
// Events cannot be expression-bodied
get { return false; }
}
Copy link
Member Author

Choose a reason for hiding this comment

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

this is just wrong (but was overridden, so it wasn't a problem). Event accessors can def be expression-bodied.

@CyrusNajmabadi
Copy link
Member Author

@dotnet/roslyn-compiler @jcouv @jaredpar ptal.

Copy link
Member

@333fred 333fred left a comment

Choose a reason for hiding this comment

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

Done review pass

@CyrusNajmabadi CyrusNajmabadi enabled auto-merge (squash) May 10, 2023 17:33
@CyrusNajmabadi CyrusNajmabadi merged commit e4c723e into dotnet:main May 10, 2023
@ghost ghost added this to the Next milestone May 10, 2023
public bool IsVarArg
{
get { return (_flags & IsVarArgBit) != 0; }
set { ThreadSafeFlagOperations.Set(ref _flags, value ? IsVarArgBit : 0); }
Copy link
Contributor

Choose a reason for hiding this comment

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

set { ThreadSafeFlagOperations.Set(ref _flags, value ? IsVarArgBit : 0); }

This doesn't look like the right thing to do. If the value is lazy calculated, then there should be a flag indicating that it has been calculated and an attempt to get the value should trigger the calculation. Alternatively, if the value is easy to calculate from the syntax, we should do that and store the final value from the start, eliminating the ability to adjust the value later.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure. I can move this to be computed up front.

@CyrusNajmabadi CyrusNajmabadi deleted the packBits branch May 10, 2023 18:09
CyrusNajmabadi added a commit that referenced this pull request May 10, 2023
…lag structure we have for all source methods (#68132)"

This reverts commit e4c723e.
CyrusNajmabadi added a commit to CyrusNajmabadi/roslyn that referenced this pull request May 10, 2023
…ing bitflag structure we have for all source methods (dotnet#68132)""

This reverts commit d51ec38.
CyrusNajmabadi added a commit that referenced this pull request May 10, 2023
…lag structure we have for all source methods (#68132)" (#68157)

This reverts commit e4c723e.
CyrusNajmabadi added a commit to CyrusNajmabadi/roslyn that referenced this pull request May 10, 2023
…cture we have for all source methods (dotnet#68132)

* In progresS

* Utilize

* initialize once

* Save space in other methods

* reorder

* reorder

* Move down

* Reorder

* Simplify

* Add docs

* move up
CyrusNajmabadi added a commit that referenced this pull request May 16, 2023
…cture we have for all source methods (#68158)

* Pack bits in SourceOrdinaryMethodSymbol into an existing bitflag structure we have for all source methods (#68132)

* In progresS

* Utilize

* initialize once

* Save space in other methods

* reorder

* reorder

* Move down

* Reorder

* Simplify

* Add docs

* move up

* Compute IsVarArg up front

* Remove unused usings

* Remove

* Remove passing of flag

* move up and make non-virtual

* "move up and make sealed"

* move up and make sealed

* use properties instead of flags

* Make parameters non-optional

* Pass all args

* move more down

* move more down

* Pass all args

* move more down

* move more down

* move more down

* move more down

* Name consistently

* Set flag consistently

* Rename

* Fix usage of hasBody where it means hasBlockBody

* Change to true

* Change to true

* Fix vararg check

* Change to true

* NRT

* Pass values explicitly

* Add assert

* Flip depending on if something is abstract or not.

* Update check

* Fix ocmment

* Fix ocmment

* Update src/Compilers/CSharp/Portable/Symbols/Source/SourceConstructorSymbol.cs
@Cosifne Cosifne modified the milestones: Next, 17.7 P2 May 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants