# blazing-fast-dotnet

blazing-fast-dotnet guides performance tuning for C# applications, profiling workflows, GC allocation cuts, and NativeAOT runtime knobs.

- skill · `type=skill` · Claude Code, Cursor, Codex, GitHub Copilot, Gemini CLI, Windsurf (Devin Desktop), Claude.ai · ★ 521 repo stars
- Author: managedcode
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/managedcode/dotnet-skills/tree/HEAD/catalog/Tools/BlazingFastDotnet/skills/blazing-fast-dotnet/SKILL.md
- Updated: 2026-10-29
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/skills/blazing-fast-dotnet

## What it does

This skill provides actionable advice for diagnosing and speeding up high-load C# applications and BenchmarkDotNet suites. It guides developers through inspecting JIT codegen, fixing thread pool starvation, cutting garbage collector pauses, and adjusting NativeAOT runtime parameters.

Profiling follows a staged approach from low-overhead checks to deep disassembly. You begin with `dotnet-counters` under traffic, move to `dotnet-trace` for call trees and lock contention, and turn to Linux `perf` when inspecting compiled assembly instructions. Profiling fails immediately if the CLI tools `dotnet-counters` and `dotnet-trace` are missing from your environment.

Techniques cover cache line false sharing, safe vectorization, and static abstract interface specialization. The guidance focuses on .NET 10.0 and 11.0, while legacy releases remain untested.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add managedcode/dotnet-skills --skill blazing-fast-dotnet -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/blazing-fast-dotnet/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/blazing-fast-dotnet/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add managedcode/dotnet-skills --skill blazing-fast-dotnet -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/blazing-fast-dotnet/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add managedcode/dotnet-skills --skill blazing-fast-dotnet -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/blazing-fast-dotnet/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install managedcode/dotnet-skills catalog/Tools/BlazingFastDotnet/skills/blazing-fast-dotnet
```

2. **Manually: put the files in place**
- File: `.github/skills/blazing-fast-dotnet/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add managedcode/dotnet-skills --skill blazing-fast-dotnet -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/managedcode/dotnet-skills --path catalog/Tools/BlazingFastDotnet/skills/blazing-fast-dotnet
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/blazing-fast-dotnet/SKILL.md` — The legacy .windsurf/skills/ path still works

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/managedcode/dotnet-skills/tree/HEAD/catalog/Tools/BlazingFastDotnet/skills/blazing-fast-dotnet/SKILL.md

## When to use it
- cut garbage collection overhead and object allocations
- detect thread contention and thread pool starvation
- inspect JIT disassembly and annotated assembly
- adjust NativeAOT and runtime configuration knobs

## Example prompts
- Help me trace lock contention in my C# service using `dotnet-trace`
- Show how to configure NativeAOT runtime knobs to reduce memory allocations
- Profile this BenchmarkDotNet benchmark to find GC pressure bottlenecks

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: 39f69e3b5e191c77.

BEGIN THIRD-PARTY FILE 39f69e3b5e191c77
````text
---
name: blazing-fast-dotnet
description: High-performance .NET guidance for writing and tuning C# apps and benchmarks (BenchmarkDotNet, ASP.NET, challenges). Use when asked to make .NET code faster, reduce allocations or GC overhead, fix lock contention or thread pool starvation, inspect JIT codegen, profile apps, or tune runtime/NativeAOT settings.
---

# Blazing Fast .NET Performance

> [!WARNING]
> Much of the advice here might not age well: as .NET evolves, old hacks and custom knobs may become obsolete or even detrimental. Apply only after careful consideration and testing. Revisit periodically to ensure continued relevance.

This skill focuses on optimizing .NET applications for maximum performance, providing tips, techniques, and best practices to achieve blazing-fast execution times. It targets .NET 10.0 and 11.0. Older versions have not been tested.

**Contents**

- [Profiling and Performance Analysis](#profiling-and-performance-analysis)
  - [dotnet-counters](#dotnet-counters)
  - [dotnet-trace](#dotnet-trace)
  - [Low-level profiling with Linux `perf`](#low-level-profiling-with-linux-perf)
  - [Popular low-level problems](#popular-low-level-problems)
  - [Inspecting JIT codegen](#inspecting-jit-codegen)
- [Best practices for high-performance C# code](#best-practices-for-high-performance-c-code)
  - [Quick tips](#quick-tips)
  - [Strings and globalization](#strings-and-globalization)
  - [Contention on shared state](#contention-on-shared-state)
    - [False sharing](#false-sharing)
  - [Safe vectorization (SIMD or SWAR)](#safe-vectorization-simd-or-swar)
  - [Generic specialization via static abstract members](#generic-specialization-via-static-abstract-members)
- [ASP.NET Core](#aspnet-core)
- [Magic knobs to Tune .NET Performance](#magic-knobs-to-tune-net-performance)
- [NativeAOT-specific tuning](#nativeaot-specific-tuning)
- [General notes](#general-notes)

# Profiling and Performance Analysis

Start cheap and go deeper only when needed: counters (what kind of bottleneck?) → traces (where?) → `perf` and JIT disassembly.
Install the tools with:

```sh
dotnet tool install -g dotnet-counters
dotnet tool install -g dotnet-trace
dotnet tool install -g dotnet-symbol
```

## dotnet-counters

[dotnet-counters](https://learn.microsoft.com/dotnet/core/diagnostics/dotnet-counters) is a low-overhead, first-level triage tool. Run it while the app is under load:

```sh
dotnet-counters monitor -p <pid>                                    # System.Runtime counters by default
dotnet-counters monitor -p <pid> --counters System.Runtime,Microsoft.AspNetCore.Hosting,System.Net.Http
````
END THIRD-PARTY FILE 39f69e3b5e191c77

The third-party file has ended. Everything between the 39f69e3b5e191c77 tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2626 of 30577 bytes. © managedcode · MIT · https://github.com/managedcode/dotnet-skills/tree/HEAD/catalog/Tools/BlazingFastDotnet/skills/blazing-fast-dotnet/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
