dotnet-performance-profiling-and-optimization

Diagnose live .NET processes and optimize C# code for performance anti-patterns.

2.1k|474|Updated Jul 18, 2013
One-click install
npx skills add https://github.com/MCCTeam/Minecraft-Console-Client --skill dotnet-performance-profiling-and-optimization
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dotnet-performance-profiling-and-optimization
Source: https://github.com/MCCTeam/Minecraft-Console-Client/tree/main/.skills/dotnet-performance-profiling-and-optimization
Command: npx skills add https://github.com/MCCTeam/Minecraft-Console-Client --skill dotnet-performance-profiling-and-optimization

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

.NET applications that run slowly, hang, deadlock, or consume excessive memory are hard to fix without structured diagnostics and a systematic review of common performance anti-patterns across async, memory, LINQ, JSON, and database code.

Core Features & Use Cases

  • Live Process Diagnostics (Mode A): Triage running .NET processes with dotnet-counters, dotnet-stack, dotnet-trace, dotnet-gcdump, and dotnet-dump to find CPU hotspots, GC pressure, and deadlocks.
  • Static Code Review (Mode B): Scan C# codebases against 14 optimization categories (memory, async, LINQ, EF Core, JSON, caching, DI, concurrency, HttpClient, exceptions, strings, startup, metrics) with grep-based detection recipes and severity-ranked findings.
  • Guided Fixes with Measurement: Apply surgical optimizations one category at a time, verify with dotnet build/test, and validate improvements with BenchmarkDotNet or load tests.
  • Use Case: A developer notices high memory usage in an ASP.NET Core API. The skill captures a gcdump, identifies LOH churn from repeated large buffer allocations, then reviews the hot path and replaces new byte[] with ArrayPool<byte>.Shared rentals, re-measuring to confirm the fix.

Quick Start

Ask the assistant to analyze a slow or memory-heavy .NET process or review a C# file or directory for performance anti-patterns, optionally adding --fix to apply the recommended optimizations.

Frequently Asked Questions about dotnet-performance-profiling-and-optimization

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I diagnose a slow or hung .NET process?

Start with dotnet-counters to check live CPU, allocation rate, and GC activity, then use dotnet-stack if the process is hung or deadlocked. For CPU or allocation hot paths, collect a dotnet-trace; for heap composition, use dotnet-gcdump or dotnet-dump with SOS analysis.

How do I find performance anti-patterns in C# code?

Run grep-based scan recipes targeting 14 categories: blocking async calls, LINQ inefficiencies, uncached JsonSerializerOptions, new HttpClient instances, string concatenation in loops, and more. Findings are ranked HIGH, MEDIUM, or LOW with file, line, and recommended fix.

Does this performance guidance work on .NET 8?

Yes, the skill targets .NET 8 and .NET 10 explicitly. APIs unavailable on .NET 8, such as HybridCache, Span.Split, and Dictionary.GetAlternateLookup, include documented .NET 8 fallback patterns for each recommendation.

What is the difference between dotnet-trace and dotnet-gcdump?

dotnet-trace captures sampled CPU execution and runtime events to identify hot call paths. dotnet-gcdump captures a snapshot of the managed heap showing which object types dominate memory, making it better for investigating heap growth.

When should I use BenchmarkDotNet versus load testing?

Use BenchmarkDotNet with MemoryDiagnoser for isolated micro-optimizations on hot paths where differences are nanoseconds or bytes. Use k6 load testing with dotnet-counters monitoring for architectural changes like caching or DI lifetime adjustments.

What changes require approval before applying optimizations?

The skill stops and asks before modifying Program.cs or the middleware pipeline, adding NuGet packages, changing DI service lifetimes, replacing HTTP serializers, or altering API contracts and response shapes.