pref: add index and optimize lookup #1901
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
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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
tanishagoyal2
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
$lookupself-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$limitstage 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 servesMultipleRemediations, which is the only rule that readsfaultremediatedand 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 |
|
$lookupruns 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
Component(s) Affected
Testing
Checklist
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
Summary by CodeRabbit
- 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.
- 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 -->