diff --git a/nativelink-scheduler/src/api_worker_scheduler.rs b/nativelink-scheduler/src/api_worker_scheduler.rs index edfe56c67..3dae0b854 100644 --- a/nativelink-scheduler/src/api_worker_scheduler.rs +++ b/nativelink-scheduler/src/api_worker_scheduler.rs @@ -238,6 +238,14 @@ impl ApiWorkerSchedulerImpl { platform_properties: &PlatformProperties, full_worker_logging: bool, ) -> Option { + // Do a fast check to see if any workers are available at all for work allocation + if !self.workers.iter().any(|(_, w)| w.can_accept_work()) { + if full_worker_logging { + info!("All workers are fully allocated"); + } + return None; + } + // Use capability index to get candidate workers that match STATIC properties // (Exact, Unknown) and have the required property keys (Priority, Minimum). // This reduces complexity from O(W × P) to O(P × log(W)) for exact properties. diff --git a/nativelink-service/tests/worker_api_server_test.rs b/nativelink-service/tests/worker_api_server_test.rs index ef31b945a..607bcb5f7 100644 --- a/nativelink-service/tests/worker_api_server_test.rs +++ b/nativelink-service/tests/worker_api_server_test.rs @@ -623,9 +623,7 @@ pub async fn workers_only_allow_max_tasks() -> Result<(), Box