-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Remove unnecessary work and refactor CompareAssemblyIdentity #5973
Remove unnecessary work and refactor CompareAssemblyIdentity #5973
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, although I'm wondering if it wouldn't be safer to remove the DllImport altogether, given that MSBuild has shipped with this bug. Thank you!
src/Tasks/NativeMethods.cs
Outdated
out pResult); | ||
out bool pfEquivalent, | ||
out _); | ||
return pfEquivalent; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without the new return statement the results of CompareAssemblyIdentityWindows
were ignored so it looks like it would be safer to not call this method at all and keep comparing identities in C# on all platforms. Is performance the reason why you chose to keep the Windows-only DllImport?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the one hand, going back to the original, long-proven code is nice. On the other, evidently this managed implementation is ok since the return was ignored! I wish we had more testing in this area to keep that true, so I filed #5974. But that doesn't need to block this!
Since this is a very perf-sensitive area, it might be nice to do some testing--if the native implementation is noticeably faster, we should probably keep it. Unfortunately I don't think it'll be easy to isolate that with a good set of test cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did some benchmarking and the fusion implementation seems to be ~10 times faster than its managed replacement. I, however, not sure it should mean so much for a decision, as I am not sure we run this code often enough for the difference to be noticeable: it is called only when we have a conflict (+ there are also other conditions). It is also clear that the managed implementation is meant to be just a replacement for the absent fusion function (see the TODO comment, line 1114) and I believe it might be less safe than the original fusion.dll code. From the other point of view, this managed code was shipped and also worked so far. So, well, it is hard to decide what is actually safer: to keep the fusion.dll or this managed implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for following up! It would probably make sense to copy your comment to the PR description and consequently to the commit message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/Tasks/NativeMethods.cs
Outdated
out pResult); | ||
out bool pfEquivalent, | ||
out _); | ||
return pfEquivalent; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for following up! It would probably make sense to copy your comment to the PR description and consequently to the commit message.
|
src/Tasks/NativeMethods.cs
Outdated
out pResult); | ||
out bool pfEquivalent, | ||
out _); | ||
return pfEquivalent; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Fixes #3930.
We remove the unused native call of CompareAssemblyIdentity (fusion.dll) and keep the custom managed implementation that duplicates it. Fusion implementation seems to be faster than its managed replacement, but it is only available for Windows. We, however, not sure that we run this code often enough for the difference to be noticeable. Current changes get us to a consistent implementation everywhere and are also a perf improvement since the unused native call won't happen.