agentleFS
mag1artmag1art/skills/dotnet-performance/SKILL.md

dotnet-performance

Skill1 starsChanged 3 months agoApache-2.0View on GitHub

Use for performance-sensitive C#/.NET code involving async pipelines, concurrency, streaming, memory, allocations, or throughput.

3 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

8 rules. 0 are common, 8 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 3 edited versions we read keep these.

  • 8

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use for measured performance work, high-throughput services, bounded worker pipelines, large payloads, and allocation-sensitive paths.

    line 27
  2. Distinctive:

    Do not optimize without a workload, baseline, or acceptance metric.

    line 31
  3. Distinctive:

    Test cancellation, errors, backpressure, ordering, duplicates, and shutdown.

    line 39
  4. Distinctive:

    Keep async all the way; never use Result, Wait, or unbounded fire-and-forget.

    line 43
  5. Distinctive:

    Use bounded channels and explicit full-mode behavior for backpressure.

    line 45
  6. Distinctive:

    Use ArrayPool only with strict ownership and finally-return.

    line 48
  7. Distinctive:

    Prefer database-side filtering, projection, pagination, and batch operations.

    line 49
  8. Distinctive:

    Keep queue capacity and worker count explicit.

    line 82

“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

.NET Performance

When to Use

Use for measured performance work, high-throughput services, bounded worker pipelines, large payloads, and allocation-sensitive paths.

When Not to Use

Do not optimize without a workload, baseline, or acceptance metric. Do not trade correctness and operability for speculative micro-optimizations.

Workflow

  1. Define throughput, latency, memory, concurrency, and correctness targets.
  2. Profile or benchmark the current implementation.
  3. Identify the bottleneck: I/O, CPU, allocations, locks, database, serialization, or dependency.
  4. Make the smallest change and benchmark again.
  5. Test cancellation, errors, backpressure, ordering, duplicates, and shutdown.

Rules

  • Keep async all the way; never use Result, Wait, or unbounded fire-and-forget.
  • Bound concurrency with Channel, SemaphoreSlim, or Parallel.ForEachAsync.
  • Use bounded channels and explicit full-mode behavior for backpressure.
  • Stream large files and responses; avoid unbounded ToList, ReadToEnd, or buffering.
  • Pass CancellationToken through every I/O path.
  • Use ArrayPool only with strict ownership and finally-return; clear sensitive buffers.
  • Prefer database-side filtering, projection, pagination, and batch operations.
  • Measure serialization and logging overhead on hot paths.
  • Preserve ordering only when the contract requires it.
  • Make retries bounded and cancellation-aware.

Quality Gate

Provide before/after measurements, resource assumptions, failure behavior, and a rollback-safe change.

Example: Bounded Channel Pipeline

var channel = Channel.CreateBounded<WorkItem>(
    new BoundedChannelOptions(256)
    {
        FullMode = BoundedChannelFullMode.Wait,
        SingleWriter = true
    });

var producer = ProduceAsync(channel.Writer, ct);
var consumers = Enumerable.Range(0, 4)
    .Select(_ => ConsumeAsync(channel.Reader, ct));

await Task.WhenAll(consumers.Append(producer));

static async Task ConsumeAsync(
    ChannelReader<WorkItem> reader,
    CancellationToken ct)
{
    await foreach (var item in reader.ReadAllAsync(ct))
        await ProcessAsync(item, ct);
}

Keep queue capacity and worker count explicit. Decide whether ordering, retries, duplicate processing, and shutdown draining are part of the contract. Measure throughput, queue depth, latency, allocations, and memory before and after the change.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.