Skip to content

Commit eeb234e

Browse files
authored
Truly Dynamic Event (#2051)
* Formatting * Truly Dynamic Event * Remove old tuning info * Rename classes for code review feedback
1 parent d8706f2 commit eeb234e

File tree

4 files changed

+106
-361
lines changed

4 files changed

+106
-361
lines changed

src/PerfView/GcStats.cs

-24
Original file line numberDiff line numberDiff line change
@@ -481,30 +481,6 @@ public static void ToXmlAttribs(TextWriter writer, TraceProcess stats, TraceLoad
481481
writer.WriteLine("/>");
482482
}
483483

484-
if (gc.HeapCountTuning != null || gc.HeapCountSample != null)
485-
{
486-
writer.Write(" <DynamicData");
487-
if (gc.HeapCountTuning != null)
488-
{
489-
writer.Write(" NewHeapCount={0}", StringUtilities.QuotePadLeft(gc.HeapCountTuning.NewHeapCount.ToString("n0"), 10));
490-
writer.Write(" MedianThroughputCostPercent={0}", StringUtilities.QuotePadLeft(gc.HeapCountTuning.MedianThroughputCostPercent.ToString("n3"), 10));
491-
writer.Write(" SmoothedMedianThroughputCostPercent={0}", StringUtilities.QuotePadLeft(gc.HeapCountTuning.SmoothedMedianThroughputCostPercent.ToString("n3"), 10));
492-
writer.Write(" ThroughputCostPercentReductionPerStepUp={0}", StringUtilities.QuotePadLeft(gc.HeapCountTuning.ThroughputCostPercentReductionPerStepUp.ToString("n3"), 10));
493-
writer.Write(" ThroughputCostPercentIncreasePerStepDown={0}", StringUtilities.QuotePadLeft(gc.HeapCountTuning.ThroughputCostPercentIncreasePerStepDown.ToString("n3"), 10));
494-
writer.Write(" SpaceCostPercentIncreasePerStepUp={0}", StringUtilities.QuotePadLeft(gc.HeapCountTuning.SpaceCostPercentIncreasePerStepUp.ToString("n3"), 10));
495-
writer.Write(" SpaceCostPercentDecreasePerStepDown={0}", StringUtilities.QuotePadLeft(gc.HeapCountTuning.SpaceCostPercentDecreasePerStepDown.ToString("n3"), 10));
496-
}
497-
498-
if (gc.HeapCountSample != null)
499-
{
500-
writer.Write(" ElapsedTimeBetweenGCsMSec={0}", StringUtilities.QuotePadLeft(gc.HeapCountSample.ElapsedTimeBetweenGCsMSec.ToString("n3"), 10));
501-
writer.Write(" GCPauseTimeMSec={0}", StringUtilities.QuotePadLeft(gc.HeapCountSample.GCPauseTimeMSec.ToString("n3"), 10));
502-
writer.Write(" MslWaitTimeMSec={0}", StringUtilities.QuotePadLeft(gc.HeapCountSample.MslWaitTimeMSec.ToString("n3"), 10));
503-
}
504-
505-
writer.WriteLine("/>");
506-
}
507-
508484
if (gc.HeapStats != null)
509485
{
510486
writer.Write(" <HeapStats");

src/TraceEvent/Computers/TraceManagedProcess.cs

+31-50
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//
44
// This program uses code hyperlinks available as part of the HyperAddin Visual Studio plug-in.
55
// It is available from http://www.codeplex.com/hyperAddin
6-
// using Microsoft.Diagnostics.Tracing.Parsers;
6+
77
using Microsoft.Diagnostics.Tracing.Analysis.GC;
88
using Microsoft.Diagnostics.Tracing.Analysis.JIT;
99
using Microsoft.Diagnostics.Tracing.Etlx;
@@ -874,16 +874,10 @@ internal static void SetupCallbacks(TraceEventDispatcher source)
874874
GCStats.ProcessCommittedUsage(stats, committedUsage);
875875
};
876876

877-
source.Clr.GCDynamicEvent.GCHeapCountTuning += delegate (HeapCountTuningTraceEvent heapCountTuning)
878-
{
879-
var stats = currentManagedProcess(heapCountTuning.UnderlyingEvent);
880-
GCStats.ProcessHeapCountTuning(stats, heapCountTuning);
881-
};
882-
883-
source.Clr.GCDynamicEvent.GCHeapCountSample += delegate (HeapCountSampleTraceEvent heapCountSample)
877+
source.Clr.GCDynamicEvent.GCDynamicTraceEvent += delegate (GCDynamicTraceEvent gcDynamic)
884878
{
885-
var stats = currentManagedProcess(heapCountSample.UnderlyingEvent);
886-
GCStats.ProcessHeapCountSample(stats, heapCountSample);
879+
var stats = currentManagedProcess(gcDynamic.UnderlyingEvent);
880+
GCStats.ProcessGCDynamicEvent(stats, gcDynamic);
887881
};
888882

889883
source.Clr.GCGlobalHeapHistory += delegate (GCGlobalHeapHistoryTraceData data)
@@ -2143,8 +2137,6 @@ public double PromotedMB
21432137
}
21442138
}
21452139

2146-
public HeapCountTuning HeapCountTuning { get; internal set; }
2147-
public HeapCountSample HeapCountSample { get; internal set; }
21482140
public CommittedUsage CommittedUsageBefore { get; internal set; }
21492141
public CommittedUsage CommittedUsageAfter { get; internal set; }
21502142

