Cap pooled bulk buffer sizes to reduce memory retention #8396
All Vouch review confidence checks passed
Residual risk 0.27 = Change Risk (0.37) × (1 − Review Confidence (0.26)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.37 · 220 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 36% · 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
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.323
Real PR Conversation Timeline
1 comments
"Review active on #8396"
general
weight: 0.35
copilot-pull-request-reviewer[bot]
What is the problem this PR solves?
The bulk engine reuses pooled buffers for individual requests and batched Elasticsearch flushes with no capacity limit. After a large request or batch grows a buffer, the pool keeps that oversized allocation across garbage collection cycles and increases memory usage under load.
This change is extracted from https://github.com/elastic/fleet-server/pull/8372 which contains the scale-test results and regression checks.
How does this PR solve the problem?
When a buffer returns to its pool, the bulk engine discards flush buffers larger than 1 MiB and releases request buffers larger than 64 KiB so the garbage collector can reclaim them. Buffers at or below those limits remain in the pools for reuse.
How to test this PR locally
Run the affected unit tests:
Design Checklist
Checklist
Made with Cursor