feat: add dependencyLevels scheduler for parallel up (#128, step 1) - #144
Open
OrtegaMatias wants to merge 1 commit into
Open
feat: add dependencyLevels scheduler for parallel up (#128, step 1)#144OrtegaMatias wants to merge 1 commit into
up (#128, step 1)#144OrtegaMatias wants to merge 1 commit into
Conversation
Groups services into launch WAVES by their depends_on graph: every service in a wave has all of its in-set dependencies in an earlier wave, so a whole wave can be launched concurrently. This is the pure, daemon-free core of parallelizing `up` (Mcrich23#128), where independent services currently start sequentially (~23s for 11 independent services vs ~7s in parallel). - depends_on entries naming a service outside the selected set (e.g. profile-excluded) are ignored, matching topoSortConfiguredServices. - Throws on a dependency cycle (including a self-dependency) before returning, so a cyclic graph can never deadlock a concurrent launch. Pure static function mirroring the existing graph helpers, with 6 static tests: linear chain, diamond, independent set, cycle, self-dependency, and out-of-set dependency. No behavior change yet — `up` still launches serially; this lands the schedulable core first.
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.
Summary
First step toward parallel
up(#128): a pure, daemon-free scheduler that groups services into launch waves by theirdepends_ongraph. Every service in a wave has all of its in-set dependencies in an earlier wave, so a whole wave can becontainer runlaunched concurrently.Today
uplaunches services strictly sequentially (for target in project.services { try await configService(...) }), so N independent services pay N× the per-service start+readiness cost. The issue reports ~23s for 11 independent services vs ~7s launched in parallel.This PR lands only the schedulable core — a pure function with tests — with no behavior change yet (
upstill launches serially). The concurrent launch that consumes it will follow in a separate PR, so the correctness-critical ordering logic can be reviewed and regression-tested on its own (and it lands in the only tier CI runs).API
Mirrors the existing pure graph helpers (
topoSortConfiguredServices,selectServices,validateRequestedServices):level 0= services with no in-set dependency;level(s) = 1 + max(level(dep)). Level 0 first; intra-wave order is unspecified (they start concurrently).depends_onnaming a service not in the set (e.g. profile-excluded) is treated as already satisfied — same tolerance astopoSortConfiguredServices.NSError/"ComposeError" shape astopoSortConfiguredServices, so a cyclic graph can never deadlock a future concurrent launch.Tests
New
@Suite("Parallel Scheduler Levels"), static (no daemon), mirroringServiceDependencyTests:web → app → db⇒[["db"], ["app"], ["web"]](chain is not falsely parallelized)front → {web, api} → db) ⇒ siblings share a wavedepends_onon an out-of-set service ⇒ dependent lands in wave 0, no throw