Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Async, Concurrency, and Resource Budgets

The server accepts connections continuously and spawns one Tokio task per connection. That is request concurrency, not permission to launch unlimited compilers.

The internal jobserver supplies the CPU/process budget. acquire() bridges the blocking jobserver helper thread to async Rust with a request channel and a per-acquisition oneshot; the returned Acquired value owns the token until drop. This is the same ownership pattern as the toy job runner, but here the permit represents machine compilation capacity rather than a typed result.

Remote storage and distributed scheduling are awaited normally. Disk archive I/O, dependency inspection, compression, and other synchronous library work use spawn_blocking so they do not occupy cooperative Tokio workers.

Multi-level storage introduces controlled fanout: levels are queried according to policy, slower hits may backfill faster levels, and write-error policy says which failures affect the compiler result. Concurrency is therefore split by resource and consequence rather than governed by one global semaphore.

Shutdown stops acceptance through explicit signal, RPC, or idle timeout. A WaitUntilZero future retains only a Weak pointer and resolves when all connection-owned ActiveInfo clones drop, with a ten-second outer deadline.