Repository navigation
perf(compile): analyze models as soon as their producers finish - #953
Merged
Merged
Conversation
Replace wave-by-wave model analysis with a dependency-driven scheduler. A model is analyzed once every producer shape it binds against is final, so a slow model no longer holds back unrelated models in the next topological level. Worker threads serialize Python preparation and projection under one lock, while self-contained native analysis releases it, so the next ready batch is prepared while earlier batches run natively. The calling thread never takes that lock: it only starts and joins the workers, and on an interrupt or start failure it cancels and joins every started worker before re-raising. Each compile catalog now owns one native analysis pool that every compact analysis and binding batch reuses, instead of building a pool per call. Compact analysis splits into a catalog-resolving prepare step and a run step that no longer borrows the catalog, so catalog updates for later batches proceed while earlier batches run. Spawned drainer tasks replace the pool broadcast, so a batch no longer needs every pool thread to finish. Every model sees exactly the producer shapes, cache entries, and changed upstream signatures it saw under wave scheduling, so compile output does not depend on completion order. An ordinary analysis error replays the wave schedule to raise the same first error; an interrupt or other non-Exception failure always wins and propagates without a replay.
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.
Why
Model analysis ran in topological waves, so every wave waited for its slowest model and a new native thread pool was built per call (58 waves and pools on a ~1,400-model project). Stage 4 of CHI-482 (CHI-500); it also adds the shared pool and prepare/run split that early rule evaluation builds on.
Changes
Verification
--no-cacheon random projects and fixtures; determinism across worker counts and injected delays; interrupt, start-failure and pool-reuse tests.make test,make check-ci.