Skip to content

Conversation

@ToddGrun
Copy link
Contributor

@ToddGrun ToddGrun commented Jun 9, 2025

Reduce allocations in LegacyFileKindVisitor.VisitMarkupTagHelperAttribute

This method shows up in the typing scenario in the razor lsp typing speedometer test as 1.8% (133MB) of allocations. This gets rid of about 1/6th of those allocations, so about a 0.3% reduction in total.

Changes are limited to a single method, but are roughly:

  1. Get rid of Linq WhereArrayIterator allocations by manually walking the IAs
  2. Get rid of the lambda closures that these methods were taking in
  3. Get rid of the loop needing to call the First(...) method and it's lambda allocation

*** Highlighted allocations should be removed by this change ***
image

…bute

This method shows up in the typing scenario in the razor lsp typing speedometer test as 1.8% (133MB) of allocations. This gets rid of about 1/6th of those allocations, so about a 0.3% reduction in total.

Changes are limited to a single method, but are roughly:

1) Get rid of Linq WhereArrayIterator allocations by manually walking the IAs
2) Get rid of the lambda closures that these methods were taking in
3) Get rid of the loop needing to call the First(...) method and it's lambda allocation
@ToddGrun ToddGrun requested a review from a team as a code owner June 9, 2025 19:10
Copy link
Member

@DustinCampbell DustinCampbell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice

@ToddGrun ToddGrun merged commit 00e9d0e into main Jun 9, 2025
11 checks passed
@ToddGrun ToddGrun deleted the dev/toddgrun/ReduceAllocationsIn_LegacyFileKindVisitor.VisitMarkupTagHelperAttribute branch June 9, 2025 22:03
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Jun 9, 2025
@RikkiGibson RikkiGibson modified the milestones: Next, 18.0 P1 Aug 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants