optimize kueue metadata streaming #57238
All Vouch review confidence checks passed
Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 289 lines diff across 3 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.339
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #57238"
general
weight: 0.35
gjulianm
<!--Please give us some feedback on your experience writing this PR ! https://app.datadoghq.com/forms/43db4c02-6837-400c-8083-692e141b1b88 !-->
What does this PR do?
Optimize Cluster Agent metadata streaming by computing namespace and Kueue metadata changes once per workloadmeta event bundle and sharing the resulting update payloads across connected agents, instead of copying and comparing the full metadata inventory separately for each stream.
Pod-to-service mapping updates remain node-specific. Initial full-state synchronization, deletion handling, and full-state recovery on reconnect are preserved.
Motivation
Namespace and Kueue metadata are shared across agents, but the previous implementation repeated the same snapshot construction and comparisons for every connected stream. Profiling identified this repeated work as a significant source of CPU usage and allocations. Computing these changes once removes the main inventory-size × stream-count scaling cost.
Describe how you validated your changes
BenchmarkMetadataStreamFanout(five repetitions).Approximate benchmark differences, rounded across the evaluated implementations:
| Connected streams | Before: time/op | After: time/op | Before → after: allocated bytes/op |
| ---: | ---: | ---: | ---: |
| 1 | ~0.25 ms | ~0.25 ms | ~594 KB → ~595 KB |
| 10 | ~2.45 ms | ~0.25–0.26 ms | ~5.94 MB → ~0.60 MB |
| 100 | ~24 ms | ~0.26–0.27 ms | ~59.4 MB → ~0.60–0.62 MB |
At 100 streams, this represents approximately 90× faster metadata-update processing and 99% fewer allocated bytes in the benchmark.
Additional Notes
The benchmark uses 1,000 seeded workloads, changes one workload per operation, and processes the update for every stream. Initial synchronization, gRPC serialization, and network I/O are excluded. These results demonstrate the reduction in redundant metadata processing, not an equivalent reduction in total production Cluster Agent CPU usage. Exact results depend on the final buffering implementation and workload.