Skip to content

[mono][tasks] reduce large allocations in build tasks - #112295

Merged
lewing merged 8 commits into
dotnet:mainfrom
lewing:compare-better
Feb 13, 2025
Merged

[mono][tasks] reduce large allocations in build tasks#112295
lewing merged 8 commits into
dotnet:mainfrom
lewing:compare-better

Conversation

@lewing

@lewing lewing commented Feb 8, 2025

Copy link
Copy Markdown
Member

It's late on a Friday so it is likely I'm missing something, but the hash comparison doesn't appear to be useful at all, that said I will assume it is useful and preserve the original behavior for now.

Use two rolling buffers to do file equality comparison since Read can return less than a full buffer, only advance a buffer once it is consumed, and compare the overlapping region.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (1)

src/tasks/Common/Utils.cs:217

  • Ensure that the new behavior introduced by the CompareFiles method is covered by tests. This includes scenarios where files are identical and where they differ.
private static bool CompareFiles(string filePath1, string filePath2)

Comment thread src/tasks/Common/Utils.cs

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

src/tasks/Common/Utils.cs:270

  • Ensure that the new behavior in CopyIfDifferent using ContentEqual is covered by tests.
bool areDifferent = !File.Exists(dst) || !ContentEqual(src, dst);

Comment thread src/tasks/Common/Utils.cs Outdated
Comment thread src/tasks/Common/Utils.cs Outdated
Comment thread src/tasks/Common/Utils.cs
}
}

#pragma warning disable IDE0060 // Remove unused parameter

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'm certain there is a difference between the text comparison and bytewise comparison but I think any value is likely an artifact of history that no longer applies. I'm happy to remove the setting at the callers and will unless someone objects.

@lewing

This comment was marked as outdated.

@lewing
lewing marked this pull request as ready for review February 13, 2025 03:08
@lewing
lewing requested a review from maraf as a code owner February 13, 2025 03:08
@lewing lewing changed the title [mono] Simplify file comparisons [mono][tasks] reduce large allocations in build tasks Feb 13, 2025
@lewing

lewing commented Feb 13, 2025

Copy link
Copy Markdown
Member Author

/ba-g issue files for red BA

@lewing
lewing merged commit 5c86aad into dotnet:main Feb 13, 2025
@lewing
lewing deleted the compare-better branch February 13, 2025 18:51
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 16, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants