Skip to content

Reduce allocations in normal elfie usage#82743

Merged
ToddGrun merged 2 commits intodotnet:mainfrom
ToddGrun:dev/toddgrun/ElfieAllocations
Mar 14, 2026
Merged

Reduce allocations in normal elfie usage#82743
ToddGrun merged 2 commits intodotnet:mainfrom
ToddGrun:dev/toddgrun/ElfieAllocations

Conversation

@ToddGrun
Copy link
Contributor

@ToddGrun ToddGrun commented Mar 13, 2026

In the binary, non-patch case (aka, the "normal" case), this should prevent a LOH byte[] allocation reading a roughly 15 MB binary file. Instead, use a stream so that the whole file need not be read into memory at once.

*** old allocations ***
image

*** new allocations ***
image

Microsoft Reviewers: Open in CodeFlow

In the binary, non-patch case (aka, the "normal" case), this should prevent a LOH byte[] allocation reading a roughly 15 MB binary file. Instead, use a stream so that the whole file need not be read into memory at once.

Will add more details if a speedometer run comes back looking good.
@ToddGrun ToddGrun requested a review from a team as a code owner March 13, 2026 13:44
@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: 82743
  • Commit SHA: 6498d38c344cedb25af66ef922bd12a4517a7c18
  • Source Branch: dev/toddgrun/ElfieAllocations
  • Target Branch: main
  • Build ID: 13545534

@CyrusNajmabadi
Copy link
Contributor

I don't think this is worthwhile. We patch like once every 3 or 6 months. Saving a single LOH allocation in that time isn't really necessary.

@ToddGrun
Copy link
Contributor Author

I don't think this is worthwhile. We patch like once every 3 or 6 months. Saving a single LOH allocation in that time isn't really necessary.

That doesn't match what I see when debugging. I see this run on each instance.

@CyrusNajmabadi
Copy link
Contributor

Ah sorry. I misread. I thought you were saying in the binary-patch case we were seeing the LOH allocation. Reviewing now.

@ToddGrun ToddGrun merged commit f808321 into dotnet:main Mar 14, 2026
25 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Mar 14, 2026
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.

3 participants