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

Optimize CoreCLR Helix runs by pruning the CORE_ROOT folder content #35243

Merged
merged 3 commits into from
Apr 26, 2020

Conversation

trylek
Copy link
Member

@trylek trylek commented Apr 21, 2020

This change limits the content of CORE_ROOT by removing some of the
unused artifacts, most notably the sharedFramework subfolder that
is not used by CoreCLR tests at all. The aim of this change is
to optimize the execution of CoreCLR tests in Helix where according
to Jarret's findings a large amount of time gets spent just
downloading and unpacking the test payloads.

In technical terms I have slightly changed the semantics of the target
CreateTestOverlay (or rather of its dependent target
CopyDependencyToCoreRoot) so that it also copies over
the appropriate binary artifacts. This let me simplify the cmd / sh
script logic and introduce common filtering at the MSBuild level.

Thanks

Tomas

This change limits the content of CORE_ROOT by removing some of the
unused artifacts, most notably the sharedFramework subfolder that
is not used by CoreCLR tests at all. The aim of this change is
to optimize the execution of CoreCLR tests in Helix where according
to Jarret's findings a large amount of time gets spent just
downloading and unpacking the test payloads.

Thanks

Tomas
@trylek trylek requested review from jkoritzinsky and jashook April 21, 2020 18:28
@trylek trylek changed the title WIP: Optimize CoreCLR Helix runs by pruning the CORE_ROOT folder content Optimize CoreCLR Helix runs by pruning the CORE_ROOT folder content Apr 21, 2020
@trylek
Copy link
Member Author

trylek commented Apr 21, 2020

Basic testing mostly seems to work, I need to run CG1 / CG2 and more tests but the AzDO job scheduling is currently experiencing some authentication issues so I need to wait on that. According to my local measurements this trims CORE_ROOT to about one half (less than 400 MB).

@trylek trylek requested review from safern and janvorli April 24, 2020 19:37

<!-- Add binary dependencies to copy-local items -->
<RunTimeDependencyCopyLocal
Include="$(CoreCLRArtifactsPath)/%(RunTimeArtifactsIncludeFolders.Identity)*"
Copy link
Member

Choose a reason for hiding this comment

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

Small nit in these two lines: CoreCLRArtifactsPath should already contain a trailing /:

<CoreCLRArtifactsPath Condition="'$(CoreCLROverridePath)' != ''">$([MSBuild]::NormalizeDirectory('$(CoreCLROverridePath)'))</CoreCLRArtifactsPath>

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for pointing that out, fixed in 2nd commit.

<RunTimeDependencyCopyLocal
Include="$(CoreCLRArtifactsPath)/%(RunTimeArtifactsIncludeFolders.Identity)*"
Exclude="@(RunTimeArtifactsExcludeFiles -> '$(CoreCLRArtifactsPath)/%(Identity)')">
<TargetDir>%(RunTimeArtifactsIncludeFolders.Identity)</TargetDir>
Copy link
Member

Choose a reason for hiding this comment

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

You could simplify this by setting the metadata inline. I.e:

<RunTimeDependencyCopyLocal
          Include="$(CoreCLRArtifactsPath)/%(RunTimeArtifactsIncludeFolders.Identity)*"
          Exclude="@(RunTimeArtifactsExcludeFiles -> '$(CoreCLRArtifactsPath)/%(Identity)')"
          TargetDir="%(RuntimeArtifactsIncludeFolders.Identity)" />

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for teaching me MSBuild, I never knew that :D. Fixed in 2nd commit.

Copy link
Member

@safern safern left a comment

Choose a reason for hiding this comment

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

Logic-wise looks good to me. Don't know much about the coreclr tests but as long as they're green feel free to merge 😄

@trylek trylek closed this Apr 26, 2020
@trylek trylek reopened this Apr 26, 2020
@trylek trylek merged commit 58f931b into dotnet:master Apr 26, 2020
@trylek trylek deleted the CoreRoot branch April 26, 2020 22:07
<RunTimeDependencyCopyLocalFile Include="@(AllResolvedRuntimeDependencies)" Exclude="@(RunTimeDependencyExcludeFiles)"/>
<RunTimeDependencyCopyLocal Include="@(RunTimeDependencyCopyLocalFile -> '%(File)')" />
<RunTimeDependencyCopyLocal Include="$(TargetingPackPath)/*" />

<RunTimeArtifactsExcludeFiles Include="protononjit.dll" />
Copy link
Contributor

Choose a reason for hiding this comment

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

