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

Crossgen2 perfmap format version support #58468

Closed
4 of 5 tasks
trylek opened this issue Jul 8, 2021 · 15 comments
Closed
4 of 5 tasks

Crossgen2 perfmap format version support #58468

trylek opened this issue Jul 8, 2021 · 15 comments
Assignees
Milestone

Comments

@trylek
Copy link
Member

trylek commented Jul 8, 2021

As of

#53792

Crossgen2 newly supports a new command-line option --perfmap-format-version that currently has two legal values, 0 and 1, where 0 corresponds to the "old style Crossgen1" perfmap naming format and 1 is the "new style Crossgen2" naming format. In particular, historically Crossgen1 used to name perfmap files like this:

<assembly-name>.ni.{<MVID of the MSIL file>}.map

This is insufficient and cumbersome in Crossgen2 composite mode where multiple assemblies get compiled into a single native executable; moreover the pre-existing scheme was insufficient anyway as symbol indexation needs to take targeting OS and architecture into consideration and that wasn't reflected in the MVID. The new naming in version 1 is like this:

<assembly-name>.ni.r2rmap

The current POR is that we drop the {MVID} bit and change .map to .r2rmap to avoid clashes with traditional .map files; this will need adjusting the following SDK source files:

https://github.com/dotnet/sdk/blob/main/src/Tasks/Microsoft.NET.Build.Tasks/ResolveReadyToRunCompilers.cs
https://github.com/dotnet/sdk/blob/main/src/Tasks/Microsoft.NET.Build.Tasks/PrepareForReadyToRunCompilation.cs
https://github.com/dotnet/sdk/blob/main/src/Tasks/Microsoft.NET.Build.Tasks/RunReadyToRunCompiler.cs

We also need to adjust the script calling them:

https://github.com/dotnet/sdk/blob/main/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets

These changes should let SDK make Crossgen2 produce the new perfmap format version 1 and ultimately switch over installer build in the runtime repo to produce the new perfmap style files. According to my understanding the bulk of the follow-up work will involve consuming the metadata in the perfmap file for the purpose of symbol indexation; I believe that should be tracked by a separate work item.

This change may need a counterpart perfview change and possibly additional downstream changes I'm not yet aware of; these will probably merit creating additional specific work items as we discover them.

Thanks

Tomas

/cc @dotnet/crossgen-contrib
@dotnet/dotnet-diag
@tommcdon
@brianrob
@hoyosjs
@mikem8361

Work Needed

@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@marcpopMSFT
Copy link
Member

@tommcdon to triage and assign if this is needed in net 6.

@davmason
Copy link
Member

Tom is out on vacation until August. The perfview changes can happen out of band, we need to know and track any runtime work that happens because we have about a month left.

@trylek @hoyosjs @mikem8361 - how much work is necessary to be in the runtime to fully support the scenario?

@trylek
Copy link
Member Author

trylek commented Jul 19, 2021

I believe we need basically two changes:

  1. An SDK change tweaking PrepareReadyToRunCompilation et al and the Microsoft.NET.Publish.targets to accept a new property optionally defining the perfmap version format. SDK should be already consuming Crossgen2 Preview 7 that supports this option. When downlevel targeting .NET 5, it must assume the old naming scheme.

  2. In the runtime repo, there are two places that need adjusting: S.P.Corelib build in the coreclr partition and framework crossgenning in the installer partition. These must be conscious changes correlated with the downstream symbol indexation logic; moreover they are blocked on consuming the updated SDK supporting the new property.

Based on these initial assumptions I believe the two changes will first have a chance to combine upon the RC fork in August even though earlier testing should be possible in the SDK repo that receives regular runtime updates.

Thanks

Tomas

@davmason
Copy link
Member

Thanks Tomas! Do we have the appropriate work items tracking this? Tom is out and I'm generally unaware of this work item. It doesn't sound like any work from the diagnostics team is needed for 6, but will be out of band in perfview. Is that right?

@trylek
Copy link
Member Author

trylek commented Jul 19, 2021

Well, this was originally intended to be "the work item" tracking the outstanding work but I can easily create two separate ones for the SDK and runtime parts. I can easily make the two fixes in accordance with Tom's suggestion in our related e-mail thread on the issue but it would be great it @hoyosjs and @brianrob could confirm I'm not missing something in the overall plan. I assume that the "work from the diagnostics team" will largely involve setting up the perfmap symbol indexation mechanism but I think it's a completely new feature not necessarily tied to the .NET 6 release.

@hoyosjs
Copy link
Member

