Ejemplo n.º 1
0
        protected override void AttachToEvents(TraceEventSession session, Benchmark benchmark)
        {
            session.Source.Clr.GCAllocationTick += gcData =>
            {
                if (StatsPerProcess.TryGetValue(gcData.ProcessID, out Stats stats))
                {
                    stats.AllocatedBytes += gcData.AllocationAmount64;
                }
            };

            session.Source.Clr.GCStart += gcData =>
            {
                if (StatsPerProcess.TryGetValue(gcData.ProcessID, out Stats stats))
                {
                    var genCounts = stats.GenCounts;
                    if (gcData.Depth >= 0 && gcData.Depth < genCounts.Length)
                    {
                        // BenchmarkDotNet calls GC.Collect(..) before/after benchmark runs, ignore these in our results!!!
                        if (gcData.Reason != GCReason.Induced)
                        {
                            genCounts[gcData.Depth]++;
                        }
                    }
                    else
                    {
                        Logger.WriteLineError(string.Format("Error Process{0}, Unexpected GC Depth: {1}, Count: {2} -> Reason: {3}", gcData.ProcessID,
                                                            gcData.Depth, gcData.Count, gcData.Reason));
                    }
                }
            };
        }
Ejemplo n.º 2
0
 private void OnPerfInfoPmcSample(PMCCounterProfTraceData obj)
 {
     if (StatsPerProcess.TryGetValue(obj.ProcessID, out var stats))
     {
         stats.Handle(obj.ProfileSource, obj.InstructionPointer);
     }
 }
        protected override void AttachToEvents(TraceEventSession session, BenchmarkCase benchmarkCase)
        {
            expectedNamespace = benchmarkCase.Descriptor.WorkloadMethod.DeclaringType.Namespace;

            Logger.WriteLine();
            Logger.WriteLineHeader(LogSeparator);
            Logger.WriteLineInfo($"{benchmarkCase.DisplayInfo}");
            Logger.WriteLineHeader(LogSeparator);

            session.Source.Clr.MethodInliningSucceeded += jitData =>
            {
                // Inliner = the parent method (the inliner calls the inlinee)
                // Inlinee = the method that is going to be "inlined" inside the inliner (it's caller)
                if (StatsPerProcess.TryGetValue(jitData.ProcessID, out _))
                {
                    var shouldPrint = !logFailuresOnly &&
                                      (!filterByNamespace ||
                                       jitData.InlinerNamespace.StartsWith(expectedNamespace) ||
                                       jitData.InlineeNamespace.StartsWith(expectedNamespace));

                    if (shouldPrint)
                    {
                        Logger.WriteLineHelp($"Inliner: {jitData.InlinerNamespace}.{jitData.InlinerName} - {jitData.InlinerNameSignature}");
                        Logger.WriteLineHelp($"Inlinee: {jitData.InlineeNamespace}.{jitData.InlineeName} - {jitData.InlineeNameSignature}");
                        Logger.WriteLineHeader(LogSeparator);
                    }
                }
            };

            session.Source.Clr.MethodInliningFailed += jitData =>
            {
                if (StatsPerProcess.TryGetValue(jitData.ProcessID, out _) &&
                    ShouldPrintEventInfo(jitData.InlinerNamespace, jitData.InlineeNamespace))
                {
                    Logger.WriteLineError($"Inliner: {jitData.InlinerNamespace}.{jitData.InlinerName} - {jitData.InlinerNameSignature}");
                    Logger.WriteLineError($"Inlinee: {jitData.InlineeNamespace}.{jitData.InlineeName} - {jitData.InlineeNameSignature}");
                    // See https://blogs.msdn.microsoft.com/clrcodegeneration/2009/10/21/jit-etw-inlining-event-fail-reasons/
                    Logger.WriteLineError($"Fail Reason: {jitData.FailReason}");
                    Logger.WriteLineHeader(LogSeparator);
                }
            };

            session.Source.Clr.MethodInliningFailedAnsi += jitData => // this is new event exposed by .NET Core 2.2 https://github.com/dotnet/coreclr/commit/95a9055dbe5f6233f75ee2d7b6194e18cc4977fd
            {
                if (StatsPerProcess.TryGetValue(jitData.ProcessID, out _) &&
                    ShouldPrintEventInfo(jitData.InlinerNamespace, jitData.InlineeNamespace))
                {
                    Logger.WriteLineError($"Inliner: {jitData.InlinerNamespace}.{jitData.InlinerName} - {jitData.InlinerNameSignature}");
                    Logger.WriteLineError($"Inlinee: {jitData.InlineeNamespace}.{jitData.InlineeName} - {jitData.InlineeNameSignature}");
                    // See https://blogs.msdn.microsoft.com/clrcodegeneration/2009/10/21/jit-etw-inlining-event-fail-reasons/
                    Logger.WriteLineError($"Fail Reason: {jitData.FailReason}");
                    Logger.WriteLineHeader(LogSeparator);
                }
            };
        }