That change affects @dotnet/jit-contrib team workflow because now we don't have these altjits in CoreRoot after running src\coreclr\build-test.cmd.
I remember there was an environment variable, like ci or similar to distinguish runs in ci from local runs, could that be used to make optimizations in this PR only when it is set and do not affect others?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, I was curious what would break :-). Will fix. Can you point me to some pipeline or script I can run to verify the change? Other than that, if this is just about the protononjit / linuxonjit binaries, these aren't very long so I guess we can put them back unconditionally.

Copy link
Contributor

Choose a reason for hiding this comment

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

Check that these altjit.dlls are in the Core_Root. I am not sure if any additional verification is needed, but you can build an individual test and try to run it:

set ARCH=x86
set MODE=Checked
set RUNTIME_PATH=F:\git\runtime
%RUNTIME_PATH%\src\coreclr\build-test.cmd skipnative skipmanaged %ARCH% %MODE% /p:LibrariesConfiguration=Release

REM build a test
%RUNTIME_PATH%\.dotnet\dotnet.exe msbuild /p:TargetArchitecture=%ARCH% /p:Configuration=%MODE% /p:LibrariesConfiguration=Release %RUNTIME_PATH%\src\coreclr\tests\src\JIT\Regression\JitBlue\Runtime_33884\Runtime_33884.csproj

set COMPlus_AltJit=*
set COMPlus_AltJitName=protononjit.dll
set CORE_ROOT=%RUNTIME_PATH%\artifacts\tests\coreclr\Windows_NT.%ARCH%.%MODE%\Tests\CORE_ROOT

REM run the test with altjit
%RUNTIME_PATH%\artifacts\tests\coreclr\Windows_NT.x86.Checked\JIT\Regression\JitBlue\Runtime_33884\Runtime_33884\Runtime_33884.cmd

Copy link
Member Author

Choose a reason for hiding this comment

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

OK, great. Just tried this (on x64 that I have a complete build for readily available) and I do see some difference - the test you mentioned passes with the normal JIT, with the protononjit it crashes as follows:

BEGIN EXECUTION
 "d:\git\runtime2\artifacts\tests\coreclr\Windows_NT.x64.Checked\tests\Core_Root\corerun.exe" Runtime_33884.dll

Assert failure(PID 12860 [0x0000323c], Thread: 14480 [0x3890]): Assertion failed 'tree->IsLocal() || (tree->OperGet() == GT_RET_EXPR) || (tree->OperGet() == GT_CALL) || ((tree->gtOper == GT_ADDR) && varTypeIsSIMD(tree->gtGetOp1()))' in 'System.SpanHelpers:IndexOf(byref,ushort,int):int' during 'Importation' (IL size 899)

    File: D:\git\runtime2\src\coreclr\src\jit\simd.cpp Line: 1197
    Image: d:\git\runtime2\artifacts\tests\coreclr\Windows_NT.x64.Checked\tests\Core_Root\CoreRun.exe

Expected: 100
Actual: -1073740286
END EXECUTION - FAILED
FAILED

Is that the expected behavior?

Copy link
Contributor

Choose a reason for hiding this comment

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

That's the expected behavior because the SIMD size is different. It should work if you set COMPlus_SIMD16ByteOnly=1

@BruceForstall
Copy link
Member

@trylek It looks like this change broke Windows arm32/arm64 R2R outerloop legs:

https://dev.azure.com/dnceng/public/_build/results?buildId=618430&view=logs&j=6a6c3cd4-d826-5910-fefe-97d01e9d1991&t=7d64d43a-07ce-5289-f10f-7ed124b0d13a

with errors like:

"F:\workspace\_work\1\s\artifacts\tests\coreclr\Windows_NT.arm64.Checked\Tests\Core_Root\x64\crossgen.exe"  /Platform_Assemblies_Paths "F:\workspace\_work\1\s\artifacts\tests\coreclr\Windows_NT.arm64.Checked\Tests\Core_Root" /in "F:\workspace\_work\1\s\artifacts\tests\coreclr\Windows_NT.arm64.Checked\Tests\Core_Root\System.AppContext.dll" /out "F:\workspace\_work\1\s\artifacts\tests\coreclr\Windows_NT.arm64.Checked\Tests\Core_Root\temp.ni._dll"
The system cannot find the path specified.
Unable to precompile "F:\workspace\_work\1\s\artifacts\tests\coreclr\Windows_NT.arm64.Checked\Tests\Core_Root\System.AppContext.dll", exit code is 3

@ghost ghost locked as resolved and limited conversation to collaborators Dec 9, 2020
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.

5 participants