@@ -2416,7 +2408,7 @@ public GCCondemnedReasons[] PerHeapCondemnedReasons
24162408
}
24172409

24182410
public enum TimingType
2419-
{
2411+
{
24202412
/// <summary>
24212413
/// This field records the time spent for marking roots (except objects pointed by sizedref handle and their descendents)
24222414
///
@@ -2522,7 +2514,8 @@ public int FindFirstHighestCondemnedHeap()
25222514
if (gen == GenNumberHighest)
25232515
{
25242516
return HeapIndex;
2525-
} }
2517+
}
2518+
}
25262519

25272520
return 0;
25282521
}
@@ -3328,6 +3321,18 @@ public PinnedPlug(ulong s, ulong e)
33283321

33293322
private float[] GCCpuServerGCThreads = null;
33303323

3324+
private List<GCDynamicEvent> dynamicEvents = new List<GCDynamicEvent>();
3325+
3326+
public List<GCDynamicEvent> DynamicEvents
3327+
{
3328+
get { return this.dynamicEvents; }
3329+
}
3330+
3331+
internal void AddDynamicEvent(GCDynamicEvent dynamicEvent)
3332+
{
3333+
dynamicEvents.Add(dynamicEvent);
3334+
}
3335+
33313336
#endregion
33323337
}
33333338

@@ -4933,12 +4938,12 @@ internal static void ProcessCommittedUsage(TraceLoadedDotNetRuntime proc, Commit
49334938
{
49344939
CommittedUsage traceData = new CommittedUsage
49354940
{
4936-
Version = committedUsage.Version,
4937-
TotalCommittedInUse = committedUsage.TotalCommittedInUse,
4941+
Version = committedUsage.Version,
4942+
TotalCommittedInUse = committedUsage.TotalCommittedInUse,
49384943
TotalCommittedInGlobalDecommit = committedUsage.TotalCommittedInGlobalDecommit,
4939-
TotalCommittedInFree = committedUsage.TotalCommittedInFree,
4940-
TotalCommittedInGlobalFree = committedUsage.TotalCommittedInGlobalFree,
4941-
TotalBookkeepingCommitted = committedUsage.TotalBookkeepingCommitted
4944+
TotalCommittedInFree = committedUsage.TotalCommittedInFree,
4945+
TotalCommittedInGlobalFree = committedUsage.TotalCommittedInGlobalFree,
4946+
TotalBookkeepingCommitted = committedUsage.TotalBookkeepingCommitted
49424947
};
49434948

49444949
if (_event.CommittedUsageBefore == null)
@@ -4953,41 +4958,17 @@ internal static void ProcessCommittedUsage(TraceLoadedDotNetRuntime proc, Commit
49534958
}
49544959
}
49554960

4956-
internal static void ProcessHeapCountTuning(TraceLoadedDotNetRuntime proc, HeapCountTuningTraceEvent heapCountTuning)
4957-
{
4958-
TraceGC _event = GetGC(proc, heapCountTuning.GCIndex);
4959-
if (_event != null)
4960-
{
4961-
// Copy over the contents of the dynamic data to prevent issues when the event is reused.
4962-
_event.HeapCountTuning = new HeapCountTuning
4963-
{
4964-
Version = heapCountTuning.Version,
4965-
NewHeapCount = heapCountTuning.NewHeapCount,
4966-
GCIndex = heapCountTuning.GCIndex,
4967-
MedianThroughputCostPercent = heapCountTuning.MedianThroughputCostPercent,
4968-
SmoothedMedianThroughputCostPercent = heapCountTuning.SmoothedMedianThroughputCostPercent,
4969-
ThroughputCostPercentReductionPerStepUp = heapCountTuning.ThroughputCostPercentReductionPerStepUp,
4970-
ThroughputCostPercentIncreasePerStepDown = heapCountTuning.ThroughputCostPercentIncreasePerStepDown,
4971-
SpaceCostPercentIncreasePerStepUp = heapCountTuning.SpaceCostPercentIncreasePerStepUp,
4972-
SpaceCostPercentDecreasePerStepDown = heapCountTuning.SpaceCostPercentDecreasePerStepDown
4973-
};
4974-
}
4975-
}
4976-
4977-
internal static void ProcessHeapCountSample(TraceLoadedDotNetRuntime proc, HeapCountSampleTraceEvent heapCountSample)
4961+
internal static void ProcessGCDynamicEvent(TraceLoadedDotNetRuntime proc, GCDynamicTraceEvent gcDynamic)
49784962
{
49794963
TraceGC _event = GetLastGC(proc);
49804964
if (_event != null)
49814965
{
4982-
_event.HeapCountSample = new HeapCountSample
4983-
{
4984-
Version = heapCountSample.Version,
4985-
GCIndex = heapCountSample.GCIndex,
4986-
// Convert the microsecond properties to MSec to be consistent with the other time based metrics.
4987-
ElapsedTimeBetweenGCsMSec = heapCountSample.ElapsedTimeBetweenGCs / 1000.0,
4988-
GCPauseTimeMSec = heapCountSample.GCPauseTime / 1000.0,
4989-
MslWaitTimeMSec = heapCountSample.MslWaitTime / 1000.0
4990-
};
4966+
_event.AddDynamicEvent(new GCDynamicEvent
4967+
(
4968+
gcDynamic.UnderlyingEvent.Name,
4969+
gcDynamic.UnderlyingEvent.TimeStamp,
4970+
gcDynamic.DataField
4971+
));
49914972
}
49924973
}
49934974

0 commit comments

Comments
 (0)