Ejemplo n.º 4
0
 private Stats ProcessEtwEvents(Benchmark benchmark, long totalOperations)
 {
     if (BenchmarkToProcess.Count > 0)
     {
         var processToReport = BenchmarkToProcess[benchmark];
         if (StatsPerProcess.TryGetValue(processToReport, out Stats stats))
         {
             stats.TotalOperations = totalOperations;
             return(stats);
         }
     }
     return(null);
 }
Ejemplo n.º 5
0
 private Stats ProcessEtwEvents(long totalOperations)
 {
     if (ProcessIdsUsedInRuns.Count > 0)
     {
         var   processToReport = ProcessIdsUsedInRuns[0];
         Stats stats;
         if (StatsPerProcess.TryGetValue(processToReport, out stats))
         {
             stats.TotalOperations = totalOperations;
             return(stats);
         }
     }
     return(null);
 }
Ejemplo n.º 6
0
        protected override void AttachToEvents(TraceEventSession traceEventSession, BenchmarkCase benchmarkCase)
        {
            expectedNamespace = benchmarkCase.Descriptor.WorkloadMethod.DeclaringType.Namespace ?? benchmarkCase.Descriptor.WorkloadMethod.DeclaringType.FullName;

            Logger.WriteLine();
            Logger.WriteLineHeader(LogSeparator);
            Logger.WriteLineInfo($"{benchmarkCase.DisplayInfo}");
            Logger.WriteLineHeader(LogSeparator);

            traceEventSession.Source.Clr.MethodTailCallSucceeded += jitData =>
            {
                if (!logFailuresOnly && ShouldPrintEventInfo(jitData.CallerNamespace, jitData.CalleeNamespace))
                {
                    if (StatsPerProcess.TryGetValue(jitData.ProcessID, out object ignored))
                    {
                        Logger.WriteLineHelp($"Caller: {jitData.CallerNamespace}.{jitData.CallerName} - {jitData.CallerNameSignature}");
                        Logger.WriteLineHelp($"Callee: {jitData.CalleeNamespace}.{jitData.CalleeName} - {jitData.CalleeNameSignature}");
                        Logger.WriteLineHelp($"Tail prefix: {jitData.TailPrefix}");
                        Logger.WriteLineHelp($"Tail call type: {jitData.TailCallType}");
                        Logger.WriteLineHeader(LogSeparator);
                    }
                }
            };
            traceEventSession.Source.Clr.MethodTailCallFailed += jitData =>
            {
                if (ShouldPrintEventInfo(jitData.CallerNamespace, jitData.CalleeNamespace))
                {
                    if (StatsPerProcess.TryGetValue(jitData.ProcessID, out object ignored))
                    {
                        Logger.WriteLineHelp($"Caller: {jitData.CallerNamespace}.{jitData.CallerName} - {jitData.CallerNameSignature}");
                        Logger.WriteLineHelp($"Callee: {jitData.CalleeNamespace}.{jitData.CalleeName} - {jitData.CalleeNameSignature}");
                        Logger.WriteLineError($"Fail Reason: {jitData.FailReason}");
                        Logger.WriteLineHeader(LogSeparator);
                    }
                }
            };
            traceEventSession.Source.Clr.MethodTailCallFailedAnsi += jitData => // this is new event exposed by .NET Core 2.2 https://github.com/dotnet/coreclr/commit/95a9055dbe5f6233f75ee2d7b6194e18cc4977fd
            {
                if (ShouldPrintEventInfo(jitData.CallerNamespace, jitData.CalleeNamespace))
                {
                    if (StatsPerProcess.TryGetValue(jitData.ProcessID, out object ignored))
                    {
                        Logger.WriteLineHelp($"Caller: {jitData.CallerNamespace}.{jitData.CallerName} - {jitData.CallerNameSignature}");
                        Logger.WriteLineHelp($"Callee: {jitData.CalleeNamespace}.{jitData.CalleeName} - {jitData.CalleeNameSignature}");
                        Logger.WriteLineError($"Fail Reason: {jitData.FailReason}");
                        Logger.WriteLineHeader(LogSeparator);
                    }
                }
            };
        }
