Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 8 commits into from
Feb 13, 2025

Conversation

lewing
Copy link
Member

@lewing lewing commented Feb 8, 2025

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.

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)
Copy link
Contributor

@Copilot Copilot AI left a comment

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);

}
}

#pragma warning disable IDE0060 // Remove unused parameter
Copy link
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
Copy link
Member Author

lewing commented Feb 13, 2025

/ba-g issue files for red BA

@lewing lewing merged commit 5c86aad into dotnet:main Feb 13, 2025
153 of 159 checks passed
@lewing lewing deleted the compare-better branch February 13, 2025 18:51
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