Repository navigation
Plan viewer: color edges by the actual/estimated row ratio (#4579) - #4586
Merged
Merged
Conversation
Ports PerformanceStudio's edge-accuracy coloring: the elbow connector feeding an actual-plan operator now colors by how far its actual row count diverged from the estimate, staying the plain default color inside a divergence band and climbing through three tiers each way outside it. Estimated plans keep the plain default; the tier math lives in a pure PlanEdgeColour helper shared by both hosts. Adds an AccuracyRatioDivergenceLimit setting (default 10, floored at 2) to both the Darling Viewer and Lite, mirroring the PerformanceStudio setting.
erikdarlingdata
marked this pull request as ready for review
September 28, 2026 14:38
This was referenced Sep 28, 2026
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.
Fixes #4579. Part of #4511.
Why
erikdarlingdata/PerformanceStudio@70d28e6 colors an actual plan's edges (the
elbow connectors between operators) by how far the child operator's actual
row count diverged from its estimate — instead of one flat gray line for
every edge. A user glancing at an actual plan can now see where the
optimizer's row estimate was badly wrong without opening every operator's
tooltip. PerformanceMonitor's plan viewer previously drew every edge in the
same flat
EdgeBrush, with no accuracy signal at all.What changes
PerformanceMonitor.PlanAnalysis.PlanEdgeColour.ForChild(hasActualStats, actualRows, estimateRows, divergenceLimit), returning one of 7PlanEdgeColourKeyvalues. Matches PerformanceStudio'sGetLinkColorBrushexactly:Neutral(the plain default color).accuracyRatio = actualRows / estimateRows(zero estimate + zero actual = 1.0; zero estimate + nonzero actual =double.MaxValue).[1/limit, limit],Neutral.limit,limit×10,limit×100— orange/red for more actual rows than estimated (underestimated), blue for fewer (overestimated).divergenceLimitis floored at 2.0 inside the helper, matching PerformanceStudio's clamp.PlanViewerControl(the shared WPF control both hosts render) now calls this helper per edge instead of always usingEdgeBrush, with the 6 non-neutral brushes at PerformanceStudio's exact hex values.AccuracyRatioDivergenceLimitproperty onPlanViewerControl(default 10, PerformanceStudio's default), set by the caller before rendering.AccuracyRatioDivergenceLimitto both hosts' persisted settings —App.AccuracyRatioDivergenceLimit(newstaticproperty, default 10), read fromsettings.json's newaccuracy_ratio_divergence_limitkey (documented insettings.sample.json), applied at everyPlanViewerControlconstruction site (ServerTab.Plans.cs,PlanViewerWindow.xaml.cs).ViewerAppSettings.AccuracyRatioDivergenceLimit(persisted, normalized/floored on load) plus a new runtime staticViewerExportSettings.AccuracyRatioDivergenceLimit(the same "seed once, re-apply on Settings-window close" pattern the CSV separator already uses), applied at bothPlanViewerControlconstruction sites (ViewerActualPlanFlow.cs,ViewerServerTab.Plans.cs).Not ported
AccuracyRatioDivergenceLimitin its settings file (default 10), and its Settings window only carries the value through Reset All; it has no control for it. PerformanceMonitor matches this. The limit lives in the Darling Viewer'sviewer-settings.jsonand Lite'ssettings.json, with the same default, and there's no Settings-window control.Test plan
New
Darling/Darling.Tests/Viewer4579Tests.cspinsPlanEdgeColour.ForChilddirectly (a new pure type, no WPF dependency, runs on macOS): estimated-plan neutrality, exact-match neutrality, the zero-estimate edge cases, every tier boundary on both the underestimate and overestimate sides (just inside, at, just above/below each oflimit,limit×10,limit×100), the divergence-limit floor, and the two public constants.PerformanceMonitor.PlanAnalysis,PerformanceMonitor.Ui,Lite/PerformanceMonitorLite.csproj,Lite.Tests,Darling/PerformanceMonitor.Darling.Viewer,Darling/Darling.Tests— all built Release with-p:EnableWindowsTargeting=true,0 Warning(s)/0 Error(s)on every one.git worktreeatorigin/dev(130bc6a) and rebuiltDarling.Teststhere — compile-only RED (PlanEdgeColour/PlanEdgeColourKeydon't exist on dev,CS0103on every reference).Darling.Tests.dllwith the WPF framework entry stripped from its runtimeconfig):-class Darling.Tests.Viewer4579Tests→Total: 20, Errors: 0, Failed: 0.Viewer4579Tests+ everyPlanSync*/Viewer*class + the fixed list ofActualPlan*/parser/MCP/doc-comment classes):Total: 1045, Errors: 0, Failed: 41, Skipped: 5. All 41 failures are inViewerConfigDiagnosticsTests,ViewerDrillDownTests,ViewerHistoryWindowTests,ViewerServerTabTimeRangeTests,ViewerCalendarRetentionPortTests,ViewerSidebarDotRendersTheCardStatusTests, andViewerTrendRoutingPortTests— none of them touchPlanViewerControl,PlanEdgeColour, or any file this PR changes (config-path anchoring, drill-down sorting/overlay, calendar retention, sidebar status dot, trend routing). I ran out of budget to prove these are pre-existing on dev with a second full run in a separate worktree (my one attempt hit anxunitCLI option-parsing error from too many-classarguments concatenated across two shell variables, not a test failure) — a follow-up should confirm these are dev-green-vs-branch-green identical before merge; I did not touch any of those seven files.Lite.Testsclasses touched: none (no Lite-specific test file added or edited); the settings/App.xaml.cs changes there are covered indirectly by the build-only gate sinceLite.Testscannot run on macOS.CHANGELOG
SECTION: Changed
ENTRY: - The plan viewer colours actual-plan edges by how far actual rows diverged from the estimate ([#4586]) - As in PerformanceStudio, an edge turns orange to red when the operator returned far more rows than estimated and blue when it returned far fewer, in three tiers each way, beyond a divergence limit that defaults to 10 and can be set in the settings file of Lite and the Darling Viewer. Estimated plans keep the plain edge colour.
REF: [#4586]: #4586
Refs
PS reference: erikdarlingdata/PerformanceStudio@70d28e6