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 all 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>
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ protected readonly struct MappedMethod
public readonly IMethodSymbolInternal PreviousMethod;
public readonly Func<SyntaxNode, SyntaxNode> SyntaxMap;

public MappedMethod(IMethodSymbolInternal previousMethodOpt, Func<SyntaxNode, SyntaxNode> syntaxMap)
public MappedMethod(IMethodSymbolInternal previousMethod, Func<SyntaxNode, SyntaxNode> syntaxMap)
{
PreviousMethod = previousMethodOpt;
PreviousMethod = previousMethod;
tmat marked this conversation as resolved.
Show resolved Hide resolved
SyntaxMap = syntaxMap;
}
}
Expand Down Expand Up @@ -311,16 +311,10 @@ internal VariableSlotAllocator TryCreateVariableSlotAllocator(EmitBaseline basel
symbolMap = MapToMetadataSymbolMatcher;
}

var previousMethod = mappedMethod.PreviousMethod;
if (previousMethod is null)
{
previousMethod = (IMethodSymbolInternal)symbolMap.MapDefinitionOrNamespace(topLevelMethod);
}

return new EncVariableSlotAllocator(
symbolMap,
mappedMethod.SyntaxMap,
previousMethod,
mappedMethod.PreviousMethod,
methodId,
previousLocals,
lambdaMap,
Expand Down
4 changes: 2 additions & 2 deletions src/Compilers/Core/Portable/Emit/SemanticEdit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public struct SemanticEdit : IEquatable<SemanticEdit>
/// </summary>
/// <param name="kind">The type of edit.</param>
/// <param name="oldSymbol">
/// The symbol from the earlier compilation, or null if the edit represents an addition or an update of the symbol from the previous compilation that exactly matches <paramref name="newSymbol"/>.
/// The symbol from the earlier compilation, or null if the edit represents an addition.
/// </param>
/// <param name="newSymbol">
/// The symbol from the later compilation, or null if the edit represents a deletion.
Expand All @@ -74,7 +74,7 @@ public struct SemanticEdit : IEquatable<SemanticEdit>
/// </exception>
public SemanticEdit(SemanticEditKind kind, ISymbol? oldSymbol, ISymbol? newSymbol, Func<SyntaxNode, SyntaxNode?>? syntaxMap = null, bool preserveLocalVariables = false)
{
if (oldSymbol == null && kind is not (SemanticEditKind.Insert or SemanticEditKind.Update))
if (oldSymbol == null && kind != SemanticEditKind.Insert)
{
throw new ArgumentNullException(nameof(oldSymbol));
}
Expand Down
Loading