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

Improve performance of lsif generation. #51457

Merged
3 commits merged into from
Feb 25, 2021
Merged

Conversation

CyrusNajmabadi
Copy link
Member

We would often write out tens of thousands of elements per file, taking locks for each eleemnt we're writing. We can just take the lock once and write out the full batch.

Before time:

Total time spent in the generation phase for all projects, including compilation fetch time: 25.02 seconds

After time:

Total time spent in the generation phase for all projects, including compilation fetch time: 18.67 seconds

This is an improvement of 25%.

@sharwell
Copy link
Member

Is there an easy way I can run the generator locally?

@CyrusNajmabadi
Copy link
Member Author

CyrusNajmabadi commented Feb 25, 2021

I'm running:

C:\github\roslyn\artifacts\bin\Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator\Release\net472\Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator.exe --project C:\github\roslyn\src\Compilers\Core\Portable\Microsoft.CodeAnalysis.csproj --log c:\temp\log.txt --output c:\temp\lsif.json

Note: you'll need #51458 where i add support for just running against a single project. i can also collect full solution time.

@CyrusNajmabadi
Copy link
Member Author

Performance at the full solution goes from:

Total time spent in the generation phase for all projects, including compilation fetch time: 523.66 seconds

to

Total time spent in the generation phase for all projects, including compilation fetch time: 464.94 seconds

Only 12% gain here, but still nice to have.

@@ -2,12 +2,14 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Collections.Generic;
using Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator.Graph;

namespace Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator.Writing
{
internal interface ILsifJsonWriter
{
void Write(Element element);
Copy link
Member

Choose a reason for hiding this comment

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

❔ Do we still need this one?

Copy link
Member Author

Choose a reason for hiding this comment

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

yup. several callers call directly into that one. I could have them wrap into a single-element list, but it seemed wasteful :)

@sharwell
Copy link
Member

Performance at the full solution goes from:

You'll get at least 60 seconds gain my moving from MSBuildWorkspace to direct creation of compilations from csc invocations in the binlog. MSBuildWorkspace is extremely terrible for end-to-end performance because there is no parallelism in the MSBuild evaluation.

csc invocations have a secondary benefit of improved accuracy.

@CyrusNajmabadi
Copy link
Member Author

to direct creation of compilations from csc invocations

Definitely agree. I'm just very limited on time to here :)

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Auto-approval

@ghost ghost merged commit bace31f into dotnet:master Feb 25, 2021
@ghost ghost added this to the Next milestone Feb 25, 2021
@CyrusNajmabadi CyrusNajmabadi deleted the lsifSpeed branch February 25, 2021 18:26
@allisonchou allisonchou modified the milestones: Next, 16.10.P2 Mar 29, 2021
This pull request was closed.
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.

4 participants