Skip to content

Conversation

@BruceForstall
Copy link
Contributor

For each class, add JIT/EE calls to getAssemblyName so the SuperPMI
collections contain this information. This can be useful to try and track
down where a particular function in a large method context hive came
from.

Only do this when COMPlus_EnableExtraSuperPmiQueries=1 is set.

For each class, add JIT/EE calls to getAssemblyName so the SuperPMI
collections contain this information. This can be useful to try and track
down where a particular function in a large method context hive came
from.

Only do this when `COMPlus_EnableExtraSuperPmiQueries=1` is set.
@ghost ghost added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Feb 19, 2021
@BruceForstall
Copy link
Contributor Author

@sandreenko PTAL
cc @dotnet/jit-contrib

Copy link
Contributor

@sandreenko sandreenko left a comment

Choose a reason for hiding this comment

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

Does it affect the merge duplicate phase? Would two methods compiled under different modules be different now?

what is the easiest way to dump it during replay for a given mc file?

Packet_SigInstHandleMap = 184,
Packet_AllocPgoInstrumentationBySchema = 186, // Added 1/4/2021
Packet_GetPgoInstrumentationResults = 187, // Added 1/4/2021
Packet_GetClassModule = 189, // Added 2/19/2021
Copy link
Contributor

Choose a reason for hiding this comment

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

why not use some of the retired numbers or do you want them to be together?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've never reused retired numbers.

Originally, there was some idea that collections wouldn't be so tightly tied to the particular build of spmi, thus not reusing was a good thing. At this point, we don't try to support that, so we could renumber everything, sort the list, and squash out all the unused numbers, if we wanted.

(void)info.compCompHnd->getAssemblyName(info.compCompHnd->getModuleAssembly(info.compCompHnd->getClassModule(info.compClassHnd)));
}
#endif // DEBUG

Copy link
Member

Choose a reason for hiding this comment

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

Does this work out ok for the unusual cases like stubs, LGC, etc...?

@kunalspathak
Copy link
Contributor

Just that I know how to use this, can you give an example use-case? Can we use this with /dumpMap , etc?

@BruceForstall
Copy link
Contributor Author

Does it affect the merge duplicate phase? Would two methods compiled under different modules be different now?

I was worried about that, but this won't contribute to determining if a function is "unique". The only thing used is the "method identity", which is (1) the IL code, (2) the method signature + calling convention + CorInfoOptions + hot/cold region + jit flags + ISA flags.

SPMI basically assumes that if the (salient) "input" to the JIT is the same, it will produce the same output. It's possible there are other inputs that could affect the output, like the assembly, but it's possibly a trade-off between precision and SPMI MCH file size and useful difference of MCs.

what is the easiest way to dump it during replay for a given mc file?

mcs -dump N foo.mch for method context N. Then you'll see something like:

GetAssemblyName - 1
0-GetAssemblyName assem-000002E226DC7DD0, value-4 'FPDist_ro'

(this example was from BringUpTest:FPDist(float,float,float,float):float)

Just that I know how to use this, can you give an example use-case? Can we use this with /dumpMap , etc?

I thought about adding it to -dumpMap. We do get multiple entries, which I believe is when we are considering inlining cross-module. E.g.,

GetAssemblyName - 5
0-GetAssemblyName assem-0000027B5D2F2700, value-28 'System.Private.CoreLib'
1-GetAssemblyName assem-0000027B5ED42E30, value-55 'System.Diagnostics.Process'
2-GetAssemblyName assem-0000027B7F8E25A0, value-86 'System.Runtime.InteropServices.RuntimeInformation'
3-GetAssemblyName assem-0000027B5ED417B0, value-140 'System.ComponentModel.Primitives'
4-GetAssemblyName assem-0000027B5ED42DB0, value-4 'Coreclr.TestWrapper'

(for CoreclrTestLib.CoreclrTestWrapperLib:RunTest(ref,ref,ref,ref,ref):int:this)

So we'd need a way to figure out which is the "root" assembly name to make outputting a single "-dumpMap" entry valuable.

Does this work out ok for the unusual cases like stubs, LGC, etc...?

Are you worried that one of getAssemblyName / getModuleAssembly / getClassModule will fail in these cases (and spmi will crash)? I tried to make repGetAssemblyName() resilient to missing info. The others should also be resilient to garbage, but I could be wrong. I can certainly trigger a collection on this PR and see what we get (beyond what I tested locally). Would we see these things in crossgen? crossgen2? PMI? benchmark run? all of the above?

@BruceForstall
Copy link
Contributor Author

Does this work out ok for the unusual cases like stubs, LGC, etc...?

Dynamic methods get an artificial "Anonymously Hosted DynamicMethods Assembly" name:

AssemblyName assemblyName = new AssemblyName("Anonymously Hosted DynamicMethods Assembly");

The common ILStubClass:IL_STUB_PInvoke function gets a useful-looking name.

I see a few names that are GUIDs, e.g., I see a benchmarks function <>c:.cctor() with assembly name 29984b41-8a88-4405-a40f-a259aa7aa626.

Across all the SPMI collections (including tests), I see 7598 unique assembly names.

@BruceForstall BruceForstall merged commit a350bc6 into dotnet:master Feb 20, 2021
@BruceForstall BruceForstall deleted the AddAssemblyName branch February 20, 2021 21:56
@JulieLeeMSFT JulieLeeMSFT added this to the 6.0.0 milestone Feb 23, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Mar 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants