[History Server] Cache JSON bytes and share the decoded snapshot via a weak pointer #5285
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.40) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 315 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.344
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #5285"
general
weight: 0.35
win5923
Why are these changes needed?
Based on the comment https://github.com/ray-project/kuberay/pull/5208#discussion_r3969000721, storing the Go struct directly is not a good choice, as there's no way for us to accurately estimate Go struct memory usage, and a fixed factor is not ideal.
This PR follows the method mentioned in https://github.com/ray-project/kuberay/pull/5208#discussion_r3969000721: it still stores the encoded JSON bytes in the LRU cache, alongside a weak pointer which points to the decoded snapshot, so concurrent requests can share the same decoded object rather than each request holding a separate copy. The byte budget goes back to counting the exact JSON length, so the 2.5x heap factor from #5208 is removed.
Related issue number
Follow-up: https://github.com/ray-project/kuberay/pull/5208#discussion_r3969000721
Labels
<!-- Please add the appropriate labels to this PR. -->
doc-updates-requiredlabel.breaking-changelabel.Checks
- [x] Unit tests
- [x] Manual tests
- [ ] This PR is not tested :(
<!-- If you selected "Manual tests" above, please fill in the section below. Otherwise you can remove it. -->
Manual test instructions
Columns are the average per GetSnapshot call: time, heap bytes allocated, and number of heap allocations.
| Version | Cache stores | ns/op | B/op | allocs/op |
|---|---|---|---|---|
| Before #5208 (
5914ac04^) | JSON bytes, decode per request | 3417 | 7512 | 112 || master (#5208) | decoded struct, 2.5x heap estimate | 257.8 | 0 | 0 |
| This PR | JSON bytes + weak pointer to shared decoded copy | 249.9 | 0 | 0 |
Add following benchmark test to
historyserver/pkg/historyserver/session_loader_test.go, and run with: