[History Server] Cache snapshot struct in the session LRU instead of JSON bytes #5208
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 · 375 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.355
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #5208"
general
weight: 0.35
chiayi
Why are these changes needed?
SessionLoadercached dead-session snapshots as JSON bytes and ranjson.Unmarshalon everyGetSnapshotcall, so each HTTP request paid a full decode and allocated a complete newSessionSnapshot. This PR stores theSessionSnapshotstruct directly and returns the shared pointer, making the read path zero-decode / zero-alloc.Changes:
SessionLoader:- LRU now holds
cacheEntry{snap, size}-
putSnapshotmarshals once only to estimate size for the byte budget.-
GetSnapshotreturns the cached pointer.cacheEntryis the marshaled JSON size *sessionSnapshotHeapFactor(2.5). The value is based on the discussion here https://github.com/ray-project/kuberay/pull/5208#discussion_r3890261932SessionSnapshotandGetSnapshot).utils.ApplyTaskFilters: This was the only consumer that mutated the snapshot in place. Updated to clone before sorting.Benchmark
Columns:
Read path (
GetSnapshot, one HTTP request)| n | ns/op before | ns/op after | B/op before | B/op after | allocs/op before | allocs/op after |
|---|---|---|---|---|---|---|
| 100 | 605.5k | 140 | 354.0k | 0 | 5.6k | 0 |
| 1000 | 5.8M | 140 | 3.7M | 0 | 55.1k | 0 |
| 10000 | 57.6M | 140 | 45.9M | 0 | 550.2k | 0 |
Write path (
putSnapshot, one cold load)| n | ns/op before | ns/op after | B/op before | B/op after | allocs/op before | allocs/op after |
|---|---|---|---|---|---|---|
| 100 | 239.0k | 231.9k | 215.4k | 215.4k | 2.6k | 2.6k |
| 1000 | 2.4M | 2.3M | 2.1M | 2.1M | 26.0k | 26.0k |
| 10000 | 24.2M | 22.9M | 21.8M | 21.7M | 260.0k | 260.0k |
Related issue number
<!-- For example: "Closes #1234" -->
Labels
<!-- Please add the appropriate labels to this PR. -->
doc-updates-requiredlabel.breaking-changelabel.Checks
- [x] Unit tests
- [ ] 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
<!--
Provide step-by-step instructions so reviewers can verify your changes.
Include any relevant screenshots or logs demonstrating the behavior.
-->