feat(scheduler): add resource-bounded grouped round-robin scheduling - #68
feat(scheduler): add resource-bounded grouped round-robin scheduling#68shudorcl wants to merge 8 commits into
Conversation
|
✅ OpenCodeReview: Review complete: 0 finding(s) across 7 selected item(s). |
|
@blahgeek @LSX-s-Software This PR has been open for a week. CI is passing and the PR is mergeable, but it hasn’t received a review yet. Could you please take a look when you have a spare moment? If you’re unavailable, would you mind suggesting an alternative reviewer? Thanks! |
|
Thanks for putting this together, and sorry for the delayed response. Our main gap is the lack of a simulation framework for evaluating scheduling strategies against realistic workloads. We plan to collect representative workload traces and replay them against different strategies, which will let us compare CPU/memory balance, cache hit ratio, cold starts across workload patterns. This does not need to be part of this PR. We can leave this strategy open and merge it once the simulation framework is in place. |
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.
025adc1 to
33ea518
Compare
|
Thanks for the context, and sorry for the delayed follow-up. Is anyone already working on or designing the simulation framework? |
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