-
Notifications
You must be signed in to change notification settings - Fork 30
Loosen memory grant colors + compile time as plan-level property (#215 C1, C4) #261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2800,9 +2800,12 @@ void AddRow(string label, string value, string? color = null) | |
| rowIndex++; | ||
| } | ||
|
|
||
| // Efficiency thresholds: white >= 80%, yellow >= 60%, orange >= 40%, red < 40% | ||
| static string EfficiencyColor(double pct) => pct >= 80 ? "#E4E6EB" | ||
| : pct >= 60 ? "#FFD700" : pct >= 40 ? "#FFB347" : "#E57373"; | ||
| // Efficiency thresholds: white >= 40%, orange >= 20%, red < 20%. | ||
| // Loosened per Joe's feedback (#215 C1): for memory grants, moderate | ||
| // utilization (e.g. 60%) is fine — operators can spill near their max, | ||
| // so we shouldn't flag anything above a real over-grant threshold. | ||
| static string EfficiencyColor(double pct) => pct >= 40 ? "#E4E6EB" | ||
| : pct >= 20 ? "#FFB347" : "#E57373"; | ||
|
|
||
| // Runtime stats (actual plans) | ||
| if (statement.QueryTimeStats != null) | ||
|
|
@@ -2815,6 +2818,11 @@ static string EfficiencyColor(double pct) => pct >= 80 ? "#E4E6EB" | |
| AddRow("UDF elapsed", $"{statement.QueryUdfElapsedTimeMs:N0}ms"); | ||
| } | ||
|
|
||
| // Compile time — plan-level property (category B). Show regardless of | ||
| // threshold so it's always visible, not just when Rule 19 fires. | ||
| if (statement.CompileTimeMs > 0) | ||
| AddRow("Compile", $"{statement.CompileTimeMs:N0}ms"); | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Duplicate row. The same // Compile stats (always available)
if (statement.CompileTimeMs > 0)
AddRow("Compile time", $"{statement.CompileTimeMs:N0}ms");With this change, the Runtime panel will render two near-identical rows — Generated by Claude Code |
||
|
|
||
| // Memory grant — color by utilization percentage | ||
| if (statement.MemoryGrant != null) | ||
| { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -308,14 +308,16 @@ private static void WriteRuntimeCard(StringBuilder sb, StatementResult stmt) | |
| WriteRow(sb, "CPU:Elapsed", ratio.ToString("N2")); | ||
| } | ||
| } | ||
| if (stmt.CompileTimeMs > 0) | ||
| WriteRow(sb, "Compile", $"{stmt.CompileTimeMs:N0} ms"); | ||
| if (stmt.DegreeOfParallelism > 0) | ||
| WriteRow(sb, "DOP", stmt.DegreeOfParallelism.ToString()); | ||
| if (stmt.NonParallelReason != null) | ||
| WriteRow(sb, "Serial", Encode(stmt.NonParallelReason)); | ||
| if (stmt.MemoryGrant != null && stmt.MemoryGrant.GrantedKB > 0) | ||
| { | ||
| var pctUsed = (double)stmt.MemoryGrant.MaxUsedKB / stmt.MemoryGrant.GrantedKB * 100; | ||
| var effClass = pctUsed >= 80 ? "eff-good" : pctUsed >= 40 ? "eff-warn" : "eff-bad"; | ||
| var effClass = pctUsed >= 40 ? "eff-good" : pctUsed >= 20 ? "eff-warn" : "eff-bad"; | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Threshold shift here is isolated to the memory grant card, so this one reads cleanly — just noting for the record that Generated by Claude Code |
||
| WriteRow(sb, "Memory", FormatKB(stmt.MemoryGrant.GrantedKB) + " granted"); | ||
| sb.AppendLine($"<div class=\"row\"><span class=\"label\">Used</span><span class=\"value {effClass}\">{FormatKB(stmt.MemoryGrant.MaxUsedKB)} ({pctUsed:N0}%)</span></div>"); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -171,6 +171,13 @@ else | |
| </div> | ||
| } | ||
| } | ||
| @if (ActiveStmt!.CompileTimeMs > 0) | ||
| { | ||
| <div class="insight-row"> | ||
| <span class="insight-label">Compile</span> | ||
| <span class="insight-value">@ActiveStmt!.CompileTimeMs.ToString("N0") ms</span> | ||
| </div> | ||
| } | ||
| @if (ActiveStmt!.DegreeOfParallelism > 0) | ||
| { | ||
| <div class="insight-row"> | ||
|
|
@@ -188,7 +195,7 @@ else | |
| @if (ActiveStmt!.MemoryGrant != null && ActiveStmt!.MemoryGrant.GrantedKB > 0) | ||
| { | ||
| var pctUsed = (double)ActiveStmt!.MemoryGrant.MaxUsedKB / ActiveStmt!.MemoryGrant.GrantedKB * 100; | ||
| var effClass = pctUsed >= 80 ? "eff-good" : pctUsed >= 60 ? "eff-ok" : pctUsed >= 40 ? "eff-warn" : "eff-bad"; | ||
| var effClass = pctUsed >= 40 ? "eff-good" : pctUsed >= 20 ? "eff-warn" : "eff-bad"; | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Generated by Claude Code |
||
| <div class="insight-row"> | ||
| <span class="insight-label">Memory</span> | ||
| <span class="insight-value">@FormatKB(ActiveStmt!.MemoryGrant.GrantedKB) granted</span> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EfficiencyColoris also called for DOP parallel efficiency (line 2862) and thread utilization (line 2878), so this threshold shift isn't memory-grant-only. Under the old scheme a plan running at ~50% parallel efficiency was yellow; now it's white/"good". Same for thread utilization. If that's intentional, the comment should say so; if not, you'll want a separate threshold for the parallelism/thread callers. Worth confirming before merge since the PR description frames this as a memory-grant tweak.Generated by Claude Code