[Store] feat: add workload-aware KV cache hints#2830
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces WorkloadHints (consisting of session_id and retention_priority) to associate workload-level metadata with stored objects, integrating it across ReplicateConfig, ObjectMetadata, MasterService, and Python bindings. It also updates MsgPack serialization/deserialization to support these hints while maintaining backward compatibility with older snapshot formats. Feedback on these changes suggests removing noexcept from the WorkloadHints stream insertion operator to prevent unsafe terminations, optimizing ReplicateConfig::IsDefault() by comparing against a static const instance, and improving forward-compatibility during metadata deserialization by verifying the element type before parsing it as workload hints.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| friend std::ostream& operator<<(std::ostream& os, | ||
| const WorkloadHints& hints) noexcept { |
There was a problem hiding this comment.
Marking operator<< as noexcept is unsafe because stream insertion operations (such as writing to os or copying/formatting hints.session_id) can throw exceptions (e.g., if the stream has its exception mask configured to throw on failure, or due to allocation failures). If an exception is thrown inside a noexcept function, std::terminate will be called immediately. It is standard practice to omit noexcept from stream insertion operators.
| friend std::ostream& operator<<(std::ostream& os, | |
| const WorkloadHints& hints) noexcept { | |
| friend std::ostream& operator<<(std::ostream& os, | |
| const WorkloadHints& hints) { |
|
|
||
| bool operator==(const ReplicateConfig&) const = default; | ||
|
|
||
| bool IsDefault() const { return *this == ReplicateConfig{}; } |
There was a problem hiding this comment.
| if (index < total_elements) { | ||
| const auto& hints_object = array[index++]; | ||
| if (hints_object.type != msgpack::type::ARRAY || | ||
| hints_object.via.array.size != 2) { |
There was a problem hiding this comment.
To ensure robust forward-compatibility, we should check if the next element is actually an array before consuming it as workload_hints. If a future version of the snapshot format omits workload_hints but appends other optional fields of different types, unconditionally advancing index and expecting an array will cause deserialization to fail. Checking the type first allows the deserializer to safely skip workload_hints and ignore unknown trailing fields.
if (index < total_elements && array[index].type == msgpack::type::ARRAY) {
const auto& hints_object = array[index++];
if (hints_object.via.array.size != 2) {|
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
Description
Implements Stage 1 of RFC #2819: Workload-Aware KV Cache Hints. This PR does not close the RFC because eviction policy, observability, and external framework integrations remain follow-up work.
This change:
WorkloadHintsAPI with optionalsession_idandretention_priorityfields while leaving all existingReplicateConfigfields in place;group_idssemantics;PUToperations and preserves the original hints when an existing object is upserted;retention_priorityis stored as provided. Callers or integration layers are responsible for normalization. Same-version client/master RPC propagation is covered here; rolling mixed-version RPC compatibility is not introduced in this stage.Module
mooncake-transfer-engine)mooncake-store)mooncake-ep)mooncake-pg)mooncake-integration)mooncake-p2p-store)mooncake-wheel)mooncake-common)mooncake-rl)Type of Change
How Has This Been Tested?
Coverage includes default and non-default hints, single and batch writes, coexistence with
group_ids, duplicatePUT, same-size and size-changing upserts, real client/master RPC propagation, current and legacy snapshot restoration, catalog-backed snapshot acceptance, and Python binding round trips.Test commands:
Test results:
Unit tests pass
Integration tests pass (if applicable)
Manual testing done (describe below)
The four requested CTest targets passed: 4/4.
Catalog-backed snapshot provider tests passed: 9/9.
Python import and binding tests passed: 3/3, plus a native-extension field round trip.
Targeted pre-commit hooks and
git diff --checkpassed.The Sphinx HTML build completed successfully. It emitted seven warnings because external intersphinx inventories were unreachable in the restricted network environment.
Checklist
./scripts/code_format.shpre-commit run --all-filesand all hooks passAI Assistance Disclosure
OpenAI Codex assisted with implementation, test development, and compatibility review. I reviewed and edited the generated code before submission.