提交 c7bbf2f0 编写于 作者: S Sam Harwell

Avoid Task allocation on GetInfoForMetadataReferenceAsync fast path

上级 835ac0e3
......@@ -84,7 +84,7 @@ public Task PopulateIndicesAsync(CancellationToken cancellationToken)
foreach (var peReference in GetAllRelevantPeReferences())
{
tasks.Add(Task.Run(()
=> SymbolTreeInfo.GetInfoForMetadataReferenceAsync(Solution, peReference, loadOnly: false, cancellationToken), cancellationToken));
=> SymbolTreeInfo.GetInfoForMetadataReferenceAsync(Solution, peReference, loadOnly: false, cancellationToken).AsTask(), cancellationToken));
}
return Task.WhenAll(tasks.ToImmutable());
......@@ -100,7 +100,7 @@ public async Task<(ImmutableArray<IMethodSymbol> symbols, bool isPartialResult)>
tasks.Add(Task.Run(() => GetExtensionMethodSymbolsFromPeReferenceAsync(
peReference,
forceIndexCreation,
cancellationToken), cancellationToken));
cancellationToken).AsTask(), cancellationToken));
}
foreach (var project in GetAllRelevantProjects())
......@@ -184,7 +184,7 @@ private ImmutableArray<PortableExecutableReference> GetAllRelevantPeReferences()
: GetExtensionMethodsForSymbolsFromDifferentCompilation(matchingMethodSymbols, cancellationToken);
}
private async Task<ImmutableArray<IMethodSymbol>?> GetExtensionMethodSymbolsFromPeReferenceAsync(
private async ValueTask<ImmutableArray<IMethodSymbol>?> GetExtensionMethodSymbolsFromPeReferenceAsync(
PortableExecutableReference peReference,
bool forceIndexCreation,
CancellationToken cancellationToken)
......
......@@ -29,7 +29,7 @@ private class SymbolTreeInfoCacheService : ISymbolTreeInfoCacheService
_metadataIdToInfo = metadataIdToInfo;
}
public async Task<SymbolTreeInfo> TryGetMetadataSymbolTreeInfoAsync(
public async ValueTask<SymbolTreeInfo> TryGetMetadataSymbolTreeInfoAsync(
Solution solution,
PortableExecutableReference reference,
CancellationToken cancellationToken)
......
......@@ -20,6 +20,6 @@ internal interface ISymbolTreeInfoCacheService : IWorkspaceService
/// <summary>
/// Returns null if the info cannot be retrieved from the cache.
/// </summary>
Task<SymbolTreeInfo> TryGetMetadataSymbolTreeInfoAsync(Solution solution, PortableExecutableReference reference, CancellationToken cancellationToken);
ValueTask<SymbolTreeInfo> TryGetMetadataSymbolTreeInfoAsync(Solution solution, PortableExecutableReference reference, CancellationToken cancellationToken);
}
}
......@@ -65,7 +65,7 @@ private static Metadata GetMetadataNoThrow(PortableExecutableReference reference
}
}
public static Task<SymbolTreeInfo> GetInfoForMetadataReferenceAsync(
public static ValueTask<SymbolTreeInfo> GetInfoForMetadataReferenceAsync(
Solution solution, PortableExecutableReference reference,
bool loadOnly, CancellationToken cancellationToken)
{
......@@ -79,7 +79,8 @@ private static Metadata GetMetadataNoThrow(PortableExecutableReference reference
/// Produces a <see cref="SymbolTreeInfo"/> for a given <see cref="PortableExecutableReference"/>.
/// Note: will never return null;
/// </summary>
public static async Task<SymbolTreeInfo> GetInfoForMetadataReferenceAsync(
[PerformanceSensitive("https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1224834", OftenCompletesSynchronously = true)]
public static async ValueTask<SymbolTreeInfo> GetInfoForMetadataReferenceAsync(
Solution solution,
PortableExecutableReference reference,
Checksum checksum,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册