Skip to content

Commit 772cf8c

Browse files
committed
applied code review notes
1 parent 6a4d2a0 commit 772cf8c

File tree

4 files changed

+67
-13
lines changed

4 files changed

+67
-13
lines changed

src/PerfView/CommandLineArgs.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ private void SetupCommandLine(CommandLineParser parser)
443443
parser.DefineOptionalQualifier("DotNetCalls", ref DotNetCalls, "Turns on per-call .NET profiling.");
444444
parser.DefineOptionalQualifier("DotNetCallsSampled", ref DotNetCallsSampled, "Turns on per-call .NET profiling, sampling types in a smart way to keep overhead low.");
445445
parser.DefineOptionalQualifier("JITInlining", ref JITInlining, "Turns on logging of successful and failed JIT inlining attempts.");
446-
parser.DefineOptionalQualifier("CCWRefCount", ref CCWRefCount, "Turns on logging of information about CCW reference counting.");
446+
parser.DefineOptionalQualifier("CCWRefCount", ref CCWRefCount, "Turns on logging of information about .NET Native CCW reference counting.");
447447
parser.DefineOptionalQualifier("OSHeapProcess", ref OSHeapProcess, "Turn on per-allocation profiling of allocation from the OS heap for the process with the given process ID.");
448448
parser.DefineOptionalQualifier("OSHeapExe", ref OSHeapExe, "Turn on per-allocation profiling of allocation from the OS heap for the process with the given EXE (only filename WITH extension).");
449449

src/PerfView/Dialogs/RunCommandDialog.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,8 @@
303303
<CheckBox Grid.Row="0" Grid.Column="9" Name="JITInliningCheckBox" VerticalAlignment="Center" />
304304

305305
<TextBlock Grid.Row="0" Grid.Column="10" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="8,2,5,2"
306-
ToolTip="Log information about CCW reference counting.">
307-
<Hyperlink Command="Help" CommandParameter="CCWRefCountCheckBox">CCWRefCount:</Hyperlink>
306+
ToolTip="Log information about .NET Native CCW Ref Counting.">
307+
<Hyperlink Command="Help" CommandParameter="CCWRefCountCheckBox"> .NET Native CCW:</Hyperlink>
308308
</TextBlock>
309309
<CheckBox Grid.Row="0" Grid.Column="11" Name="CCWRefCountCheckBox" VerticalAlignment="Center"/>
310310

src/PerfView/PerfViewData.cs