hoyosjs commented Jul 20, 2021

The symuploader work needs to happen + pipe it through arcade and then have it flow up if we want to index runtime at build time. Outside of that there's this SDK work and any work needed to have it be consumed (and some pending work in the SFX sdk).

trylek referenced this issue in dotnet/sdk Jul 23, 2021
This PR addresses the remaining work outlined in the issue

https://github.com/dotnet/sdk/issues/18813

As of .NET 6 Preview 7 Crossgen2 supports the option
--perfmap-format-version that currently supports two values, 0
(being the legacy value / default) and 1; the only difference is
that version 1 uses a different naming scheme for the output
perfmap files, dropping the {MVID} part and using the extension
".ni.r2rmap".

This PR adds support for the new option in the SDK Crossgen2
publishing logic; for .NET 5 and prior, we naturally need to stick
to the legacy naming; for .NET 6, SDK honors a new property
PublishReadyToRunPerfmapFormatVersion that can be used to override
the default.

As of the 1st commit on this PR, the SDK default is set to 1 i.e.
the "new format". This basically means that from the point of
merging this PR onwards SDK will by default produce the new
perfmap file names on Linux.

Similarly, once SDK preview 7 combines with the runtime repo
(which will likely happen as part of the RC1 fork), the installer
partition will start producing the new naming style for the
Crossgen2-compiled framework.

As this is technically a breaking change, we need to discuss whether
that's acceptable (e.g. if there was no prior support for perfmap
indexation, we probably don't need to care much); if we need tighter
control over the perfmap versioning / naming, there are two different
things we can do:

1) For now change the PerfmapFormatVersion default to 0 in the SDK
Microsoft.NET.CrossGen.targets script. This means that perfmap files
will continue to use the legacy naming scheme until someone explicitly
switches over runtime or the SDK itself later on in the future.

2) We can make a counterpart check-in to the runtime repo setting
PublishReadyToRunPerfmapFormatVersion to 0 in the installer
ReadyToRun.targets script; once we're confident to switch over,
we'll just delete the property from the scripts.

I'm still hitting a couple of errors in local testing but I'm
publishing the PR anyway as I'm hoping to solicit early feedback for the
change.

Thanks

Tomas
@trylek
Copy link
Member Author

trylek commented Jul 23, 2021

I have merged in the SDK change adding support for perfmap format version. @hoyosjs / @brianrob, any suggestions regarding the next step? Should we file a new issue to track the symbol upload / indexation logic in arcade? I'm afraid that the remaining work is pretty arcane for me, it would be great if someone more familiar with this logic could pick it up (apart from the fact that I'm OOF for one more week next week).

@hoyosjs
Copy link
Member

hoyosjs commented Jul 23, 2021

You can put it there as there's some work that needs to be done there to the SFX framework too (The globbing needs to be updated). Then runtime and WindowsDesktop use that to crossgen the shared framework I believe. ASP will need to happen separately as they don't use that. Also @trylek, do you know if runtime uses the live crossgen2, or does it use the one in the SDK? Because if so this becomes post-RC1 work.

@hoyosjs
Copy link
Member

hoyosjs commented Aug 4, 2021

Added the details of the missing work items to consume this. Except for the last one, I thing all are needed if we are going to get this for .NET 6.

@tommcdon tommcdon transferred this issue from dotnet/sdk Aug 31, 2021
@dotnet-issue-labeler dotnet-issue-labeler bot added area-crossgen2-coreclr untriaged New issue has not been triaged by the area owner labels Aug 31, 2021
@tommcdon tommcdon added this to the 6.0.0 milestone Aug 31, 2021
@tommcdon tommcdon removed the untriaged New issue has not been triaged by the area owner label Aug 31, 2021
@tommcdon tommcdon removed their assignment Aug 31, 2021
@tommcdon
Copy link
Member

@mangod we are transferring this issue to crossgen2 as we discovered there is work left on it. Juan will be updating the checklist with the remaining work

@mangod9
Copy link
Member

mangod9 commented Aug 31, 2021

so this still requires work in 6?

@tommcdon
Copy link
Member

tommcdon commented Sep 1, 2021

@mangod yes this is net6 bug fix work. @hoyosjs is authoring a pr

@mangod9
Copy link
Member

mangod9 commented Sep 15, 2021

@hoyosjs assume this can now be closed based on your PR?

@mangod9
Copy link
Member

mangod9 commented Sep 15, 2021

Closing this issue for now.

@mangod9 mangod9 closed this as completed Sep 15, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Nov 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants