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

Rewrite AnalyzeFileReference.GetSupportedLanguages without LINQ #49337

Merged
merged 1 commit into from
Nov 13, 2020

Conversation

stephentoub
Copy link
Member

@stephentoub stephentoub commented Nov 12, 2020

I did an allocation profile of csc.dll for building a simple "hello world" with the configuration dotnet build employs on a simple dotnet new console app. There are ~194K allocations / ~19MB. And ~30K / ~1MB of those are occurring unnecessarily because of use of LINQ in one function. This just rewrites that function to not use LINQ.

Before:
image

After:
image

Contributes to dotnet/msbuild#5876

I did an allocation profile of csc.dll for building a simple "hello world" with the configuration `dotnet build` employs on a simple `dotnet new console` app.  There are ~194K allocations / ~19MB.  And ~30K / ~1MB of those are occurring unnecessarily because of use of LINQ in one function.  This just rewrites that function to not use LINQ.
@sharwell
Copy link
Member

sharwell commented Nov 12, 2020

The reference scenarios I've been monitoring produce roughly 200-250GiB allocations for compilation with analyzer scenarios. I'm not sure the 0.0004% improvement is worth the additional complexity here. I typically expect to see 1GiB for moderate complexity improvements and at least 100MiB for improvements that don't also improve readability.

@stephentoub
Copy link
Member Author

The reference scenarios

We don't care about simple apps?

Copy link
Member

@sharwell sharwell left a comment

Choose a reason for hiding this comment

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

This one is easy enough. I'm not sure it's noticeable but I don't see a downside of taking it since the work was already done.

@stephentoub
Copy link
Member Author

the work was already done.

For reference, the work was right-click, convert to foreach, and fix up the select many at the end.

@333fred 333fred merged commit 8cbae31 into dotnet:master Nov 13, 2020
@ghost ghost added this to the Next milestone Nov 13, 2020
@stephentoub stephentoub deleted the getsupportedlanguageslinq branch November 13, 2020 21:22
@sharwell
Copy link
Member

We don't care about simple apps?

Just to make sure it's clear for future readers, yes, we do believe simple applications are important. My comment was more related to the fact that not all measurable issues are observable, and it's my experience that this scenario is unlikely to be one of the observable ones.

I have to be careful when looking at problems of the scale facing this component. If we were to set/keep the performance bar at the level used for this pull request, there would be almost limitless pull requests touching this very complex subsystem, and eventually one of them would break functionality when we miss something during review. The bar mentioned above has proven to be reasonable in the sense that meaningful progress across a range of scenarios is not blocked, while at the same time there have been very few unexpected changes in behavior.

@stephentoub
Copy link
Member Author

stephentoub commented Nov 13, 2020

If we were to set/keep the performance bar at the level used for this pull request

This eliminated 15% of all allocations when compiling a simple program, and did so by modifying a single function. If there are more possible PRs like that, we should absolutely take them.

333fred added a commit to 333fred/roslyn that referenced this pull request Nov 16, 2020
* upstream/master: (148 commits)
  Remove unnecessary ArrayBuilder in MakeCallWithNoExplicitArgument (dotnet#49377)
  Revert "Skip binary for determinism checking"
  Use deterministic metadata names for emitted anonymous type fields. (dotnet#49370)
  Reuse LSP solutions if they don't need re-forking (dotnet#49305)
  Small nullability fixes (dotnet#49279)
  Create default arguments during binding (dotnet#49186)
  Clean nits
  Backport dotnet#48420 to release/dev16.8 (dotnet#49357)
  Rewrite AnalyzeFileReference.GetSupportedLanguages without LINQ (dotnet#49337)
  Use .Any extension of ImmutableArray(Of Symbol) (dotnet#48980)
  fix 'remove unnecessary cast' when doing bitwise ops on unsigned values.
  Harden, document, cross-link XunitDisposeHook
  Simplify x86 hook
  Fix split comment exporting for VB.
  Code style fix
  Overwrite xunit's app domain handling to not call AppDomain.Unload
  Revert pragma suppression
  Remove blank line
  Revert file
  Move block structure code back to Features layer
  ...
@allisonchou allisonchou modified the milestones: Next, 16.9.P2 Nov 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants