Add new scheduler component for distributed ML workload orchestration: - Hub-based coordination for multi-worker clusters - Pacing controller for rate limiting job submissions - Priority queue with preemption support - Port allocator for dynamic service discovery - Protocol handlers for worker-scheduler communication - Service manager with OS-specific implementations - Connection management and state persistence - Template system for service deployment Includes comprehensive test suite: - Unit tests for all core components - Integration tests for distributed scenarios - Benchmark tests for performance validation - Mock fixtures for isolated testing Refs: scheduler-architecture.md
28 lines
678 B
Go
28 lines
678 B
Go
package scheduler
|
|
|
|
// AdaptivePacingController derives request pacing based on worker capacity.
|
|
type AdaptivePacingController struct {
|
|
DesiredRPSPerWorker int
|
|
}
|
|
|
|
// NewAdaptivePacingController constructs a controller with sane defaults.
|
|
func NewAdaptivePacingController(desired int) AdaptivePacingController {
|
|
if desired < 1 {
|
|
desired = 1
|
|
}
|
|
return AdaptivePacingController{DesiredRPSPerWorker: desired}
|
|
}
|
|
|
|
// RequestsPerSec returns max(1, maxWorkers * desiredRPSPerWorker).
|
|
func (a AdaptivePacingController) RequestsPerSec(maxWorkers int) int {
|
|
if maxWorkers < 1 {
|
|
maxWorkers = 1
|
|
}
|
|
|
|
rps := maxWorkers * a.DesiredRPSPerWorker
|
|
if rps < 1 {
|
|
rps = 1
|
|
}
|
|
|
|
return rps
|
|
}
|