← Back to Pull requests

pref: add index and optimize lookup #1901

Closed
unknown closed this pull request without merging on Sep 23, 2026 11:23 UTC
View on GitHub
unknown unknown commented on Sep 22, 2026 14:25 UTC
Author

Summary

The health-events-analyzer evaluates 22 rules for each health event. Each rule sends one query to MongoDB. This change makes those queries cheaper.

Problem 1: the self-join repeats the same work. Four XID 74 rules use a $lookup self-join. The sub-query reads only the node name and the GPU UUID. The mandatory first stage already limits the query to one node. Every event on the same GPU therefore asks the sub-query the same question. The rule ran that sub-query one time for each matching document, and each run read the node's full 24-hour window again. The cost grew with the square of the event rate on the node.

Problem 2: the available index does not fit the rule filters. The index that the rules use includes entitiesimpacted, which is an array. MongoDB therefore creates about three index keys for each document. The rules filter on none of those fields, so they pay that cost for no result.

Changes

1. The four XID 74 rules now group the documents by GPU before the $lookup. The sub-query runs one time for each GPU instead of one time for each document. A terminal $limit stage stops the rule at the first match.
2. Two new indexes support the rule filters. Both are non-multikey and create one key for each document. The first serves the 16 rules that filter on ishealthy. The second serves MultipleRemediations, which is the only rule that reads faultremediated and the only rule with a 7-day window.

Results

Measured on MongoDB 8.0.3 with the chart resource limits, 500 nodes and 1.53M events:

| Measurement | Before | After |
| --- | --- | --- |
| Fleet-weighted cost for each event | 210 ms | 68 ms |
| Busiest node, XID 74 event | 1,550 ms | 305 ms |
| $lookup runs for each event | 96 | 8 |

The rules give the same result as before. A test compared the old and new rules across all 500 nodes: 4,000 comparisons, 63 matches, 0 differences.

Type of Change


  • [X] 🐛 Bug fix

  • ✨ New feature

  • 💥 Breaking change

  • 📚 Documentation

  • 🔧 Refactoring

  • 🔨 Build/CI
  • Component(s) Affected


  • [X] Health Monitor

  • Core Service

  • Fault Management

  • Janitor

  • Deployment/Config

  • API/Interface

  • Preflight

  • Plugins

  • Documentation/CI

  • New Component

  • Multiple Components

  • Other
  • Testing


  • [X] Tests pass locally

  • [X] Manual testing completed

  • [X] No breaking changes (or documented)
  • Checklist


  • [X] Self-review completed

  • [X] Documentation updated (if needed)

  • [X] Ready for review
  • <!-- This is an auto-generated comment: release notes by coderabbit.ai -->

    Summary by CodeRabbit

  • Performance

  • - Improved health-event analysis efficiency by grouping GPU-related candidate events before historical lookups, reducing redundant query work.
    - Added database indexes to support health-event queries involving nodes, health and remediation status, fatality, and timestamps.

  • Reliability

  • - Preserved existing XID 74 matching behavior while reducing unnecessary lookup work and maintaining expected results.
    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 398 lines (+298 / -100) across 4 files Reviewer: tanishagoyal2 Review duration: 1257m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.43) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.43 · 398 lines diff across 4 files
    0.43
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.358
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #1901"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 43.2% (MEDIUM) · Higher = larger blast radius
    43.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 17.1% · Safe to merge
    17.1%