Skip to content

Conversation

@daxian-dbw
Copy link
Member

PR Summary

Supersede #16265

The .NET team has confirmed that ALL .NET 6 runtime assemblies should be R2R images. See dotnet/runtime#60779 for details.
During my verification, I found some runtime assemblies that are not R2R images, but it turns out that is by design because those assemblies as pure façade assemblies. See dotnet/runtime#60782 for details.

I have also verified that <PublishReadyToRun>true</PublishReadyToRun> actually crossgen'ed all the package assemblies pwsh depends on, including all that in the $commonAssembliesForAddType array today. The following is the pdb generated for those crossgen'ed assemblies.

InputObject                                           SideIndicator
-----------                                           -------------
Markdig.Signed.ni.pdb                                 =>
Microsoft.ApplicationInsights.ni.pdb                  =>
Microsoft.CodeAnalysis.CSharp.ni.pdb                  =>
Microsoft.CodeAnalysis.ni.pdb                         =>
Microsoft.Extensions.ObjectPool.ni.pdb                =>
Microsoft.Management.Infrastructure.CimCmdlets.ni.pdb =>
Microsoft.Management.Infrastructure.Native.ni.pdb     =>
Microsoft.Management.Infrastructure.ni.pdb            =>
Microsoft.PowerShell.Commands.Diagnostics.ni.pdb      =>
Microsoft.PowerShell.Commands.Management.ni.pdb       =>
Microsoft.PowerShell.Commands.Utility.ni.pdb          =>
Microsoft.PowerShell.ConsoleHost.ni.pdb               =>
Microsoft.PowerShell.CoreCLR.Eventing.ni.pdb          =>
Microsoft.PowerShell.GraphicalHost.ni.pdb             =>
Microsoft.PowerShell.MarkdownRender.ni.pdb            =>
Microsoft.PowerShell.Security.ni.pdb                  =>
Microsoft.WSMan.Management.ni.pdb                     =>
Microsoft.WSMan.Runtime.ni.pdb                        =>
Namotion.Reflection.ni.pdb                            =>
Newtonsoft.Json.ni.pdb                                =>
NJsonSchema.ni.pdb                                    =>
pwsh.ni.pdb                                           =>
System.ComponentModel.Composition.ni.pdb              =>
System.ComponentModel.Composition.Registration.ni.pdb =>
System.Data.Odbc.ni.pdb                               =>
System.Data.OleDb.ni.pdb                              =>
System.Data.SqlClient.ni.pdb                          =>
System.DirectoryServices.AccountManagement.ni.pdb     =>
System.DirectoryServices.Protocols.ni.pdb             =>
System.IO.Ports.ni.pdb                                =>
System.Management.Automation.ni.pdb                   =>
System.Management.ni.pdb                              =>
System.Net.Http.WinHttpHandler.ni.pdb                 =>
System.Private.ServiceModel.ni.pdb                    =>
System.Reflection.Context.ni.pdb                      =>
System.Runtime.Caching.ni.pdb                         =>
System.ServiceModel.Syndication.ni.pdb                =>
System.ServiceProcess.ServiceController.ni.pdb        =>
System.Speech.ni.pdb                                  =>

Given all above, we should just remove the Start-CrossGen code, and also remove the -CrossGen switch parameter from Start-PSBuild, because we have <PublishReadyToRun Condition=" '$(Configuration)' != 'Debug' ">true</PublishReadyToRun> in PowerShell.Common.props file, so unless explicitly disabling R2R (for fxdependent* and minSize packages), our build will generate R2R images for release builds.

Also add <PublishReadyToRunEmitSymbols>true</PublishReadyToRunEmitSymbols> to generate the native symbols for the R2R images when publishing R2R, because profiler needs the symbols generated by <PublishReadyToRunEmitSymbols> to examine the R2R files. However, those symbols are only useful for profiling the startup scenario of PowerShell because PowerShell enables tiered compilation which will overwrite the R2R code.

PR Context

PR Checklist

@ghost ghost assigned iSazonov Oct 22, 2021
@daxian-dbw daxian-dbw marked this pull request as draft October 23, 2021 00:01
@daxian-dbw daxian-dbw marked this pull request as ready for review October 23, 2021 01:50
@iSazonov
Copy link
Collaborator

However, those symbols are only useful for profiling the startup scenario of PowerShell because PowerShell enables tiered compilation which will overwrite the R2R code.

For profiling other scenarios users can set .Net environment variable DOTNET_TieredCompilation = 0

@iSazonov
Copy link
Collaborator

Could you please see search results https://github.com/PowerShell/PowerShell/search?l=PowerShell&q=Crossgen I see more files with crossgen word.

@iSazonov iSazonov added the Area-Maintainers-Build specific to affecting the build label Oct 23, 2021
@iSazonov iSazonov added CL-BuildPackaging Indicates that a PR should be marked as a build or packaging change in the Change Log and removed Area-Maintainers-Build specific to affecting the build labels Oct 23, 2021
Copy link
Member

@TravisEz13 TravisEz13 left a comment

Choose a reason for hiding this comment

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

Should we take this for 7.2?

@TravisEz13 TravisEz13 merged commit f2d5ae7 into PowerShell:master Oct 27, 2021
@adityapatwardhan
Copy link
Member

@daxian-dbw Can we do a quick startup perf check before and after the change?

@daxian-dbw daxian-dbw deleted the crossgen branch October 27, 2021 20:24
@daxian-dbw
Copy link
Member Author

OK, will do so.

@daxian-dbw
Copy link
Member Author

I don't see a noticeable difference on both Windows and Linux with or without this change.

  • on my Windows machine, they are both in the range of 580 - 620 ms (sometimes slower than 620ms, and sometimes faster than 580ms)
  • on my WSL v2 with Ubuntu 18.04, they are both in the range of 660 - 700 ms (sometimes slower than 700ms, and sometimes faster than 660ms)

@ghost
Copy link

ghost commented Nov 8, 2021

🎉v7.2.0 has been released which incorporates this pull request.:tada:

Handy links:

@ghost
Copy link

ghost commented Dec 16, 2021

🎉v7.3.0-preview.1 has been released which incorporates this pull request.:tada:

Handy links:

TrapGodBrim pushed a commit to TrapGodBrim/PowerShell that referenced this pull request Jan 19, 2022
…s for `R2R` images (PowerShell#16297)

* Clean up crossgen related build scripts

* Fix ci.psm1

* Clean up '-CrossGen' use in a few other files
daxian-dbw added a commit to daxian-dbw/PowerShell that referenced this pull request Mar 9, 2022
…s for `R2R` images (PowerShell#16297)

* Clean up crossgen related build scripts

* Fix ci.psm1

* Clean up '-CrossGen' use in a few other files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backport-7.2.x-Done CL-BuildPackaging Indicates that a PR should be marked as a build or packaging change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants