Skip to content

Add wait stats as cross-cutting analysis signal#216

Merged
erikdarlingdata merged 2 commits intodevfrom
feature/wait-stats-cross-cutting
Apr 10, 2026
Merged

Add wait stats as cross-cutting analysis signal#216
erikdarlingdata merged 2 commits intodevfrom
feature/wait-stats-cross-cutting

Conversation

@erikdarlingdata
Copy link
Copy Markdown
Owner

Summary

  • Surface statement-level wait stats across Rules 1, 5, 11, and 16 so the analyzer enriches warnings with actual execution wait evidence (dominant wait type appended to each warning message)
  • Rule 11 (Scan with Predicate) elevates to Critical when I/O waits confirm disk access at >= 50% of plan cost
  • Annotate each wait stat line in the advice panel with an inline description label (e.g., "I/O — reading data from disk", "CPU — scheduler yielding")
  • Expand GetWaitStatsAdvice (Rules 25/31) with specific explanations for all 21 wait types found in real plan files: SOS_SCHEDULER_YIELD, CXSYNC_PORT, MEMORY_ALLOCATION_EXT, HTBUILD/HTDELETE/HTREPARTITION, BPSORT, BMPBUILD, PAGELATCH, LOGBUFFER, ASYNC_NETWORK_IO, SOS_PHYS_PAGE_CACHE
  • Remove dead RESOURCE_SEMAPHORE branch (pre-execution wait, never appears in statement-level plan wait stats)

Test plan

  • 82/82 unit tests passing (10 new wait stats tests covering SOS_SCHEDULER_YIELD, CXPACKET, HTBUILD, PAGEIOLATCH, LCK_M_S)
  • Verified with join_or_clause_plan.sqlplan — inline labels appear for all 8 wait types
  • Test with additional plans from .internal/examples that have diverse wait profiles
  • Verify advice panel rendering on plans with few vs many wait types

🤖 Generated with Claude Code

erikdarlingdata and others added 2 commits April 10, 2026 14:54
Surface statement-level wait stats across Rules 1, 5, 11, and 16 so the
analyzer uses actual execution wait evidence to enrich warnings. The dominant
wait type (SOS_SCHEDULER_YIELD, CXPACKET, HTBUILD, PAGEIOLATCH, LCK_M_S,
etc.) is appended to each warning message. Rule 11 (Scan with Predicate)
additionally elevates to Critical when I/O waits confirm the scan is hitting
disk at >= 50% of plan cost.

Expand GetWaitStatsAdvice (Rules 25/31) with specific explanations for all
21 wait types found in real plan files: SOS_SCHEDULER_YIELD, CXSYNC_PORT,
MEMORY_ALLOCATION_EXT, HTBUILD/HTDELETE/HTREPARTITION, BPSORT, BMPBUILD,
PAGELATCH, LOGBUFFER, ASYNC_NETWORK_IO, SOS_PHYS_PAGE_CACHE, and others.
Remove dead RESOURCE_SEMAPHORE branch (pre-execution wait, never appears
in statement-level plan wait stats).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Annotate each wait stat line in the advice panel with a short description
(e.g., "I/O — reading data from disk", "CPU — scheduler yielding") so
users can immediately understand what each wait type means without leaving
the panel. Labels render inline in muted text via GetWaitLabel().

Extract DescribeWaitType() from GetWaitStatsAdvice() so the wait type
knowledge is reusable. Remove dead RESOURCE_SEMAPHORE branch (pre-execution
wait, never appears in plan wait stats). Drop the separate summary line
that had formatting issues in favor of per-line inline labels.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@erikdarlingdata erikdarlingdata merged commit 3439ce6 into dev Apr 10, 2026
2 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.

1 participant