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

EnC support for source-generated files #51526

Merged
merged 6 commits into from
Mar 1, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
``` ini

BenchmarkDotNet=v0.12.1, OS=Windows 10.0.19042
AMD Ryzen Threadripper 3960X, 1 CPU, 48 logical and 24 physical cores
[Host] : .NET Framework 4.8 (4.8.4300.0), X64 RyuJIT
DefaultJob : .NET Framework 4.8 (4.8.4300.0), X64 RyuJIT


```
| Method | DocumentCount | Mean | Error | StdDev | Median | Gen 0 | Gen 1 | Gen 2 | Allocated |
|-------------------------- |-------------- |----------------:|--------------:|--------------:|----------------:|-------:|-------:|------:|----------:|
| **Project.DocumentIds** | **0** | **23.34 ns** | **0.494 ns** | **0.891 ns** | **22.91 ns** | **-** | **-** | **-** | **-** |
| Project.Documents | 0 | 77.22 ns | 0.537 ns | 0.502 ns | 77.31 ns | 0.0772 | - | - | 128 B |
| Solution.WithDocumentText | 0 | 14.60 ns | 0.324 ns | 0.690 ns | 14.57 ns | - | - | - | - |
| **Project.DocumentIds** | **100** | **8,159.41 ns** | **10.113 ns** | **8.965 ns** | **8,157.79 ns** | **0.0305** | **-** | **-** | **72 B** |
| Project.Documents | 100 | 16,356.60 ns | 97.365 ns | 91.076 ns | 16,382.64 ns | 0.0916 | - | - | 201 B |
| Solution.WithDocumentText | 100 | 14,436.90 ns | 355.846 ns | 1,015.248 ns | 14,392.68 ns | 0.8240 | 0.2136 | - | 5285 B |
| **Project.DocumentIds** | **10000** | **863,988.25 ns** | **1,297.511 ns** | **1,213.693 ns** | **863,625.88 ns** | **-** | **-** | **-** | **80 B** |
| Project.Documents | 10000 | 1,861,933.16 ns | 11,538.506 ns | 10,793.125 ns | 1,859,064.65 ns | - | - | - | 208 B |
| Solution.WithDocumentText | 10000 | 14,088.55 ns | 281.041 ns | 453.828 ns | 14,003.49 ns | 0.8698 | 0.2289 | - | 5539 B |
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Method,Job,AnalyzeLaunchVariance,EvaluateOverhead,MaxAbsoluteError,MaxRelativeError,MinInvokeCount,MinIterationTime,OutlierMode,Affinity,EnvironmentVariables,Jit,Platform,PowerPlanMode,Runtime,AllowVeryLargeObjects,Concurrent,CpuGroups,Force,HeapAffinitizeMask,HeapCount,NoAffinitize,RetainVm,Server,Arguments,BuildConfiguration,Clock,EngineFactory,NuGetReferences,Toolchain,IsMutator,InvocationCount,IterationCount,IterationTime,LaunchCount,MaxIterationCount,MaxWarmupIterationCount,MinIterationCount,MinWarmupIterationCount,RunStrategy,UnrollFactor,WarmupCount,DocumentCount,Mean,Error,StdDev,Median,Gen 0,Gen 1,Gen 2,Allocated
Project.DocumentIds,DefaultJob,False,Default,Default,Default,Default,Default,Default,111111111111111111111111111111111111111111111111,Empty,RyuJit,X64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 4.8,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,1,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,0,23.34 ns,0.494 ns,0.891 ns,22.91 ns,0.0000,0.0000,0.0000,0 B
Project.Documents,DefaultJob,False,Default,Default,Default,Default,Default,Default,111111111111111111111111111111111111111111111111,Empty,RyuJit,X64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 4.8,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,1,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,0,77.22 ns,0.537 ns,0.502 ns,77.31 ns,0.0772,0.0000,0.0000,128 B
Solution.WithDocumentText,DefaultJob,False,Default,Default,Default,Default,Default,Default,111111111111111111111111111111111111111111111111,Empty,RyuJit,X64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 4.8,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,1,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,0,14.60 ns,0.324 ns,0.690 ns,14.57 ns,0.0000,0.0000,0.0000,0 B
Project.DocumentIds,DefaultJob,False,Default,Default,Default,Default,Default,Default,111111111111111111111111111111111111111111111111,Empty,RyuJit,X64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 4.8,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,1,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,100,"8,159.41 ns",10.113 ns,8.965 ns,"8,157.79 ns",0.0305,0.0000,0.0000,72 B
Project.Documents,DefaultJob,False,Default,Default,Default,Default,Default,Default,111111111111111111111111111111111111111111111111,Empty,RyuJit,X64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 4.8,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,1,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,100,"16,356.60 ns",97.365 ns,91.076 ns,"16,382.64 ns",0.0916,0.0000,0.0000,201 B
Solution.WithDocumentText,DefaultJob,False,Default,Default,Default,Default,Default,Default,111111111111111111111111111111111111111111111111,Empty,RyuJit,X64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 4.8,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,1,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,100,"14,436.90 ns",355.846 ns,"1,015.248 ns","14,392.68 ns",0.8240,0.2136,0.0000,5285 B
Project.DocumentIds,DefaultJob,False,Default,Default,Default,Default,Default,Default,111111111111111111111111111111111111111111111111,Empty,RyuJit,X64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 4.8,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,1,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,10000,"863,988.25 ns","1,297.511 ns","1,213.693 ns","863,625.88 ns",0.0000,0.0000,0.0000,80 B
Project.Documents,DefaultJob,False,Default,Default,Default,Default,Default,Default,111111111111111111111111111111111111111111111111,Empty,RyuJit,X64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 4.8,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,1,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,10000,"1,861,933.16 ns","11,538.506 ns","10,793.125 ns","1,859,064.65 ns",0.0000,0.0000,0.0000,208 B
Solution.WithDocumentText,DefaultJob,False,Default,Default,Default,Default,Default,Default,111111111111111111111111111111111111111111111111,Empty,RyuJit,X64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 4.8,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,1,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,10000,"14,088.55 ns",281.041 ns,453.828 ns,"14,003.49 ns",0.8698,0.2289,0.0000,5539 B
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='utf-8' />
<title>IdeCoreBenchmarks.ProjectOperationBenchmarks.IterateDocuments-20210223-114823</title>

<style type="text/css">
table { border-collapse: collapse; display: block; width: 100%; overflow: auto; }
td, th { padding: 6px 13px; border: 1px solid #ddd; text-align: right; }
tr { background-color: #fff; border-top: 1px solid #ccc; }
tr:nth-child(even) { background: #f8f8f8; }
</style>
</head>
<body>
<pre><code>
BenchmarkDotNet=v0.12.1, OS=Windows 10.0.19042
AMD Ryzen Threadripper 3960X, 1 CPU, 48 logical and 24 physical cores
[Host] : .NET Framework 4.8 (4.8.4300.0), X64 RyuJIT
DefaultJob : .NET Framework 4.8 (4.8.4300.0), X64 RyuJIT
</code></pre>
<pre><code></code></pre>

<table>
<thead><tr><th> Method</th><th>DocumentCount</th><th> Mean</th><th> Error</th><th> StdDev</th><th> Median</th><th>Gen 0</th><th>Gen 1</th><th>Gen 2</th><th>Allocated</th>
</tr>
</thead><tbody><tr><td>Project.DocumentIds</td><td>0</td><td>23.34 ns</td><td>0.494 ns</td><td>0.891 ns</td><td>22.91 ns</td><td>-</td><td>-</td><td>-</td><td>-</td>
</tr><tr><td>Project.Documents</td><td>0</td><td>77.22 ns</td><td>0.537 ns</td><td>0.502 ns</td><td>77.31 ns</td><td>0.0772</td><td>-</td><td>-</td><td>128 B</td>
</tr><tr><td>Solution.WithDocumentText</td><td>0</td><td>14.60 ns</td><td>0.324 ns</td><td>0.690 ns</td><td>14.57 ns</td><td>-</td><td>-</td><td>-</td><td>-</td>
</tr><tr><td>Project.DocumentIds</td><td>100</td><td>8,159.41 ns</td><td>10.113 ns</td><td>8.965 ns</td><td>8,157.79 ns</td><td>0.0305</td><td>-</td><td>-</td><td>72 B</td>
</tr><tr><td>Project.Documents</td><td>100</td><td>16,356.60 ns</td><td>97.365 ns</td><td>91.076 ns</td><td>16,382.64 ns</td><td>0.0916</td><td>-</td><td>-</td><td>201 B</td>
</tr><tr><td>Solution.WithDocumentText</td><td>100</td><td>14,436.90 ns</td><td>355.846 ns</td><td>1,015.248 ns</td><td>14,392.68 ns</td><td>0.8240</td><td>0.2136</td><td>-</td><td>5285 B</td>
</tr><tr><td>Project.DocumentIds</td><td>10000</td><td>863,988.25 ns</td><td>1,297.511 ns</td><td>1,213.693 ns</td><td>863,625.88 ns</td><td>-</td><td>-</td><td>-</td><td>80 B</td>
</tr><tr><td>Project.Documents</td><td>10000</td><td>1,861,933.16 ns</td><td>11,538.506 ns</td><td>10,793.125 ns</td><td>1,859,064.65 ns</td><td>-</td><td>-</td><td>-</td><td>208 B</td>
</tr><tr><td>Solution.WithDocumentText</td><td>10000</td><td>14,088.55 ns</td><td>281.041 ns</td><td>453.828 ns</td><td>14,003.49 ns</td><td>0.8698</td><td>0.2289</td><td>-</td><td>5539 B</td>
</tr></tbody></table>
</body>
</html>
6 changes: 3 additions & 3 deletions src/EditorFeatures/CSharpTest/Workspaces/WorkspaceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,14 +220,14 @@ public async Task TestAddedSubmissionParseTreeHasEmptyFilePath()
// Check that a parse tree for a submission has an empty file path.
var tree1 = await workspace.CurrentSolution
.GetProjectState(project1.Id)
.GetDocumentState(document1.Id)
.DocumentStates.GetState(document1.Id)
.GetSyntaxTreeAsync(CancellationToken.None);
Assert.Equal("", tree1.FilePath);

// Check that a parse tree for a script does not have an empty file path.
var tree2 = await workspace.CurrentSolution
.GetProjectState(project2.Id)
.GetDocumentState(document2.Id)
.DocumentStates.GetState(document2.Id)
.GetSyntaxTreeAsync(CancellationToken.None);
Assert.Equal("a.csx", tree2.FilePath);
}
Expand Down Expand Up @@ -821,7 +821,7 @@ public async Task TestAnalyzerConfigFile_Properties()

Assert.Equal(1, project.Documents.Count());
Assert.Equal(1, project.AnalyzerConfigDocuments.Count());
Assert.Equal(1, project.State.AnalyzerConfigDocumentIds.Count());
Assert.Equal(1, project.State.AnalyzerConfigDocumentStates.Count);

var doc = project.GetDocument(analyzerConfigDoc.Id);
Assert.Null(doc);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,15 +183,21 @@ internal async Task TrackActiveSpansAsync()
}

Debug.Assert(openDocumentIds.Length == baseActiveStatementSpans.Length);
using var _ = ArrayBuilder<Document?>.GetInstance(out var documents);

foreach (var id in openDocumentIds)
{
documents.Add(await currentSolution.GetDocumentAsync(id, includeSourceGenerated: true, _cancellationSource.Token).ConfigureAwait(false));
}

lock (_trackingSpans)
{
for (var i = 0; i < baseActiveStatementSpans.Length; i++)
{
var document = currentSolution.GetDocument(openDocumentIds[i]);
var document = documents[i];
if (document == null)
{
// Document has been deleted.
// Document has been deleted
continue;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Licensed to the .NET Foundation under one or more agreements.
// 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 System.Diagnostics.CodeAnalysis;
using System.Linq;
using Microsoft.CodeAnalysis.Diagnostics;
using Roslyn.Utilities;

namespace Microsoft.CodeAnalysis.EditAndContinue.UnitTests
{
internal class EditAndContinueTestAnalyzerConfigOptions : AnalyzerConfigOptions
{
private readonly Dictionary<string, string> _options;

public EditAndContinueTestAnalyzerConfigOptions(IEnumerable<(string key, string value)> options)
=> _options = options.ToDictionary(e => e.key, e => e.value);

public override bool TryGetValue(string key, [NotNullWhen(true)] out string? value)
=> _options.TryGetValue(key, out value);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Licensed to the .NET Foundation under one or more agreements.
// 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.Diagnostics;

namespace Microsoft.CodeAnalysis.EditAndContinue.UnitTests
{
internal class EditAndContinueTestAnalyzerConfigOptionsProvider : AnalyzerConfigOptionsProvider
{
public EditAndContinueTestAnalyzerConfigOptionsProvider(IEnumerable<(string, string)> options)
=> GlobalOptions = new EditAndContinueTestAnalyzerConfigOptions(options);

public override AnalyzerConfigOptions GlobalOptions { get; }

public override AnalyzerConfigOptions GetOptions(SyntaxTree tree)
=> GlobalOptions;

public override AnalyzerConfigOptions GetOptions(AdditionalText textFile)
=> GlobalOptions;
}
}
Loading