Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 28 additions & 5 deletions Darling/Darling.Tests/FinOpsIndexAnalysisViewTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,19 +137,42 @@ public void Gb_RoundsAwayFromZero_ToThreeDecimals()
}

[Fact]
public void Notes_AreUptimeThenDedupeThenAnalyzerNotes()
public void Notes_AreUptimeThenAnalyzerNotes_WhenOnlyTheUptimeWarningApplies()
{
var root = Build(new IndexCleanupAnalysisResult
{
DatabaseRollups = [Roll("d")], UptimeWarning = true, DedupeOnlyApplied = true, Notes = ["n1", "n2"],
DatabaseRollups = [Roll("d")], UptimeWarning = true, Notes = ["n1", "n2"],
});
var notes = root.GetProperty("notes").EnumerateArray().Select(n => n.GetString()!).ToArray();
Assert.Equal(4, notes.Length);
Assert.Equal(3, notes.Length);
Assert.StartsWith("Server uptime is under 14 days", notes[0], StringComparison.Ordinal);
Assert.StartsWith("Dedupe-only mode is in effect", notes[1], StringComparison.Ordinal);
Assert.Equal(new[] { "n1", "n2" }, notes.Skip(2).ToArray());
Assert.Equal(new[] { "n1", "n2" }, notes.Skip(1).ToArray());
}

/// <summary>#6653: dedupe-only mode flags no unused index, so the uptime caveat about premature "Unused Index" findings is left
/// out beside the dedupe notice; the raw uptime_warning fact stays on the payload.</summary>
[Fact]
public void Notes_LeaveOutTheUptimeCaveat_WhenDedupeOnlyIsInEffect()
{
var root = Build(new IndexCleanupAnalysisResult
{
DatabaseRollups = [Roll("d")], UptimeWarning = true, DedupeOnlyApplied = true, Notes = ["n1", "n2"],
});
var notes = root.GetProperty("notes").EnumerateArray().Select(n => n.GetString()!).ToArray();
Assert.Equal(3, notes.Length);
Assert.StartsWith("Dedupe-only mode is in effect", notes[0], StringComparison.Ordinal);
Assert.Equal(new[] { "n1", "n2" }, notes.Skip(1).ToArray());
Assert.True(root.GetProperty("uptime_warning").GetBoolean());
}

[Theory]
[InlineData(true, false, true)]
[InlineData(true, true, false)]
[InlineData(false, true, false)]
[InlineData(false, false, false)]
public void ShowUptimeCaveat_IsTheUptimeWarning_OnlyWhenDedupeOnlyIsNotInEffect(bool uptimeWarning, bool dedupeOnly, bool expected) =>
Assert.Equal(expected, new IndexCleanupAnalysisResult { UptimeWarning = uptimeWarning, DedupeOnlyApplied = dedupeOnly }.ShowUptimeCaveat);

