EVENTPIPE & HOTSPOTS
Live CPU profiling
EventPipe sample capture, inclusive/exclusive call-stack hotspots, and target execution-window analysis to locate expensive methods.
.NET performance laboratory for AI agents
Open source under Apache-2.0. View on GitHub
Give your AI coding agent a performance goal. DotNetLab equips it to find bottlenecks, implement optimizations, and verify the gains with profiling tools, C# optimization guidance, and the scientific method.
Start with your existing application. Profile running .NET processes without code changes.
For Codex, Claude Code, Cursor & Google Antigravity
START WITH A GOAL
Use DotNetLab to improve this application's performance. Find the largest bottlenecks, implement candidate optimizations, and retain changes supported by measurements and correctness checks.
Windows & Linuxx64 platforms
.NET 6+ applicationsCoreCLR targets · .NET 10+ to run DotNetLab
Your existing codeNo code changes for initial profiling
Open sourceApache-2.0 · MCP server + agent skill
MEASURED WITH DOTNETLAB · WILDCARDMATCH
Time per matching call on dense inputs with a 16,384-character prefix in Tedd.WildcardMatch.
The matcher repeatedly checked an already-scanned prefix for newlines. Tracking how far it had checked let each retry scan only the new interval.
DotNetLab compared the source change with the original in fresh processes. The smaller dense-input scenario improved by 27.4%; ordinary inputs stayed within the declared ±5% equivalence margin.
Inspect the measured code changeDENSE-16384 · TIME PER MATCHING CALL
10 paired fresh-process blocks per scenario.
Correctness checks passed in all 80 sessions across four scenarios.
| Scenario | Original ns/call | Optimized ns/call | Result |
|---|---|---|---|
| Dense · 4,096-character prefix | 654,963.0 | 475,514.9 | 27.4% less time |
| Dense · 16,384-character prefix | 8,259,676.3 | 2,771,530.9 | 66.4% less time |
| Ordinary | 84.9 | 84.7 | Equivalent within ±5% |
| Newline | 155,255.8 | 127,016.4 | 18.2% less time |
Each scenario used ten randomized paired blocks, with a separate baseline and candidate process per block, two warm-up batches, and no excluded or replacement runs. Timings are geometric means of batch means. Four comparisons shared a 5% error budget; the dense-16384 candidate/baseline ratio was 0.3355, with a 98.75% interval of 0.2871–0.3922.
The study covered one pattern and four synthetic input distributions. Host load, CPU affinity, frequency, and thermal state were uncontrolled. The results describe these matching calls; application throughput depends on its workload.
Read the measurement data and protocolTECHNICAL CAPABILITIES
Profile CPU and memory, inspect generated code, test live method changes, and compare .NET runtimes. Give your agent the evidence to explain expensive work and investigate improvements.
EVENTPIPE & HOTSPOTS
EventPipe sample capture, inclusive/exclusive call-stack hotspots, and target execution-window analysis to locate expensive methods.
MEMORY & RUNTIME
Allocation stacks, per-generation GC pauses, runtime counters, contention and JIT events, and correlation of GC suspensions with measured execution windows.
NATIVE CODE & DISASSEMBLY
Live native-code snapshots, IL/metadata inspection, Iced disassembly, and instruction diffs to investigate inlining, bounds checks, and vectorization.
CORECLR REJIT
Import a selected compiled method body and test it through CoreCLR ReJIT while retaining the process and application objects. Supported bodies include instance fields, floating-point arithmetic, arrays, spans, refs, structs, and existing SIMD calls.
METHOD INSTRUMENTATION
Instrument supported methods for invocation counts, normal/exceptional outcomes, and optional timing, with setup validation and original-body restoration.
RELEASES & PREVIEWS
Discover installed .NET runtimes and pin an exact release or preview using target_runtime_version. Windows Core_Root/corerun development builds have a separate quiet-validation workflow.
THE SCIENTIFIC METHOD
Your agent follows an experimental loop: measure a real bottleneck, explain its cause, test a focused change, and check whether the improvement survives independent confirmation.
Profile your workload to locate CPU hotspots, allocations, and GC pauses. Your agent forms a testable hypothesis about the expensive work and the change that could reduce it.
Your agent edits the code, checks its outputs, and compares it with the baseline. Metrics and acceptance criteria are fixed before timing; randomized trials help separate gains from noise.
Retest baseline and candidate builds in fresh, profiler-free processes. Retain changes that pass performance and correctness checks, revert unsupported candidates, then profile again.
PROFILING TOOLS + OPTIMIZATION EXPERTISE
The MCP server gives your agent access to the runtime. The companion skill guides algorithm, memory, JIT, SIMD, and concurrency optimizations based on the bottleneck it measures.
CPU & ALGORITHMS
Locate hot paths with live CPU profiles. Guide your agent toward better algorithms, fewer repeated scans, faster lookups, and work it can remove entirely.
MEMORY & ALLOCATIONS
Trace allocation stacks and GC pauses. Test spans, buffer reuse, and data-layout changes while checking their effect on both speed and allocated bytes.
JIT & SIMD
Inspect generated x64 assembly to check inlining, bounds checks, and vectorization. Compare the machine code behind a proposed C# optimization.
LIVE REJIT
With the optional native profiler, replace supported method bodies while retaining application state. Validate the candidate and restore the original between experiments.
LATENCY & CONCURRENCY
Measure per-operation latency and compare p95 and p99. Use contention and runtime evidence to guide experiments with synchronization, batching, and concurrency.
REPEATABLE EVIDENCE
Compare candidates with confidence intervals and correctness checks. Confirm gains in normal builds, with plans, results, and decisions retained across agent sessions.
Initial profiling needs no application code changes. For controlled comparisons, your agent integrates the cooperative harness with repeatable inputs and correctness checks. Harness guide ↗
Native workflows require the optional profiler. Live profiler attachment is supported on Windows x64; Linux x64 supports startup instrumentation. Platform details ↗
START WITH YOUR WORKLOAD
Bring an application, library, service, or batch job. Describe the cost you want to reduce; your agent uses DotNetLab to profile the workload and test improvements.
// Process more work in the same time.
Use DotNetLab to improve this library's throughput. Profile a representative workload and identify the largest CPU costs. Implement and compare candidate optimizations, checking output correctness and allocations. Confirm the gains in fresh builds.
profile → optimize → verify// Reduce memory allocated per operation.
Use DotNetLab to reduce allocations in this parser. Find the allocation hotspots, then test ways to avoid intermediate strings and reuse buffers. Check output equivalence and throughput as well as allocated bytes. Confirm the selected change in fresh builds.
trace → compare → confirm// Investigate the slow end of the distribution.
Use DotNetLab to investigate p99 latency in this message handler under representative burst load. Measure per-operation latencies and inspect GC and contention evidence. Test a focused change, check correctness, and report whether the p99 improvement holds across independent blocks.
measure → explain → testGET STARTED
The installer configures the CLI, MCP server, and companion skill for Codex, Claude Code, Cursor, and Google Antigravity. It downloads a matching release, or builds from source when no release matches.
Run DotNetLab with a .NET 10+ runtime or SDK on Windows x64 or Linux x64. It can investigate .NET 6+ CoreCLR applications.
After installation, restart your coding client, verify compatibility, and open your application's repository. Give your agent the starting prompt and a workload to exercise.
Client selection and installation options01 / INSTALL FOR YOUR CODING CLIENTS
irm https://raw.githubusercontent.com/tedd/Tedd.DotNetLab/main/tools/install.ps1 | iex01 / INSTALL FOR YOUR CODING CLIENTS
curl -fsSL https://raw.githubusercontent.com/tedd/Tedd.DotNetLab/main/tools/install.sh | bash02 / RESTART YOUR CODING CLIENT
Start a new session so the MCP tools and skill load.
03 / VERIFY COMPATIBILITY IN YOUR TERMINAL
dotnetlab compatibility04 / OPEN YOUR PROJECT AND ASK YOUR AGENT
Find the largest bottlenecks, implement candidate optimizations, and verify the gains.
Linux trace parsing requires delegated cgroup v2 memory and pids controllers. WSL catalogs require a local Linux filesystem. Setup guide ↗
GO DEEPER