Ejemplo n.º 7
0
        protected override void AttachToEvents(TraceEventSession session, Benchmark benchmark)
        {
            var expectedNamespace = benchmark.Target.Method.DeclaringType.Namespace;

            Logger.WriteLine();
            Logger.WriteLineHeader(LogSeparator);
            Logger.WriteLineInfo($"{benchmark.DisplayInfo}");
            Logger.WriteLineHeader(LogSeparator);

            session.Source.Clr.MethodInliningSucceeded += jitData =>
            {
                // Inliner = the parent method (the inliner calls the inlinee)
                // Inlinee = the method that is going to be "inlined" inside the inliner (it's caller)
                object ignored;
                if (StatsPerProcess.TryGetValue(jitData.ProcessID, out ignored))
                {
                    var shouldPrint = !logFailuresOnly &&
                                      (!filterByNamespace ||
                                       jitData.InlinerNamespace.StartsWith(expectedNamespace) ||
                                       jitData.InlineeNamespace.StartsWith(expectedNamespace));

                    if (shouldPrint)
                    {
                        Logger.WriteLineHelp($"Inliner: {jitData.InlinerNamespace}.{jitData.InlinerName} - {jitData.InlinerNameSignature}");
                        Logger.WriteLineHelp($"Inlinee: {jitData.InlineeNamespace}.{jitData.InlineeName} - {jitData.InlineeNameSignature}");
                        Logger.WriteLineHeader(LogSeparator);
                    }
                }
            };

            session.Source.Clr.MethodInliningFailed += jitData =>
            {
                object ignored;
                if (StatsPerProcess.TryGetValue(jitData.ProcessID, out ignored))
                {
                    var shouldPrint = !filterByNamespace ||
                                      jitData.InlinerNamespace.StartsWith(expectedNamespace) ||
                                      jitData.InlineeNamespace.StartsWith(expectedNamespace);

                    if (shouldPrint)
                    {
                        Logger.WriteLineError($"Inliner: {jitData.InlinerNamespace}.{jitData.InlinerName} - {jitData.InlinerNameSignature}");
                        Logger.WriteLineError($"Inlinee: {jitData.InlineeNamespace}.{jitData.InlineeName} - {jitData.InlineeNameSignature}");
                        // See https://blogs.msdn.microsoft.com/clrcodegeneration/2009/10/21/jit-etw-inlining-event-fail-reasons/
                        Logger.WriteLineError($"Fail Reason: {jitData.FailReason}");
                        Logger.WriteLineHeader(LogSeparator);
                    }
                }
            };
        }
Ejemplo n.º 8
0
        protected override void AttachToEvents(TraceEventSession session, Benchmark benchmark)
        {
            session.Source.Kernel.FileIORead += readData =>
            {
                Stats stats;
                if (StatsPerProcess.TryGetValue(readData.ProcessID, out stats))
                {
                    stats.ReadBytes += readData.IoSize;
                }
            };

            session.Source.AllEvents += readData =>
            {
                Stats stats;
                if (StatsPerProcess.TryGetValue(readData.ProcessID, out stats))
                {
                    stats.ReadBytes += 0;
                }
            };
        }
Ejemplo n.º 9
0
        protected override void AttachToEvents(TraceEventSession traceEventSession, Benchmark benchmark)
        {
            expectedNamespace = benchmark.Target.Method.DeclaringType.Namespace ?? benchmark.Target.Method.DeclaringType.FullName;

            Logger.WriteLine();
            Logger.WriteLineHeader(LogSeparator);
            Logger.WriteLineInfo($"{benchmark.DisplayInfo}");
            Logger.WriteLineHeader(LogSeparator);

            traceEventSession.Source.Clr.MethodTailCallSucceeded += jitData =>
            {
                if (!logFailuresOnly && ShouldPrintEventInfo(jitData.CallerNamespace, jitData.CalleeNamespace))
                {
                    if (StatsPerProcess.TryGetValue(jitData.ProcessID, out object ignored))
                    {
                        Logger.WriteLineHelp($"Caller: {jitData.CallerNamespace}.{jitData.CallerName} - {jitData.CallerNameSignature}");
                        Logger.WriteLineHelp($"Callee: {jitData.CalleeNamespace}.{jitData.CalleeName} - {jitData.CalleeNameSignature}");
                        Logger.WriteLineHelp($"Tail prefix: {jitData.TailPrefix}");
                        Logger.WriteLineHelp($"Tail call type: {jitData.TailCallType}");
                        Logger.WriteLineHeader(LogSeparator);
                    }
                }
            };
            traceEventSession.Source.Clr.MethodTailCallFailed += jitData =>
            {
                if (ShouldPrintEventInfo(jitData.CallerNamespace, jitData.CalleeNamespace))
                {
                    if (StatsPerProcess.TryGetValue(jitData.ProcessID, out object ignored))
                    {
                        Logger.WriteLineHelp($"Caller: {jitData.CallerNamespace}.{jitData.CallerName} - {jitData.CallerNameSignature}");
                        Logger.WriteLineHelp($"Callee: {jitData.CalleeNamespace}.{jitData.CalleeName} - {jitData.CalleeNameSignature}");
                        Logger.WriteLineError($"Fail Reason: {jitData.FailReason}");
                        Logger.WriteLineHeader(LogSeparator);
                    }
                }
            };
        }