performance-optimization-dotnet

Diagnose and fix .NET performance bottlenecks using BenchmarkDotNet, dotnet-counters, and dotnet-trace.

7|Updated Jan 11, 2026
One-click install
npx skills add https://github.com/peterblazejewicz/claude-plugins --skill performance-optimization-dotnet-peterblazejewicz
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: performance-optimization-dotnet
Source: https://github.com/peterblazejewicz/claude-plugins/tree/main/plugins/dotnet-skills/skills/performance-optimization-dotnet
Command: npx skills add https://github.com/peterblazejewicz/claude-plugins --skill performance-optimization-dotnet-peterblazejewicz

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? .NET applications suffer from latency regressions, memory growth, and throughput limits that are hard to fix without measurement. This Skill enforces a measure-first workflow so you fix the actual bottleneck — EF Core N+1 queries, sync-over-async, Gen2 GC pressure, thread-pool starvation — instead of guessing. ## Core Features & Use Cases - Measurement Tooling Guidance: Match symptoms to the right tool — BenchmarkDotNet for micro-benchmarks, dotnet-counters for live process stats, dotnet-trace and PerfView for CPU profiles, dotnet-gcdump for heap analysis. - Anti-Pattern Fixes: Concrete before/after C# code for EF Core N+1, sync-over-async, unbounded queries, HttpClient misuse, allocation hotspots, runtime-compiled Regex, and Kestrel misconfiguration. - Performance Budgets & CI Guards: Set enforceable budgets (p95 latency, allocated bytes per request, Gen2 rate) with a CI step that parses BenchmarkDotNet JSON and fails the build on regression. - Use Case: Your ASP.NET Core API's p95 latency jumped from 100 ms to 420 ms after a release. Use this Skill to profile with dotnet-trace, identify an EF Core N+1 introduced in the new endpoint, fix it with Include and AsSplitQuery, verify the delta with BenchmarkDotNet, and add a CI budget to prevent recurrence. ## Quick Start Ask the AI to profile your slow .NET endpoint and fix the identified bottleneck using the measure-identify-fix-verify-guard workflow.

Frequently Asked Questions about performance-optimization-dotnet

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

FAQPage Schema
How do I find performance bottlenecks in a .NET application?

Start by measuring with the tool matching your symptom: dotnet-counters for live GC and thread-pool stats, dotnet-trace for CPU sampling, dotnet-gcdump for heap analysis, and BenchmarkDotNet for micro-benchmarks. Never optimize before a profile identifies the actual bottleneck.

How to fix EF Core N+1 query problems in C#?

Replace per-item queries inside loops with a single query using Include, add AsSplitQuery when multiple Include chains would cause a cartesian explosion, or project to a DTO with Select and AsNoTracking for read paths. Enable EF Core query logging to confirm the generated SQL.

BenchmarkDotNet vs dotnet-trace — which should I use?

Use BenchmarkDotNet for deterministic micro-benchmarks comparing code variants with statistical confidence intervals and allocation tracking. Use dotnet-trace for CPU-sampling profiles of a running process to see where wall-clock time actually goes in production-like conditions.

Why is sync-over-async bad in ASP.NET Core?

Calling .Result, .Wait(), or GetAwaiter().GetResult() blocks a thread-pool thread, which under load causes thread-pool starvation and collapsed throughput. Make the call chain async end-to-end and pass CancellationToken through; library code should add ConfigureAwait(false).

When should I not optimize .NET code performance?

Do not optimize without measurement evidence of a problem. Premature optimization adds complexity that costs more than the performance it gains, and a delta inside BenchmarkDotNet's noise floor is not a real improvement. Readable code beats marginally faster code.