[Fact]
public void OverallRow_HasNoWorkloadKeys_AndDatabaseRowsDo()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@
},
"UptimeWarning": true,
"DedupeOnlyApplied": true,
"ShowUptimeCaveat": false,
"Notes": [
"Reverse Duplicate and Equal Except For Filter indexes are listed as REVIEW rows only and are never disabled for you. An index with the same columns in a different order, or with a different filter, can serve different queries or rows, so check each one by hand.",
"Not covered: sp_IndexCleanup also reports a Same Keys Different Order review case. The Reverse Duplicate review rows above cover most of it."
Expand Down Expand Up @@ -950,6 +951,7 @@
},
"UptimeWarning": false,
"DedupeOnlyApplied": false,
"ShowUptimeCaveat": false,
"Notes": [
"Reverse Duplicate and Equal Except For Filter indexes are listed as REVIEW rows only and are never disabled for you. An index with the same columns in a different order, or with a different filter, can serve different queries or rows, so check each one by hand.",
"Not covered: sp_IndexCleanup also reports a Same Keys Different Order review case. The Reverse Duplicate review rows above cover most of it."
Expand Down
2 changes: 1 addition & 1 deletion Darling/Darling.Tests/Viewer4570Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void RuntimeSummaryTitle_NoQueryTimeStats_IsPredictedRuntime()
{
var stmt = Statement();
Assert.Null(stmt.QueryTimeStats);
Assert.Equal("Predicted Runtime", PlanDisplayText.RuntimeSummaryTitle(stmt));
Assert.Equal("Plan properties", PlanDisplayText.RuntimeSummaryTitle(stmt));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking (naming): the method is still RuntimeSummaryTitle_NoQueryTimeStats_IsPredictedRuntime while the assertion now pins "Plan properties". After this PR that test name is the only remaining "Predicted Runtime" string in the C# tree (grep -rn "Predicted Runtime" otherwise hits only docs/changelog/3.9.md:141), so the name points at the title it no longer asserts. ..._IsPlanProperties would keep the grep honest.

}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ internal static string BuildIndexAnalysisPayload(
}

var notes = new List<string>();
if (result.UptimeWarning) notes.Add(IndexAnalysisUptimeNote);
if (result.ShowUptimeCaveat) notes.Add(IndexAnalysisUptimeNote);
if (result.DedupeOnlyApplied) notes.Add(IndexAnalysisDedupeNote);
notes.AddRange(result.Notes);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ export const tab = {
const recs = (data.recommendations || []).map((r) => recommendationRow(r, captured));
const rollups = (data.overall ? [rollupRow({ ...data.overall, database_name: "ALL DATABASES" })] : [])
.concat((data.databases || []).map(rollupRow));
const lead = (data.uptime_warning ? 1 : 0) + (data.dedupe_only_applied ? 1 : 0);
/* #6653: the notes lead with the uptime caveat only when dedupe-only is not in effect (the tool leaves it out beside the dedupe notice). */
const lead = (data.uptime_warning && !data.dedupe_only_applied ? 1 : 0) + (data.dedupe_only_applied ? 1 : 0);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking: correct as written, and the arithmetic matches the tool's note order at DarlingMcpFinOpsTools.IndexAnalysis.cs:242-244 for all four flag combinations — but nothing fails if the two drift. finops-index-analysis-limit-harness.mjs:97-98 hardcodes uptime_warning: false, dedupe_only_applied: false in every one of its six payloads, so this line is exercised only on the lead = 0 path; a wrong lead here would either bury the dedupe notice inside the collapsed "Analyzer notes (N)" details or promote n1 to a top-level notice strip, and FinOpsIndexAnalysisLimitBehaviourTests would stay green.

The harness already captures notice text (noticeTexts), so a both-flags-true step asserting the dedupe strip is a top-level notice and the analyzer notes sit in the details would cover it. Alternatively, have the payload carry the caveat count so the page reads it instead of re-deriving the rule in a second language.

const notes = data.notes || [];
const parts = [noticeStrip(noticeText(data, recs.length, choice.db))];
notes.slice(0, lead).forEach((t) => parts.push(noticeStrip(t)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ private void BuildIndexAnalysisBanners(IndexCleanupAnalysisResult result)
{
FinOpsIndexAnalysisBannerPanel.Children.Clear();

if (result.UptimeWarning)
/* #6653: dedupe-only mode flags no unused index, so the uptime caveat about them is left out beside its notice. */
if (result.ShowUptimeCaveat)
{
AddIndexAnalysisBanner(
"Server uptime is under 14 days — index usage data may be incomplete, so some \"Unused Index\" findings could be premature.",
Expand Down
12 changes: 6 additions & 6 deletions Darling/PerformanceMonitor.Darling.Viewer/SettingsWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,14 @@
</Grid>
<CheckBox x:Name="CapturePlansCheckBox" Content="Capture execution plans (all servers)" Margin="0,12,0,0"
Foreground="{DynamicResource ForegroundBrush}"/>
<TextBlock Text="Store query and Query Store execution-plan XML across the fleet. Disable to shave storage on a very large fleet; a per-server override lives on each server's dialog."
FontSize="11" FontStyle="Italic" Foreground="{DynamicResource ForegroundMutedBrush}"
TextWrapping="Wrap" Margin="24,2,0,0"/>
<CheckBox x:Name="QueryStoreBackfillCheckBox" Content="Query Store history backfill (all servers)" Margin="0,12,0,0"
Foreground="{DynamicResource ForegroundBrush}"/>
<TextBlock Text="Fill Query Store history gaps (outages, newly added or freshly restored databases) in bounded background slices. Disable to stop a heavy catch-up — for example after restoring a large database onto a monitored server — live collection is unaffected; re-enabling resumes where it left off."
FontSize="11" FontStyle="Italic" Foreground="{DynamicResource ForegroundMutedBrush}"
TextWrapping="Wrap" Margin="24,2,0,0"/>
<Grid Margin="0,12,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
Expand Down Expand Up @@ -119,12 +125,6 @@
<TextBlock Text="Query text and plan XML are fetched for each database-hour's top N plans on CPU, duration, physical reads, writes, memory grant, tempdb and executions (0-100000, default 100), plus forced plans and plans the engine's plan correction names. A plan outside the top N keeps its runtime statistics, shows as not collected, and is fetched by a later run if it ranks then. 0 fetches every new plan. Takes effect on the next collection cycle, no restart."
FontSize="11" FontStyle="Italic" Foreground="{DynamicResource ForegroundMutedBrush}"
TextWrapping="Wrap" Margin="0,4,0,0"/>
<TextBlock Text="Fill Query Store history gaps (outages, newly added or freshly restored databases) in bounded background slices. Disable to stop a heavy catch-up — for example after restoring a large database onto a monitored server — live collection is unaffected; re-enabling resumes where it left off."
FontSize="11" FontStyle="Italic" Foreground="{DynamicResource ForegroundMutedBrush}"
TextWrapping="Wrap" Margin="24,2,0,0"/>
<TextBlock Text="Store query and Query Store execution-plan XML across the fleet. Disable to shave storage on a very large fleet; a per-server override lives on each server's dialog."
FontSize="11" FontStyle="Italic" Foreground="{DynamicResource ForegroundMutedBrush}"
Margin="0,4,0,0" TextWrapping="Wrap"/>
</StackPanel>
</Border>

Expand Down
8 changes: 8 additions & 0 deletions PerformanceMonitor.Common/IndexCleanupModels.cs
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,14 @@ public sealed record IndexCleanupAnalysisResult
/// <summary>Dedupe-only was in effect (either requested, or auto-enabled because uptime &lt;= 7 days), so unused indexes were not flagged.</summary>
public bool DedupeOnlyApplied { get; init; }

/// <summary>
/// Whether the "uptime under 14 days" caveat is worth showing (#6653). It warns that usage data may be incomplete and some "Unused
/// Index" findings premature, but dedupe-only mode (uptime of 7 days or less, or requested) flags no unused index at all, so beside
/// the dedupe notice the caveat describes findings that are not there and contradicts it. Both the Viewer's banners and the
/// get_finops notes (which the web page shows) read this one rule; <see cref="UptimeWarning"/> itself stays the raw fact.
/// </summary>
public bool ShowUptimeCaveat => UptimeWarning && !DedupeOnlyApplied;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking, and not a live defect — but the doc's own "or requested" branch is the one case where this rule drops a true statement without a replacement.

IndexCleanupAnalyzer.cs:87 sets dedupeOnly = options.DedupeOnly || uptime <= 7. On the uptime branch the suppression is self-repairing: the dedupe notice itself says "server uptime is 7 days or less", so the reader still learns the uptime is short. On the requested branch with uptime of 8–13 days, UptimeWarning is true and DedupeOnlyApplied is true, so the only thing shown is a notice asserting "(server uptime is 7 days or less)" — false for that server — while the accurate "under 14 days, usage data may be incomplete" line is suppressed. The rollup grid's workload counters (user_seeks/user_scans/user_lookups) are still the incomplete ones.

Unreachable from either shipped Darling surface today: the single options builder both the viewer and get_finops go through hardcodes DedupeOnly = false (Darling/PerformanceMonitor.Darling.Storage/FinOps/DarlingFinOpsIndexAnalysisReader.cs:273, pinned by ViewerIndexAnalysisTests.cs:321). Since this property is public API in .Common, worth either saying that in the doc ("safe because the dedupe notice carries the uptime fact on the auto branch") or dropping the parenthetical reason from IndexAnalysisDedupeNote so the notice never claims an uptime it did not measure.


/// <summary>Precisely-surfaced limitations of this data-driven reproduction (e.g. omitted filegroup placement, compression exclusions not reproducible, out-of-scope rules).</summary>
public IReadOnlyList<string> Notes { get; init; } = Array.Empty<string>();
}
Expand Down
8 changes: 5 additions & 3 deletions PerformanceMonitor.PlanAnalysis/PlanDisplayText.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,13 @@ public static string CopyQueryText(PlanStatement statement, int statementCount,

/// <summary>
/// The runtime summary card's title, matching erikdarlingdata/PerformanceStudio@40ade29 (E7):
/// "Predicted Runtime" when the statement has no <see cref="PlanStatement.QueryTimeStats"/>
/// (an estimated-plan-only statement), "Runtime Summary" otherwise.
/// "Plan properties" when the statement has no <see cref="PlanStatement.QueryTimeStats"/>
/// (an estimated-plan-only statement), "Runtime Summary" otherwise. #6653: PerformanceStudio@40ade29
/// titled the estimated card "Predicted Runtime", but it holds compile facts (compile time, memory, cached size),
/// not a predicted runtime, so the title is "Plan properties" here.
/// </summary>
public static string RuntimeSummaryTitle(PlanStatement statement) =>
statement.QueryTimeStats == null ? "Predicted Runtime" : "Runtime Summary";
statement.QueryTimeStats == null ? "Plan properties" : "Runtime Summary";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking (UI copy): every sibling card title in the plan viewer is Title Case — "Server Context" (PerformanceMonitor.Ui/PlanViewerControl.xaml:94), "Runtime Summary" (:115), "Missing Index Suggestions" (:137), "Parameters" (:163), "Wait Stats" (:188), "Operator Properties" (:379) — so "Plan properties" is the one sentence-case title in the strip, and it sits beside an existing "Operator Properties" card. "Plan Properties" would match both conventions; the rename itself reads right for what BuildRuntimeSummaryRows emits when QueryTimeStats is null (DOP/Serial, Compile, Cached plan size, Memory grant — PlanDisplayText.cs:163-235).


/// <summary>
/// Walks a plan's node tree looking for any warning whose type ends in " Spill" (Sort Spill,
Expand Down
Loading