-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Add a config to MIBC format #71359
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
Add a config to MIBC format #71359
Changes from 5 commits
8319fa8
3a8f82d
0b68488
1714407
6ebfbcb
11cab7a
776061a
285eab6
03beced
1cf0aef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -354,6 +354,38 @@ static int InnerDumpMain(CommandLineOptions commandLineOptions) | |||||
| return 0; | ||||||
| } | ||||||
|
|
||||||
| static MibcConfig ParseMibcConfigsAndMerge(TypeSystemContext tsc, params PEReader[] pEReader) | ||||||
| { | ||||||
| MibcConfig firstCfg = null; | ||||||
| foreach (PEReader peReader in pEReader) | ||||||
| { | ||||||
| MibcConfig config = MIbcProfileParser.ParseMibcConfig(tsc, peReader); | ||||||
| if (firstCfg == null) | ||||||
| { | ||||||
| firstCfg = config; | ||||||
| } | ||||||
| else | ||||||
| { | ||||||
| if (firstCfg.Runtime != config.Runtime) | ||||||
| { | ||||||
| PrintMessage( | ||||||
| $"Warning: Attempting to merge MIBCs collected on different runtimes: {firstCfg.Runtime} != {config.Runtime}"); | ||||||
| } | ||||||
| if (firstCfg.FormatVersion != config.FormatVersion) | ||||||
| { | ||||||
| PrintMessage( | ||||||
| $"Warning: Attempting to merge MIBCs with different format versions: {firstCfg.FormatVersion} != {config.FormatVersion}"); | ||||||
| } | ||||||
| if (firstCfg.Os != config.Os || | ||||||
| firstCfg.Arch != config.Arch) | ||||||
| { | ||||||
| PrintMessage( | ||||||
| $"Warning: Attempting to merge MIBCs collected on different RIDs: {firstCfg.Os}-{firstCfg.Arch} != {config.Os}-{config.Arch}"); | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
| return firstCfg; | ||||||
| } | ||||||
|
|
||||||
| static int InnerMergeMain(CommandLineOptions commandLineOptions) | ||||||
| { | ||||||
|
|
@@ -399,7 +431,8 @@ static int InnerMergeMain(CommandLineOptions commandLineOptions) | |||||
| ProfileData.MergeProfileData(ref partialNgen, mergedProfileData, MIbcProfileParser.ParseMIbcFile(tsc, peReader, assemblyNamesInBubble, onlyDefinedInAssembly: null)); | ||||||
| } | ||||||
|
|
||||||
| int result = MibcEmitter.GenerateMibcFile(tsc, commandLineOptions.OutputFileName, mergedProfileData.Values, commandLineOptions.ValidateOutputFile, commandLineOptions.Uncompressed); | ||||||
| MibcConfig mergedConfig = ParseMibcConfigsAndMerge(tsc, mibcReaders); | ||||||
| int result = MibcEmitter.GenerateMibcFile(mergedConfig, tsc, commandLineOptions.OutputFileName, mergedProfileData.Values, commandLineOptions.ValidateOutputFile, commandLineOptions.Uncompressed); | ||||||
| if (result == 0 && commandLineOptions.InheritTimestamp) | ||||||
| { | ||||||
| commandLineOptions.OutputFileName.CreationTimeUtc = commandLineOptions.InputFilesToMerge.Max(fi => fi.CreationTimeUtc); | ||||||
|
|
@@ -794,7 +827,8 @@ static void PrintLikelihoodHistogram(double[] likelihoods) | |||||
|
|
||||||
| static void PrintMibcStats(ProfileData data) | ||||||
| { | ||||||
| List<MethodProfileData> methods = data.GetAllMethodProfileData().ToList(); | ||||||
| PrintOutput(data.Config?.ToString()); | ||||||
| List <MethodProfileData> methods = data.GetAllMethodProfileData().ToList(); | ||||||
| List<MethodProfileData> profiledMethods = methods.Where(spd => spd.SchemaData != null).ToList(); | ||||||
| PrintOutput($"# Methods: {methods.Count}"); | ||||||
| PrintOutput($"# Methods with any profile data: {profiledMethods.Count(spd => spd.SchemaData.Length > 0)}"); | ||||||
|
|
@@ -1659,13 +1693,24 @@ void AddToInstrumentationData(int eventClrInstanceId, long methodID, int methodF | |||||
| GenerateJittraceFile(commandLineOptions.OutputFileName, methodsUsedInProcess, commandLineOptions.JitTraceOptions); | ||||||
| else if (commandLineOptions.FileType.Value == PgoFileType.mibc) | ||||||
| { | ||||||
| var config = new MibcConfig(); | ||||||
|
|
||||||
| // Look for OS and Arch, e.g. "Windows" and "x64" | ||||||
| TraceEvent processInfo = p.EventsInProcess.Filter(t => t.EventName == "ProcessInfo").FirstOrDefault(); | ||||||
| config.Os = processInfo?.PayloadByName("OSInformation")?.ToString(); | ||||||
| config.Arch = processInfo?.PayloadByName("ArchInformation")?.ToString(); | ||||||
|
|
||||||
| // Look for Sku, e.g. "CoreClr" | ||||||
| TraceEvent runtimeStart = p.EventsInProcess.Filter(t => t.EventName == "Runtime/Start").FirstOrDefault(); | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How does the Sku work (what does it stand for)? It would be nice to have the mono runtime be emitted, so if we use the Sku for emitting runtime, would it be unproblematic to extend the Sku enum to also contain Mono (not sure if there is a trickle effect)? What is the
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wasn't sure what to pick for runtime so probably it would be easier if you tell me which event to analyze cc @lateralusX
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If that eventname is the same as runtime/src/mono/mono/eventpipe/ep-rt-mono.c Line 2804 in 41d9c1c
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here is the events we collect -
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So I assume the current impl is correct as is, right? it does poll "Runtime/Start" event and extract Sku so once Mono is added we're all set
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @lateralusX @EgorBo I'm thinking the value should be 0x4 as 0x3 will show up as DesktopClr, CoreClr since it matches those bits (0x1 || 0x2). I obtained a trace with I also verified that we should be able to obtain the actual Sku value from the Mono AOT Compiler side as well. I'll put up a separate PR to integrate the .mibc file validation. I think we should extend the relevant Sku structs and Mono additions I mentioned earlier
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is anything treating the sku as a bit set? Seems like it shouldn't be.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jakobbotsch I'm not sure what the main rationale is between making something a bitmap vs a valuemap, but this might be why its behaving as such runtime/src/coreclr/vm/ClrEtwAll.man Line 611 in 4a63cb2
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see, seems reasonable then. |
||||||
| config.Runtime = runtimeStart?.PayloadByName("Sku")?.ToString(); | ||||||
|
|
||||||
| ILCompiler.MethodProfileData[] methodProfileData = new ILCompiler.MethodProfileData[methodsUsedInProcess.Count]; | ||||||
| for (int i = 0; i < methodProfileData.Length; i++) | ||||||
| { | ||||||
| ProcessedMethodData processedData = methodsUsedInProcess[i]; | ||||||
| methodProfileData[i] = new ILCompiler.MethodProfileData(processedData.Method, ILCompiler.MethodProfilingDataFlags.ReadMethodCode, processedData.ExclusiveWeight, processedData.WeightedCallData, 0xFFFFFFFF, processedData.InstrumentationData); | ||||||
| } | ||||||
| return MibcEmitter.GenerateMibcFile(tsc, commandLineOptions.OutputFileName, methodProfileData, commandLineOptions.ValidateOutputFile, commandLineOptions.Uncompressed); | ||||||
| return MibcEmitter.GenerateMibcFile(config, tsc, commandLineOptions.OutputFileName, methodProfileData, commandLineOptions.ValidateOutputFile, commandLineOptions.Uncompressed); | ||||||
| } | ||||||
| } | ||||||
| return 0; | ||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.