[Fix #10460]: Pre-size ProxyContext map to avoid HashMap resize on request path#10461
[Fix #10460]: Pre-size ProxyContext map to avoid HashMap resize on request path#10461HarshMehta112 wants to merge 3 commits into
Conversation
Signed-off-by: Harsh Mehta <harshmehta010102@gmail.com>
Signed-off-by: Harsh Mehta <harshmehta010102@gmail.com>
Signed-off-by: Harsh Mehta <harshmehta010102@gmail.com>
oss-sentinel-ai
left a comment
There was a problem hiding this comment.
Review: Approved ✅
PR: #10461 — [Fix #10460]: Pre-size ProxyContext map to avoid HashMap resize on request path
Type: Performance optimization (1 file, +2/-1)
Assessment
Valid performance fix. ProxyContext is created per gRPC/Remoting request, and its value map previously used the default HashMap capacity (16, threshold 12). Adding ~10 ContextVariable keys plus interceptor entries would trigger a resize on the hot path.
Changes
- Pre-sized
HashMapto 64 (threshold 48), well above the expected key count - Minimal, focused change with no API impact
Verdict
✅ Clean, well-targeted optimization. Fixes #10460.
🤖 Automated review by oss-sentinel-ai
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #10461 +/- ##
=============================================
- Coverage 48.11% 47.99% -0.12%
+ Complexity 13329 13289 -40
=============================================
Files 1377 1377
Lines 100632 100632
Branches 12995 12995
=============================================
- Hits 48422 48302 -120
- Misses 46289 46385 +96
- Partials 5921 5945 +24 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Which Issue(s) This PR Fixes
Brief Description
ProxyContextis created on every gRPC/Remoting request. Itsvaluemap used the defaultHashMapcapacity (16, threshold 12), so adding the 10ContextVariablekeys plus interceptor entries triggers aresize on the hot path. Pre-size the map to avoid it:
No behavior or API change.
How Did You Test This Change?
Pure capacity refactor, no logic change. Existing proxy module tests pass.