csharp-optimization

Identify C# bottlenecks in MCC hot paths and propose allocation-reducing optimizations.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps developers optimize C# code in MCC to reduce GC pressure, lower latency, and improve overall throughput by providing measurement-driven techniques.

Core Features & Use Cases

  • Reuse patterns like thread-static buffers, stackalloc, and MemoryMarshal for allocation reduction.
  • Target MCC hot paths such as per-packet handling, per-tick calculations, and chunk decoding with measurable improvements.
  • Guiding profiling-driven refactors to maintain correctness while lowering latency and allocations.

Quick Start

Run a profiling session on MCC to identify hot paths, then apply the outlined optimization patterns to reduce allocations and latency.

Frequently Asked Questions about csharp-optimization

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

FAQPage Schema
How do I reduce GC pressure in C# hot paths?

Reduce GC pressure in C# hot paths by reusing thread-static buffers, applying stackalloc, and using MemoryMarshal to minimize allocations. This Skill guides measurement-driven refactors for per-packet handling and per-tick calculations to lower allocation frequency and latency.

What's the best way to optimize C# packet handling for latency?

Optimize C# packet handling for latency by profiling bottlenecks in per-packet methods like HandlePacket, then applying allocation reduction patterns. This Skill proposes safe, testable refactors that preserve behavior while lowering latency in protocol handlers.

How does stackalloc help with C# allocation reduction?

Stackalloc helps with C# allocation reduction by allocating memory on the stack instead of the heap, avoiding GC pressure. This Skill applies stackalloc alongside thread-static buffers and MemoryMarshal to optimize MCC hot paths like chunk decoding and data type reading.

Do I need profiling data before optimizing C# hot paths?

Profiling data is required before optimizing C# hot paths to justify any changes. This Skill mandates measurement-driven techniques to identify bottlenecks accurately, ensuring refactors target actual latency and allocation issues rather than speculative assumptions.

Can I use MemoryMarshal to optimize chunk decoding in C#?

You can use MemoryMarshal to optimize chunk decoding in C# by accessing memory regions directly without allocations. This Skill targets chunk decoding and data reading hot paths, applying framework-appropriate techniques to achieve measurable throughput improvements.

Why must C# optimization refactors preserve behavior?

C# optimization refactors must preserve behavior to ensure safe, testable changes that do not break existing functionality. This Skill requires language- and framework-appropriate techniques guided by profiling data, maintaining correctness while reducing allocations and latency.