[Coding Agent] Add find-allocation-opportunities skill#8386
Draft
lucaspimentel wants to merge 4 commits intomasterfrom
Draft
[Coding Agent] Add find-allocation-opportunities skill#8386lucaspimentel wants to merge 4 commits intomasterfrom
find-allocation-opportunities skill#8386lucaspimentel wants to merge 4 commits intomasterfrom
Conversation
🤖 Co-Authored-By: Claude Code <noreply@anthropic.com>
🤖 Co-Authored-By: Claude Code <noreply@anthropic.com>
🤖 Co-Authored-By: Claude Code <noreply@anthropic.com>
find-allocation-opportunities skill
Backlog of 7 analyzers (DDALLOC001-007) to detect heap-allocation anti-patterns at compile time, covering: ToString() in log calls, missing JsonArrayPool, new StringBuilder, Enum.HasFlag/ToString boxing, capturing lambdas in Task.Run, and throw-in-AggressiveInlining methods. 🤖 Co-Authored-By: Claude Code <noreply@anthropic.com>
Execution-Time Benchmarks Report ⏱️Execution-time results for samples comparing This PR (8386) and master. ✅ No regressions detected - check the details below Full Metrics ComparisonFakeDbCommand
HttpMessageHandler
Comparison explanationExecution-time benchmarks measure the whole time it takes to execute a program, and are intended to measure the one-off costs. Cases where the execution time results for the PR are worse than latest master results are highlighted in **red**. The following thresholds were used for comparing the execution times:
Note that these results are based on a single point-in-time result for each branch. For full results, see the dashboard. Graphs show the p99 interval based on the mean and StdDev of the test run, as well as the mean value of the run (shown as a diamond below the graph). Duration chartsFakeDbCommand (.NET Framework 4.8)gantt
title Execution time (ms) FakeDbCommand (.NET Framework 4.8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8386) - mean (72ms) : 70, 75
master - mean (73ms) : 70, 75
section Bailout
This PR (8386) - mean (76ms) : 74, 78
master - mean (76ms) : 74, 78
section CallTarget+Inlining+NGEN
This PR (8386) - mean (1,081ms) : 1030, 1132
master - mean (1,075ms) : 1036, 1115
FakeDbCommand (.NET Core 3.1)gantt
title Execution time (ms) FakeDbCommand (.NET Core 3.1)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8386) - mean (112ms) : 109, 115
master - mean (113ms) : 109, 116
section Bailout
This PR (8386) - mean (113ms) : 110, 116
master - mean (113ms) : 111, 116
section CallTarget+Inlining+NGEN
This PR (8386) - mean (797ms) : 779, 814
master - mean (798ms) : 781, 816
FakeDbCommand (.NET 6)gantt
title Execution time (ms) FakeDbCommand (.NET 6)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8386) - mean (99ms) : 96, 102
master - mean (99ms) : 96, 102
section Bailout
This PR (8386) - mean (100ms) : 98, 102
master - mean (100ms) : 97, 103
section CallTarget+Inlining+NGEN
This PR (8386) - mean (947ms) : 907, 986
master - mean (946ms) : 911, 980
FakeDbCommand (.NET 8)gantt
title Execution time (ms) FakeDbCommand (.NET 8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8386) - mean (99ms) : 96, 103
master - mean (98ms) : 95, 101
section Bailout
This PR (8386) - mean (100ms) : 98, 102
master - mean (100ms) : 97, 102
section CallTarget+Inlining+NGEN
This PR (8386) - mean (829ms) : 790, 868
master - mean (833ms) : 786, 880
HttpMessageHandler (.NET Framework 4.8)gantt
title Execution time (ms) HttpMessageHandler (.NET Framework 4.8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8386) - mean (215ms) : 208, 223
master - mean (216ms) : 211, 222
section Bailout
This PR (8386) - mean (219ms) : 214, 224
master - mean (222ms) : 215, 228
section CallTarget+Inlining+NGEN
This PR (8386) - mean (1,258ms) : 1202, 1315
master - mean (1,269ms) : 1205, 1332
HttpMessageHandler (.NET Core 3.1)gantt
title Execution time (ms) HttpMessageHandler (.NET Core 3.1)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8386) - mean (309ms) : 301, 316
master - mean (315ms) : 308, 322
section Bailout
This PR (8386) - mean (311ms) : 301, 322
master - mean (317ms) : 310, 325
section CallTarget+Inlining+NGEN
This PR (8386) - mean (1,033ms) : 1003, 1064
master - mean (1,039ms) : 1004, 1073
HttpMessageHandler (.NET 6)gantt
title Execution time (ms) HttpMessageHandler (.NET 6)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8386) - mean (305ms) : 296, 313
master - mean (309ms) : 301, 316
section Bailout
This PR (8386) - mean (304ms) : 294, 314
master - mean (307ms) : 299, 315
section CallTarget+Inlining+NGEN
This PR (8386) - mean (1,202ms) : 1162, 1242
master - mean (1,208ms) : 1170, 1246
HttpMessageHandler (.NET 8)gantt
title Execution time (ms) HttpMessageHandler (.NET 8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8386) - mean (302ms) : 294, 310
master - mean (308ms) : 301, 315
section Bailout
This PR (8386) - mean (304ms) : 297, 311
master - mean (309ms) : 298, 320
section CallTarget+Inlining+NGEN
This PR (8386) - mean (1,146ms) : 1023, 1269
master - mean (1,160ms) : 1036, 1285
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of changes
Add a Claude Code skill that scans code for heap allocation opportunities in hot paths, codifying 22+ proven allocation-avoidance patterns used by the team.
Reason for change
The
dd-trace-dotnettracer runs in-process with customer applications, so heap allocations in hot paths directly impact customer GC pressure. The team has accumulated significant tribal knowledge about allocation-avoidance patterns. This skill makes that knowledge consistently available to AI-assisted code reviews and allocation audits.Implementation details
SKILL.md: Skill definition with triggering keywords, assessment criteria (severity levels, confidence thresholds), and structured output format for allocation findingsreferences/patterns.md: 22+ proven allocation-avoidance patterns with before/after examples (e.g.,ArraySegment<T>overArray.Copy, struct enumerators,TryFormatoverToString(), tag list pre-sizing)references/anti-patterns.md: Common allocation anti-patterns organized by category (string operations, collections, LINQ, boxing, closures, async, logging) with severity ratings and fixesTest coverage
N/A — skill definition files only (no compiled code).
Other details
The skill covers both scanning existing code and reviewing PR diffs for missed optimization opportunities. It prioritizes findings by hot-path proximity and uses confidence-based filtering to minimize false positives.