Skip to content

Commit 5731ae9

Browse files
Loosen memory grant color thresholds + show compile time in Runtime panel (#215 C1, C4) (#261)
C1: memory grant utilization color was too harsh. Old thresholds said anything under 80% used was warn/bad, so a 61% grant showed orange. Joe's point: operators spill near their max grant, so moderate utilization is fine and even preferable; what we actually want to flag is significant over-granting (very low utilization, reserved memory wasted). New thresholds: >= 40% utilized: good (neutral / green) 20-39%: warn (orange) < 20%: bad (red) Applied in three places: - PlanViewerControl.EfficiencyColor (used for memory grant, DOP efficiency, and thread utilization — loosens all three consistently) - HtmlExporter memory card eff class - Index.razor memory card eff class C4: compile time is now shown as a plan-level property in the Runtime panel of all three surfaces regardless of whether Rule 19 fires, per Joe's point that compile time belongs in the category-B "plan-level" grouping. Previously only visible when compile CPU >= 1000ms via the warning. Small `Compile: Nms` row next to Elapsed/CPU/DOP. Version bump 1.7.4 -> 1.7.5. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 6b61d79 commit 5731ae9

4 files changed

Lines changed: 23 additions & 6 deletions

File tree

src/PlanViewer.App/Controls/PlanViewerControl.axaml.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2800,9 +2800,12 @@ void AddRow(string label, string value, string? color = null)
28002800
rowIndex++;
28012801
}
28022802

2803-
// Efficiency thresholds: white >= 80%, yellow >= 60%, orange >= 40%, red < 40%
2804-
static string EfficiencyColor(double pct) => pct >= 80 ? "#E4E6EB"
2805-
: pct >= 60 ? "#FFD700" : pct >= 40 ? "#FFB347" : "#E57373";
2803+
// Efficiency thresholds: white >= 40%, orange >= 20%, red < 20%.
2804+
// Loosened per Joe's feedback (#215 C1): for memory grants, moderate
2805+
// utilization (e.g. 60%) is fine — operators can spill near their max,
2806+
// so we shouldn't flag anything above a real over-grant threshold.
2807+
static string EfficiencyColor(double pct) => pct >= 40 ? "#E4E6EB"
2808+
: pct >= 20 ? "#FFB347" : "#E57373";
28062809

28072810
// Runtime stats (actual plans)
28082811
if (statement.QueryTimeStats != null)
@@ -2815,6 +2818,11 @@ static string EfficiencyColor(double pct) => pct >= 80 ? "#E4E6EB"
28152818
AddRow("UDF elapsed", $"{statement.QueryUdfElapsedTimeMs:N0}ms");
28162819
}
28172820

2821+
// Compile time — plan-level property (category B). Show regardless of
2822+
// threshold so it's always visible, not just when Rule 19 fires.
2823+
if (statement.CompileTimeMs > 0)
2824+
AddRow("Compile", $"{statement.CompileTimeMs:N0}ms");
2825+
28182826
// Memory grant — color by utilization percentage
28192827
if (statement.MemoryGrant != null)
28202828
{

src/PlanViewer.App/PlanViewer.App.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<ApplicationManifest>app.manifest</ApplicationManifest>
77
<ApplicationIcon>EDD.ico</ApplicationIcon>
88
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
9-
<Version>1.7.4</Version>
9+
<Version>1.7.5</Version>
1010
<Authors>Erik Darling</Authors>
1111
<Company>Darling Data LLC</Company>
1212
<Product>Performance Studio</Product>

src/PlanViewer.Core/Output/HtmlExporter.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,14 +308,16 @@ private static void WriteRuntimeCard(StringBuilder sb, StatementResult stmt)
308308
WriteRow(sb, "CPU:Elapsed", ratio.ToString("N2"));
309309
}
310310
}
311+
if (stmt.CompileTimeMs > 0)
312+
WriteRow(sb, "Compile", $"{stmt.CompileTimeMs:N0} ms");
311313
if (stmt.DegreeOfParallelism > 0)
312314
WriteRow(sb, "DOP", stmt.DegreeOfParallelism.ToString());
313315
if (stmt.NonParallelReason != null)
314316
WriteRow(sb, "Serial", Encode(stmt.NonParallelReason));
315317
if (stmt.MemoryGrant != null && stmt.MemoryGrant.GrantedKB > 0)
316318
{
317319
var pctUsed = (double)stmt.MemoryGrant.MaxUsedKB / stmt.MemoryGrant.GrantedKB * 100;
318-
var effClass = pctUsed >= 80 ? "eff-good" : pctUsed >= 40 ? "eff-warn" : "eff-bad";
320+
var effClass = pctUsed >= 40 ? "eff-good" : pctUsed >= 20 ? "eff-warn" : "eff-bad";
319321
WriteRow(sb, "Memory", FormatKB(stmt.MemoryGrant.GrantedKB) + " granted");
320322
sb.AppendLine($"<div class=\"row\"><span class=\"label\">Used</span><span class=\"value {effClass}\">{FormatKB(stmt.MemoryGrant.MaxUsedKB)} ({pctUsed:N0}%)</span></div>");
321323
}

src/PlanViewer.Web/Pages/Index.razor

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,13 @@ else
171171
</div>
172172
}
173173
}
174+
@if (ActiveStmt!.CompileTimeMs > 0)
175+
{
176+
<div class="insight-row">
177+
<span class="insight-label">Compile</span>
178+
<span class="insight-value">@ActiveStmt!.CompileTimeMs.ToString("N0") ms</span>
179+
</div>
180+
}
174181
@if (ActiveStmt!.DegreeOfParallelism > 0)
175182
{
176183
<div class="insight-row">
@@ -188,7 +195,7 @@ else
188195
@if (ActiveStmt!.MemoryGrant != null && ActiveStmt!.MemoryGrant.GrantedKB > 0)
189196
{
190197
var pctUsed = (double)ActiveStmt!.MemoryGrant.MaxUsedKB / ActiveStmt!.MemoryGrant.GrantedKB * 100;
191-
var effClass = pctUsed >= 80 ? "eff-good" : pctUsed >= 60 ? "eff-ok" : pctUsed >= 40 ? "eff-warn" : "eff-bad";
198+
var effClass = pctUsed >= 40 ? "eff-good" : pctUsed >= 20 ? "eff-warn" : "eff-bad";
192199
<div class="insight-row">
193200
<span class="insight-label">Memory</span>
194201
<span class="insight-value">@FormatKB(ActiveStmt!.MemoryGrant.GrantedKB) granted</span>

0 commit comments

Comments
 (0)