Skip to content

Add wait stats benefit scoring (Stage 2)#224

Merged
erikdarlingdata merged 1 commit intodevfrom
feature/wait-stats-benefit
Apr 14, 2026
Merged

Add wait stats benefit scoring (Stage 2)#224
erikdarlingdata merged 1 commit intodevfrom
feature/wait-stats-benefit

Conversation

@erikdarlingdata
Copy link
Copy Markdown
Owner

Summary

  • Stage 2 of the maximum benefit system ([FEATURE] Add system to assign a "maximum benefit" for plan analysis rules #215): calculate MaxBenefitPercent for each wait type
  • Serial plans: waitMs / elapsedMs * 100
  • Parallel plans: Joe's proportional allocation formula — maps wait types to relevant operators, distributes benefit by per-thread wait time
  • Parallelism waits (CXPACKET etc.) use efficiency gap formula, not raw wait time
  • New WaitBenefit model, wait_benefits array in JSON output
  • Benefit % shown in CLI text, HTML export, and desktop app wait stats ribbon

Test plan

  • dotnet build — 0 errors
  • dotnet test — 75/75 pass
  • Tested against 6 example plans with wait stats — benefits look correct
  • CXPACKET on parallel-skew plan: 24% (was 98% before efficiency gap fix)
  • Serial plan (udf): SOS_SCHEDULER_YIELD 4% — simple ratio works

🤖 Generated with Claude Code

Calculate MaxBenefitPercent for each wait type in plan wait stats.
Serial plans use a simple ratio (waitMs/elapsedMs). Parallel plans
use Joe's proportional allocation formula, mapping wait types to
relevant operators (I/O waits to operators with physical reads,
CPU waits to operators with CPU work, etc.).

Parallelism waits (CXPACKET/CXCONSUMER/CXSYNC) use the efficiency
gap formula instead of raw wait time — threads waiting for other
threads is a symptom, not directly addressable time.

Benefits shown in CLI text, HTML export, JSON API (wait_benefits
array), and desktop app wait stats ribbon.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@erikdarlingdata erikdarlingdata merged commit fa8458f into dev Apr 14, 2026
2 checks passed
@erikdarlingdata erikdarlingdata deleted the feature/wait-stats-benefit branch April 19, 2026 00:25
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