Skip to content
Merged
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
Allow large InlineHint ArrayBuilder pooling
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.
  • Loading branch information
ToddGrun committed Aug 8, 2025
commit 6019566380f21d4ecec15c619274b37e04b87017
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ public async Task<ImmutableArray<InlineHint>> GetInlineHintsAsync(
var semanticModel = await document.GetRequiredSemanticModelAsync(cancellationToken).ConfigureAwait(false);
var syntaxFacts = document.GetRequiredLanguageService<ISyntaxFactsService>();

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

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