feat(scheduler): add resource-bounded grouped round-robin scheduling - #68
Open
shudorcl wants to merge 7 commits into
Open
feat(scheduler): add resource-bounded grouped round-robin scheduling#68shudorcl wants to merge 7 commits into
shudorcl wants to merge 7 commits into
Conversation
Add template_id to the internal scheduling hint and extract it from bounded sandbox creation bodies so scheduler strategies can group template and snapshot requests. Refs kvcache-ai#15
Replace raw heartbeat snapshot peeks with a scheduling snapshot whose node status reflects discovery state and heartbeat TTL.
Keep requests for the same image or template on an open group node until a sandbox, CPU, or memory budget closes the group. Assign new groups through stable global round-robin, require ready telemetry, and account concurrent placements atomically. Refs kvcache-ai#15
Wire locality strategy limits through scheduler JSON and environment configuration, validate the mandatory sandbox bound, and document the placement semantics and operator controls. Refs kvcache-ai#15
Rename the strategy and its configuration surface to grouped_round_robin so the public name describes its resource-bounded grouping and rotation semantics precisely.
Contributor
|
✅ OpenCodeReview: No comments generated. Looks good to me. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
This PR adds an opt-in
grouped_round_robinscheduling strategy as a bounded workload-affinity building block for #15. Requests with the same rootfs image reference or exact template reference stay on one eligible READY node until the group's sandbox, CPU, or memory budget is reached, after which a new group is assigned through global round-robin.The Gateway now propagates
templateIDthrough the internal scheduling hint, scheduling snapshots derive current node status from discovery state and heartbeat TTL, and the new strategy is covered by configuration, documentation, and focused tests.Why
Plain round-robin can scatter repeated workloads across nodes and repeatedly warm the same image or template artifacts. Grouped placement improves the opportunity for local cache reuse while bounding concentration and preserving the existing node resource filter.
Related issue
Refs #15
This PR provides request-identity affinity but does not close the broader cache-aware scheduling issue.
Scope and non-goals
In scope: grouped placement by the first rootfs image or exact template reference, configurable group budgets, fresh READY-node enforcement, bounded in-memory group state, gateway hint propagation, and operator documentation.
Non-goals: inspecting or scoring actual node cache or P2P inventory, resolving mutable image tags or template aliases, considering attached-drive identities, adding projected hard-capacity admission, or persisting and reconciling group state across scheduler restarts.
Design and behavior changes
Each workload identity has at most one open group. Requests reuse its node while the request fits the configured group budget; otherwise the group closes and the request starts a new group on the next eligible node. New groups for all identities share one stable global round-robin cursor, while missing or oversized identities use a separate round-robin fallback.
Placement accounting is serialized and updated during scheduling so concurrent bursts cannot overfill an open group while heartbeat metrics lag. Open state is capped at 10,000 keys with LRU eviction. Template requests do not carry CPU or memory values, so their groups use the sandbox-count limit only.
Compatibility and operations
NewSandboxHint.template_idfield 2, which is wire-compatible with mixed Gateway and Scheduler versions.round_robin. Selectinggrouped_round_robinrequiresscheduler.grouped_round_robin.max_sandbox_count > 0; CPU and memory group limits are optional. Equivalent environment overrides are documented.Validation
make fmtmake clippymake test-unitmake -C services test(required whenservices/changes)maketargetCommands and results:
Local
make -C services fmt-checkreports unrelated CRLF files because this WSL checkout usescore.autocrlf=true; the same commit passesfmt-checkin Services CI.Skipped checks and reasons:
Risks and reviewer notes
services/scheduler/internal/strategy.go,services/gateway/internal/schedule_hint.go,services/scheduler/internal/node_registry.go, andservices/shared/config/config.go.Checklist