Skip to content

Conversation

Copy link

Copilot AI commented Jan 3, 2026

Analyzed 1,142 commits from v9.0.0 to HEAD, identifying performance regressions introduced during the .NET 10 migration.

Critical Fixes

Infinite loop in MySqlJsonTableExpression.VisitChildren()

Loop increment bug causes application hang when visiting JSON table expressions with path segments:

// Before: increments wrong variable
for (var j = 0; j < i; i++)

// After
for (var j = 0; j < i; j++)

String allocation in MySqlQueryStringFactory.PrepareCommand()

Hot path repeatedly allocates strings (N×3 allocations per query) when evaluating LEAST/GREATEST functions in LIMIT clauses:

// Before: creates 3 new strings per replacement
command.CommandText = command.CommandText.Substring(0, index) +
                     value +
                     command.CommandText.Substring(index + length);

// After: single StringBuilder allocation
var sb = new StringBuilder(command.CommandText.Length);
foreach (var func in functionsToReplace.OrderBy(f => f.Index)) {
    sb.Append(command.CommandText, lastIndex, func.Index - lastIndex);
    sb.Append(func.EvaluatedValue);
    lastIndex = func.Index + func.FunctionCall.Length;
}
command.CommandText = sb.ToString();

Documentation

PERFORMANCE_ANALYSIS.md: Comprehensive analysis of all commits, identifying 1 critical, 3 moderate, and 2 minor performance concerns. Documents one positive optimization (reflection caching in MySqlStructuralJsonTypeMapping).

PERFORMANCE_FIXES_SUMMARY.md: Executive summary with before/after impact analysis and recommendations for remaining issues that require profiling before optimization.

Impact

  • Critical bug: Complete application hang → Fixed
  • String allocation: O(N²) memory overhead → O(N)
  • Risk assessment: MODERATE-HIGH → LOW
Original prompt

This section details on the original issue you should resolve

<issue_title>Find possible performance issues</issue_title>
<issue_description>Go through the commits made when updating to .net 10 and figure if any of those changes could create performance issues.</issue_description>

<agent_instructions>Look over all commits since the stable .net 9 release and up latest commit</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits January 3, 2026 05:21
- Analyzed 1142 commits between v9.0.0 and HEAD
- Created comprehensive PERFORMANCE_ANALYSIS.md document
- Fixed CRITICAL infinite loop bug in MySqlJsonTableExpression.cs (line 100: i++ should be j++)
- Identified 3 moderate performance issues (string concatenation, multi-pass evaluation)
- Documented 2 minor concerns and 1 positive optimization (reflection caching)

Co-authored-by: renemadsen <[email protected]>
- Replace string concatenation with StringBuilder for LEAST/GREATEST function evaluation
- Reduces allocations from N×3 to 1 per PrepareCommand call
- Processes replacements in single pass from start to end
- Eliminates repeated string copying overhead
- Updated PERFORMANCE_ANALYSIS.md to reflect fixes

Co-authored-by: renemadsen <[email protected]>
- Create executive summary of all performance issues found and fixed
- Document the critical infinite loop bug fix
- Document the string concatenation optimization
- List remaining issues for future consideration
- Provide clear before/after comparisons and impact analysis

Co-authored-by: renemadsen <[email protected]>
Copilot AI changed the title [WIP] Identify performance issues from .net 10 update Fix critical infinite loop and optimize string allocation in .NET 10 migration Jan 3, 2026
Copilot AI requested a review from renemadsen January 3, 2026 05:28
@renemadsen renemadsen marked this pull request as ready for review January 3, 2026 05:49
@renemadsen renemadsen merged commit 8a8d699 into master Jan 3, 2026
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Find possible performance issues

2 participants