-
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
Update native File.Exists #9223
Conversation
@JaynieBai Could you comment on this PR and fill the description? |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
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.
Overall looking good!
One comment left probably nit
src/Build/BackEnd/Components/RequestBuilder/IntrinsicTasks/MSBuild.cs
Outdated
Show resolved
Hide resolved
It looks like the root of the problem here is that our custom Windows-only implementation of msbuild/src/Framework/NativeMethods.cs Lines 1725 to 1731 in 053feb0
BCL API accepts paths like @JaynieBai, can you please check why exactly |
I Find FileSystems.Default.FileExists calls the unmanage function
.NET Framework Output
.Net Output
|
I agree with @ladipro here that we need to make sure a change happens on a correct abstraction layer and isolated only to the failing scenario, given the perf concerns. @rainersigwald do you have some knowledge why we have a custom Windows-only implementation of File.Exists here? |
Synced with @AR-May on this - our conclusion: The root of the problem is in our custom implementation of FileExists (
|
BenchmarkDotNet v0.13.12, Windows 11 (10.0.22631.4037/23H2/2023Update/SunValley3)
No big difference in time, but managed implementation allocates. |
Thanks @MichalPavlik! We should probably file a bug with Runtime team. I'm wondering how does this allocation influence overall build perf. @JaynieBai - can you run OrchardCore build with current version (custom FileExists impl) vs version where we'd switch to |
@JanKrivanek, it was a little bit misleading as I forgot to test BenchmarkDotNet v0.13.12, Windows 11 (10.0.22631.4037/23H2/2023Update/SunValley3)
This one doesn't allocate :)
|
@JanKrivanek, @JaynieBai Replacing the |
I have no strong preference between the 2 ( |
@JaynieBai, please rewrite the #if NETFRAMEWORK
return Microsoft.IO.File.Exists(path);
#else
return File.Exists(path);
#endif This simple focused change is enough for now. We will talk about the rest of P/Invokes later. |
@MichalPavlik Microsoft.Build.UnitTests.XMakeAppTests.ConfigurationInvalid failed since not find the project file when build with copied MSBuild in the temp folder. |
This was tricky. The reason why is MS.IO.Redist returning
This exception is silently ignored as @rainersigwald Is this test critical enough to have such a complicated functional test? If so, then we have these options:
I would personally prefer to find a way how to simplify the test if we really need this one. These kind of tests can fail on magnitude of reasons, and investigation is costly. Edit: Bug report created - dotnet/maintenance-packages#117 |
No opinions so far. Let's use the simplest way :) @JaynieBai, please replace the XElement configRuntimeElement = XDocument.Load(RunnerUtilities.PathToCurrentlyRunningMsBuildExe + ".config").Root.Element("runtime");
string configContent = $@"<?xml version =""1.0""?>
<configuration>
<configSections>
<section name=""msbuildToolsets"" type=""Microsoft.Build.Evaluation.ToolsetConfigurationSection, Microsoft.Build, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"" />
<foo/>
</configSections>
<startup>
<supportedRuntime version=""v4.0""/>
</startup>
<foo/>
<msbuildToolsets default=""X"">
<foo/>
<toolset toolsVersion=""X"">
<foo/>
<property name=""MSBuildBinPath"" value=""Y""/>
<foo/>
</toolset>
<foo/>
</msbuildToolsets>
{configRuntimeElement}
</configuration>"; It adds all assembly redirects to the config file and the |
Ah sorry. I like that plan @MichalPavlik. |
I am not sure if the teams working on this component is also part of the team for Azure DevOps agents. But I would just let you know, that I just reported an issues happening in Azure DevOps self hosted agents, because of this recent change to MS.IO.Redist. https://developercommunity.visualstudio.com/t/MSBuild-Task-stopped-finding-MSBuildexe/10813148 |
Fixes #4272
Context
The root of the problem here is that our custom Windows-only implementation of File.Exists behaves differently than the regular one in BCL
Changes Made
Rewrite the WindowsFileSystem.FileExists implementation like this:
Testing
ProjectItemSpecTooLong()
Notes