Skip to content

Commit

Permalink
Enable using custom TraceEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
cshung committed Jun 19, 2024
1 parent 830354f commit 6cf8b2a
Show file tree
Hide file tree
Showing 7 changed files with 283 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,32 @@

<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
</PropertyGroup>

<Import Project="../Versions.props" />

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Html.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.Data.Analysis" Version="0.19.1" />
<PackageReference Include="Microsoft.Diagnostics.Tracing.TraceEvent" Version="3.1.9" />
<PackageReference Condition="'$(CustomTraceEvent)' != 'true'" Include="Microsoft.Diagnostics.Tracing.TraceEvent" Version="3.1.9" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="XPlot.Plotly" Version="4.0.6" />
<PackageReference Include="YamlDotNet" Version="11.2.1" />
</ItemGroup>

<ItemGroup Condition="'$(CustomTraceEvent)' == 'true'">
<Reference Include="Microsoft.Diagnostics.FastSerialization.dll">
<HintPath>$(PerfViewPath)\src\FastSerialization\bin\Release\netstandard2.0\Microsoft.Diagnostics.FastSerialization.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Diagnostics.Tracing.TraceEvent">
<HintPath>$(PerfViewPath)\src\TraceEvent\bin\Release\netstandard2.0\Microsoft.Diagnostics.Tracing.TraceEvent.dll</HintPath>
</Reference>
</ItemGroup>

<ItemGroup>
<None Update="CPUAnalysis\DefaultMethods.yaml">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
</PropertyGroup>

<Import Project="../Versions.props" />

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.2-beta1" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="7.0.0-preview.7.22375.6" />
Expand All @@ -23,5 +25,14 @@
<ItemGroup>
<ProjectReference Include="..\GC.Analysis.API\GC.Analysis.API.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(CustomTraceEvent)' == 'true'">
<Reference Include="Microsoft.Diagnostics.FastSerialization.dll">
<HintPath>$(PerfViewPath)\src\FastSerialization\bin\Release\netstandard2.0\Microsoft.Diagnostics.FastSerialization.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Diagnostics.Tracing.TraceEvent">
<HintPath>$(PerfViewPath)\src\TraceEvent\bin\Release\netstandard2.0\Microsoft.Diagnostics.Tracing.TraceEvent.dll</HintPath>
</Reference>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,246 @@
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"# Usage of GC.Analysis.API for GC Analysis"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"dotnet_interactive": {
"language": "csharp"
},
"polyglot_notebook": {
"kernelName": "csharp"
},
"vscode": {
"languageId": "polyglot-notebook"
}
},
"outputs": [],
"source": [
"// In order to use a custom TraceEvent library, we need to reference it directly here\n",
"\n",
"#r \"C:\\Dev\\perfview\\src\\TraceEvent\\bin\\Release\\netstandard2.0\\Microsoft.Diagnostics.Tracing.TraceEvent.dll\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"dotnet_interactive": {
"language": "csharp"
},
"vscode": {
"languageId": "polyglot-notebook"
}
},
"outputs": [],
"source": [
"#r \"nuget: XPlot.Plotly\"\n",
"#r \"nuget: XPlot.Plotly.Interactive\"\n",
"#r \"nuget: Microsoft.Data.Analysis\"\n",
"#r \"nuget: Newtonsoft.Json\"\n",
"\n",
"using Etlx = Microsoft.Diagnostics.Tracing.Etlx;\n",
"using Microsoft.Data.Analysis;\n",
"using Microsoft.Diagnostics.Tracing.Analysis.GC;\n",
"using Microsoft.Diagnostics.Tracing.Analysis;\n",
"using Microsoft.Diagnostics.Tracing.Parsers.Clr;\n",
"using Microsoft.Diagnostics.Tracing;\n",
"using XPlot.Plotly;\n",
"\n",
"using System.IO;\n",
"using Newtonsoft.Json;"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## Building and Using The GC Analysis API"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Before building `GC.Analysis.API`, make sure we change the project file so that it references the local copy instead of pulling it from Nuget. "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"dotnet_interactive": {
"language": "pwsh"
},
"vscode": {
"languageId": "polyglot-notebook"
}
},
"outputs": [],
"source": [
"dotnet build -c Release \"..\\..\\GC.Analysis.API\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"dotnet_interactive": {
"language": "csharp"
},
"vscode": {
"languageId": "polyglot-notebook"
}
},
"outputs": [],
"source": [
"#r \"C:\\performance\\artifacts\\bin\\GC.Analysis.API\\Release\\net8.0\\GC.Analysis.API.dll\" \n",
"\n",
"using GC.Analysis.API;"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## Creating the Analyzer"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"dotnet_interactive": {
"language": "csharp"
},
"vscode": {
"languageId": "polyglot-notebook"
}
},
"outputs": [],
"source": [
"var TRACE_PATH = @\".\\Traces\\gccollectonly.etl.zip\";"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"### Get Analyzer From a Single Path"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Get All Processes From a Trace"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"dotnet_interactive": {
"language": "csharp"
},
"vscode": {
"languageId": "polyglot-notebook"
}
},
"outputs": [],
"source": [
"Analyzer gcTraceData = new Analyzer(tracePath: TRACE_PATH);"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Get Select Processes From a Trace"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"dotnet_interactive": {
"language": "csharp"
},
"vscode": {
"languageId": "polyglot-notebook"
}
},
"outputs": [],
"source": [
"gcTraceData.SummarizeTrace(processName: \"corerun\")"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Getting To a ``List<TraceGC>`` from the Trace Data For a Process"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"dotnet_interactive": {
"language": "csharp"
},
"vscode": {
"languageId": "polyglot-notebook"
}
},
"outputs": [],
"source": [
"List<GCProcessData> corerunData = gcTraceData.GetProcessGCData(processName: \"corerun\");\n",
"GCProcessData corerunToInvestigate = corerunData[0];\n",
"List<TraceGC> traceGCs = corerunToInvestigate.GCs;"
]
}
],
"metadata": {
"kernelspec": {
"display_name": ".NET (C#)",
"language": "C#",
"name": ".net-csharp"
},
"language_info": {
"file_extension": ".cs",
"mimetype": "text/x-csharp",
"name": "C#",
"pygments_lexer": "csharp",
"version": "9.0"
},
"orig_nbformat": 4,
"polyglot_notebook": {
"kernelInfo": {
"defaultKernelName": "csharp",
"items": [
{
"aliases": [],
"name": "csharp"
}
]
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
},
"outputs": [],
"source": [
"#r \"C:\\performance\\artifacts\\bin\\GC.Analysis.API\\Release\\net7.0\\GC.Analysis.API.dll\" \n",
"#r \"C:\\performance\\artifacts\\bin\\GC.Analysis.API\\Release\\net8.0\\GC.Analysis.API.dll\" \n",
"\n",
"using GC.Analysis.API;"
]
Expand Down
9 changes: 9 additions & 0 deletions src/benchmarks/gc/GC.Infrastructure/Versions.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<PropertyGroup>
<!-- To use a custom TraceEvent library, specify CustomTraceEvent to true and the PerfViewPath below -->
<CustomTraceEvent>false</CustomTraceEvent>
<PerfViewPath>$(MSBuildProjectDirectory)\..\..\..\..\..\..\PerfView</PerfViewPath>
<DefineConstants Condition="'$(CustomTraceEvent)' == 'true'">CUSTOM_TRACE_EVENT;$(DefineConstants)</DefineConstants>
</PropertyGroup>
</Project>

0 comments on commit 6cf8b2a

Please sign in to comment.