Imported from rudironsoni/Synaxis (
.codex/skills/dotnet-performance/SKILL.md). Install upstream withnpx skills add rudironsoni/Synaxis --skill dotnet-performance. Copyright stays with the author.
.NET Performance
Performance optimization and measurement for .NET applications. This meta-skill provides navigation to ~10 performance-focused skills covering zero-allocation coding, benchmarking, profiling, Native AOT, and optimization patterns.
When to Use This Skill
Load this skill when:
- Optimizing application performance and allocations
- Measuring performance with BenchmarkDotNet
- Profiling memory or CPU usage
- Building Native AOT applications
- Tuning garbage collection
- Reducing memory allocations
Quick Navigation
Optimization Patterns
| Need | Load Skill | Level |
|---|---|---|
| Span, ArrayPool, ref struct | dotnet-performance-patterns |
Advanced |
| Type design for performance | dotnet-csharp-type-design-performance |
Advanced |
| LINQ optimization | dotnet-linq-optimization |
Intermediate |
Memory Management
| Need | Load Skill | Level |
|---|---|---|
| GC tuning, LOH/POH | dotnet-gc-memory |
Advanced |
| Struct vs class decisions | dotnet-csharp-type-design-performance |
Advanced |
Measurement
| Need | Load Skill | Level |
|---|---|---|
| BenchmarkDotNet setup | dotnet-benchmarkdotnet |
Intermediate |
| Profiling tools | dotnet-profiling |
Advanced |
| CI performance gates | dotnet-ci-benchmarking |
Advanced |
AOT & Compilation
| Need | Load Skill | Level |
|---|---|---|
| Native AOT publishing | dotnet-native-aot |
Advanced |
| AOT architecture patterns | dotnet-aot-architecture |
Advanced |
| WASM AOT | dotnet-aot-wasm |
Advanced |
| Trimming | dotnet-trimming |
Intermediate |
| Multi-targeting | dotnet-multi-targeting |
Intermediate |
Platform-Specific
| Need | Load Skill | Level |
|---|---|---|
| MAUI iOS/Catalyst AOT | dotnet-maui-aot |
Advanced |
Performance Decision Trees
Which Optimization Technique?
Reduce allocations → Span<T>, ArrayPool<T> (dotnet-performance-patterns)
↓
Improve throughput → Struct optimization (dotnet-csharp-type-design-performance)
↓
Reduce startup time → Native AOT (dotnet-native-aot)
↓
Optimize queries → LINQ optimization (dotnet-linq-optimization)
Which Measurement Tool?
| Goal | Tool | Skill |
|---|---|---|
| Microbenchmarks | BenchmarkDotNet | dotnet-benchmarkdotnet |
| Live profiling | dotnet-trace | dotnet-profiling |
| Memory analysis | dotnet-counters | dotnet-profiling |
| Crash dumps | dotnet-dump | dotnet-profiling |
| CI gating | Automated benchmarks | dotnet-ci-benchmarking |
When to Use Native AOT?
| Scenario | Recommendation |
|---|---|
| CLI tools | Strongly recommended |
| Microservices | Consider for fast startup |
| Containers | Good for size reduction |
| Web APIs | Evaluate trade-offs |
| Libraries | Use IsTrimmable |
Complete Skill List
Optimization Patterns (3 skills)
dotnet-performance-patterns- Span, ArrayPool, ref structdotnet-csharp-type-design-performance- Struct vs class designdotnet-linq-optimization- IQueryable vs IEnumerable
Memory & GC (2 skills)
dotnet-gc-memory- GC tuning, LOH/POHdotnet-performance-patterns- Memory patterns
Benchmarking & Profiling (3 skills)
dotnet-benchmarkdotnet- BenchmarkDotNetdotnet-profiling- dotnet-counters, trace, dumpdotnet-ci-benchmarking- CI performance gating
AOT & Compilation (5 skills)
dotnet-native-aot- PublishAot, descriptorsdotnet-aot-architecture- AOT-first designdotnet-aot-wasm- Blazor/Uno WASMdotnet-trimming- Trimming annotationsdotnet-multi-targeting- Polyfills, multi-TFM
Platform-Specific (1 skill)
dotnet-maui-aot- MAUI iOS/Catalyst optimization
Build Optimization (2 skills)
dotnet-build-optimization- Slow build diagnosisdotnet-artifacts-output- UseArtifactsOutput
Performance Patterns
Zero-Allocation Patterns
// Use Span<T> instead of arrays
public void Process(Span<byte> data) { }
// Use ArrayPool<T> for temporary buffers
var buffer = ArrayPool<byte>.Shared.Rent(1024);
try { /* use buffer */ }
finally { ArrayPool<byte>.Shared.Return(buffer); }
// Use stackalloc for small fixed buffers
Span<int> stack = stackalloc int[100];
Struct Design
// Mark readonly for immutability
public readonly struct Point(double x, double y);
// Use ref readonly for large structs
public ref readonly Point GetOrigin();
// Seal classes for devirtualization
public sealed class Calculator { }
GC Optimization
- Use
GC.TryStartNoGCRegionfor critical sections - Pool objects to reduce Gen 0 collections
- Avoid LOH fragmentation with ArrayPool
- Consider GC configs for server apps
Cross-References
- Fundamentals →
dotnet-fundamentals - Architecture →
dotnet-architecture - Security →
dotnet-security - Web →
dotnet-web
Version Assumptions
- .NET 8.0+ for modern patterns
- Native AOT requires .NET 7.0+
- HybridCache requires .NET 8.0+
- BenchmarkDotNet works on all versions
Anti-Patterns to Avoid
- Premature optimization - Measure first
- Ignoring GC pressure - Monitor allocations
- Using ValueTask incorrectly - Don't await twice
- Async void methods - Always use Task
- Ignoring async state machine overhead - Consider sync for hot paths
See Also
- INDEX.md - Complete skill index
- TAXONOMY.md - Taxonomy schema