Lines changed: 62 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4123,16 +4123,54 @@ protected internal override StackSource OpenStackSourceImpl(string streamName, T
41234123
}
41244124
else if (streamName == "CCW Ref Count")
41254125
{
4126+
// TODO use the callback model. We seem to have an issue getting the names however.
4127+
foreach (var data in events.ByEventType<CCWRefCountChangeTraceData>())
4128+
{
4129+
sample.Metric = 1;
4130+
sample.TimeRelativeMSec = data.TimeStampRelativeMSec;
4131+
var stackIndex = stackSource.GetCallStack(data.CallStackIndex(), data);
4132+
4133+
var operation = data.Operation;
4134+
if (operation.StartsWith("Release", StringComparison.OrdinalIgnoreCase))
4135+
sample.Metric = -1;
4136+
4137+
var ccwRefKindName = "CCW " + operation;
4138+
var ccwRefKindIndex = stackSource.Interner.FrameIntern(ccwRefKindName);
4139+
stackIndex = stackSource.Interner.CallStackIntern(ccwRefKindIndex, stackIndex);
4140+
4141+
var ccwRefCountName = "CCW NewRefCnt " + data.NewRefCount.ToString();
4142+
var ccwRefCountIndex = stackSource.Interner.FrameIntern(ccwRefCountName);
4143+
stackIndex = stackSource.Interner.CallStackIntern(ccwRefCountIndex, stackIndex);
4144+
4145+
var ccwInstanceName = "CCW Instance 0x" + data.COMInterfacePointer.ToString("x");
4146+
var ccwInstanceIndex = stackSource.Interner.FrameIntern(ccwInstanceName);
4147+
stackIndex = stackSource.Interner.CallStackIntern(ccwInstanceIndex, stackIndex);
4148+
4149+
var ccwTypeName = "CCW Type " + data.NameSpace + "." + data.ClassName;
4150+
var ccwTypeIndex = stackSource.Interner.FrameIntern(ccwTypeName);
4151+
stackIndex = stackSource.Interner.CallStackIntern(ccwTypeIndex, stackIndex);
4152+
4153+
sample.StackIndex = stackIndex;
4154+
stackSource.AddSample(sample);
4155+
}
4156+
}
4157+
else if (streamName == ".NET Native CCW Ref Count")
4158+
{
4159+
var objectTypeMap = new Dictionary<long, long>(1000);
41264160
var interopTraceEventParser = new InteropTraceEventParser(eventSource);
4161+
interopTraceEventParser.AddCallbackForEvent<TaskCCWCreationArgs>(null, args =>
4162+
{
4163+
if(!objectTypeMap.ContainsKey(args.objectID))
4164+
objectTypeMap.Add(args.objectID, args.targetObjectIDType);
4165+
});
41274166
interopTraceEventParser.AddCallbackForEvents<TaskCCWQueryRuntimeClassNameArgs>(args =>
41284167
{
4129-
sample.Metric = 1;
41304168
sample.TimeRelativeMSec = args.TimeStampRelativeMSec;
41314169
var stackIndex = stackSource.GetCallStack(args.CallStackIndex(), args);
41324170

41334171
var ccwRefKindName = "CCW QueryRuntimeClassName";
41344172
var ccwRefKindNameIndex = stackSource.Interner.FrameIntern(ccwRefKindName);
4135-
stackSource.Interner.CallStackIntern(ccwRefKindNameIndex, stackIndex);
4173+
stackIndex = stackSource.Interner.CallStackIntern(ccwRefKindNameIndex, stackIndex);
41364174

41374175
sample.StackIndex = stackIndex;
41384176
stackSource.AddSample(sample);
@@ -4141,14 +4179,24 @@ protected internal override StackSource OpenStackSourceImpl(string streamName, T
41414179
sample.Metric = 1;
41424180
sample.TimeRelativeMSec = args.TimeStampRelativeMSec;
41434181
var stackIndex = stackSource.GetCallStack(args.CallStackIndex(), args);
4144-
4182+
41454183
var ccwRefKindName = "CCW RefCountInc";
41464184
var ccwRefKindNameIndex = stackSource.Interner.FrameIntern(ccwRefKindName);
4147-
stackSource.Interner.CallStackIntern(ccwRefKindNameIndex, stackIndex);
4185+
stackIndex = stackSource.Interner.CallStackIntern(ccwRefKindNameIndex, stackIndex);
4186+
4187+
var objectId = "Object ID " + args.objectID;
4188+
var objectIdIndex = stackSource.Interner.FrameIntern(objectId);
4189+
stackIndex = stackSource.Interner.CallStackIntern(objectIdIndex, stackIndex);
41484190

4191+
if (objectTypeMap.ContainsKey(args.objectID))
4192+
{
4193+
var objectType = "Object Type " + objectTypeMap[args.objectID];
4194+
var objectTypeIndex = stackSource.Interner.FrameIntern(objectType);
4195+
stackIndex = stackSource.Interner.CallStackIntern(objectTypeIndex, stackIndex);
4196+
}
41494197
var ccwRefCount = "CCW NewRefCnt " + args.refCount;
41504198
var ccwRefCountIndex = stackSource.Interner.FrameIntern(ccwRefCount.ToString());
4151-
stackSource.Interner.CallStackIntern(ccwRefCountIndex, stackIndex);
4199+
stackIndex = stackSource.Interner.CallStackIntern(ccwRefCountIndex, stackIndex);
41524200

41534201
sample.StackIndex = stackIndex;
41544202
stackSource.AddSample(sample);
@@ -4161,11 +4209,11 @@ protected internal override StackSource OpenStackSourceImpl(string streamName, T
41614209

41624210
var ccwRefKindName = "CCW RefCountDec";
41634211
var ccwRefKindNameIndex = stackSource.Interner.FrameIntern(ccwRefKindName);
4164-
stackSource.Interner.CallStackIntern(ccwRefKindNameIndex, stackIndex);
4212+
stackIndex = stackSource.Interner.CallStackIntern(ccwRefKindNameIndex, stackIndex);
41654213

41664214
var ccwRefCount = "CCW NewRefCnt " + args.refCount;
41674215
var ccwRefCountIndex = stackSource.Interner.FrameIntern(ccwRefCount.ToString());
4168-
stackSource.Interner.CallStackIntern(ccwRefCountIndex, stackIndex);
4216+
stackIndex = stackIndex = stackSource.Interner.CallStackIntern(ccwRefCountIndex, stackIndex);
41694217

41704218
sample.StackIndex = stackIndex;
41714219
stackSource.AddSample(sample);
@@ -5781,6 +5829,7 @@ protected override Action<Action> OpenImpl(Window parentWindow, StatusBar worker
57815829
bool hasDotNetHeapDumps = false;
57825830
bool hasWCFRequests = false;
57835831
bool hasCCWRefCountStacks = false;
5832+
bool hasNetNativeCCWRefCountStacks = false;
57845833
bool hasWindowsRefCountStacks = false;
57855834
bool hasPinObjectAtGCTime = false;
57865835
bool hasObjectUpdate = false;
@@ -5823,8 +5872,10 @@ protected override Action<Action> OpenImpl(Window parentWindow, StatusBar worker
58235872
hasMemAllocStacks = true;
58245873
if (name.StartsWith("GC/SampledObjectAllocation"))
58255874
hasMemAllocStacks = true;
5826-
if (name.StartsWith("GC/CCWRefCountChange") || name.StartsWith("TaskCCWRef"))
5875+
if (name.StartsWith("GC/CCWRefCountChange"))
58275876
hasCCWRefCountStacks = true;
5877+
if (name.StartsWith("TaskCCWRef"))
5878+
hasNetNativeCCWRefCountStacks = true;
58285879
if (name.StartsWith("Object/CreateHandle"))
58295880
hasWindowsRefCountStacks = true;
58305881
if (name.StartsWith("Image"))
@@ -5923,6 +5974,9 @@ protected override Action<Action> OpenImpl(Window parentWindow, StatusBar worker
59235974
if (hasCCWRefCountStacks)
59245975
advanced.Children.Add(new PerfViewStackSource(this, "CCW Ref Count"));
59255976

5977+
if (hasNetNativeCCWRefCountStacks)
5978+
advanced.Children.Add(new PerfViewStackSource(this, ".NET Native CCW Ref Count"));
5979+
59265980
if (hasWindowsRefCountStacks)
59275981
advanced.Children.Add(new PerfViewStackSource(this, "Windows Handle Ref Count"));
59285982

src/PerfView/SupportFiles/UsersGuide.htm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4029,9 +4029,9 @@ <h3>Advanced Options</h3>
40294029
activated with the /JITInlining command line option.
40304030
</li>
40314031
<li>
4032-
The <strong><a id="CCWRefCountCheckBox">CCW References Count Checkbox</a></strong> - Causes
4032+
The <strong><a id="CCWRefCountCheckBox">.NET Native CCW</a></strong> - Causes
40334033
an event to be captured produced via .NET COM Callable Wrapper (CCW), an increase and decrease references count.
4034-
Also shows the stacks according to collected events.
4034+
Works only with .NET Native applications. Also shows the stacks according to collected events.
40354035
</li>
40364036
<li>
40374037
The <strong><a id="NetCaptureCheckBox">Net Capture Checkbox</a></strong> This option

0 commit comments

Comments
 (0)