Skip to content

Commit f2d2eec

Browse files
authored
Allow large InlineHint ArrayBuilder pooling (#79857)
The razor cohosting speedometer test shows 0.4% of total allocations during it's completion scenarios allocating InlineHint arrays. Manual debugging of the test scenario showed these arrays were about 260 items long, and thus weren't being placed back into the standard ArrayBuilder pool. Instead, we can use the non-bounded pool by passing in false as discardLargeInstances to the ArrayBuilder.GetInstance call.
1 parent 77ea404 commit f2d2eec

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/Features/Core/Portable/InlineHints/AbstractInlineParameterNameHintsService.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ public async Task<ImmutableArray<InlineHint>> GetInlineHintsAsync(
5959
var semanticModel = await document.GetRequiredSemanticModelAsync(cancellationToken).ConfigureAwait(false);
6060
var syntaxFacts = document.GetRequiredLanguageService<ISyntaxFactsService>();
6161

62-
using var _1 = ArrayBuilder<InlineHint>.GetInstance(out var result);
62+
// Allow large array instances in the pool, as these arrays often exceed the ArrayBuilder reuse size threshold
63+
using var _1 = ArrayBuilder<InlineHint>.GetInstance(discardLargeInstances: false, out var result);
6364
using var _2 = ArrayBuilder<(int position, SyntaxNode argument, IParameterSymbol? parameter, HintKind kind)>.GetInstance(out var buffer);
6465

6566
foreach (var node in root.DescendantNodes(textSpan, n => n.Span.IntersectsWith(textSpan)))

0 commit comments

Comments
 (0)