Skip to content

Conversation

@ToddGrun
Copy link
Contributor

@ToddGrun ToddGrun commented Jan 23, 2026

  1. Use discardLargeInstances in ArrayBuilder usage as the matchResultsBuilder array can typically be 1000 entries long which exceeds the ArrayBuilder.PooledArrayLengthLimitExclusive threshold.

  2. Replace Linq usage in the method to get rid of some enumerator allocs.

  3. Get rid of the SelectAsArray usage, as again, it would end up using an ArrayBuilder that exceeds the ArrayBuilder.PooledArrayLengthLimitExclusive threshold.

Validation PR didn't show a big improvement, but looking at the Razor C# completion scenario, it only tests bringing up completion inside a using statement. That isn't a scenario where there are a large number (> 1000) of completion items, and thus not a scenario which would hit this codepath. This PR improves allocations in less restrictive completion contexts (ie, typing in a context where accessible types are in the list).

1) Use discardLargeInstances in ArrayBuilder usage as the matchResultsBuilder array can typically be 1000 entries long which exceeds the ArrayBuilder.PooledArrayLengthLimitExclusive threshold.

2) Replace Linq usage in the method to get rid of some enumerator allocs.

3) Get rid of the SelectAsArray usage, as again, it would end up using an ArrayBuilder that exceeds the ArrayBuilder.PooledArrayLengthLimitExclusive threshold.
@ToddGrun ToddGrun requested a review from a team as a code owner January 23, 2026 22:04
@ToddGrun
Copy link
Contributor Author

/pr-val

@github-actions
Copy link
Contributor

View PR Validation Run triggered by @ToddGrun

Parameters
  • Validation Type: pr-val
  • Pipeline ID: 8972
  • Pipeline Version: main
  • PR Number: 82133
  • Commit SHA: bb17e2eab905aa24a936c78e0a8b8145135f39e4
  • Source Branch: dev/toddgrun/LSPCompletionAllocs
  • Target Branch: main
  • Build ID: 13158840

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant