Skip to main content

Module schedule

Module schedule 

Source
Expand description

Running the jobs in a Plan across threads, deterministically.

Design: spec/03-architecture.md section 3.5, and section 3.7 for the determinism rule.

rucc a.c b.c c.c compiles all three in one process on a shared Session, rather than the build system forking three processes that each re-read every header. That is the larger of the two levels of parallelism and it is the reason Session is thread-safe rather than merely convenient.

The rule that makes this safe to have at all: each unit of parallel work writes only to its own slot, and results are merged in index order, never in completion order. Byte identical output is a requirement in spec/02-the-goal.md, and a scheduler that merges by whoever finishes first quietly gives it up. The API here makes that hard to get wrong, because the only thing a caller can do with a result is receive the whole vector back in input order.

§Status

The scheduler is real. The work it schedules is not, until M3. spec/18-package-layout.md section 18.3 has rayon down for this, and it will be needed for the per-function level inside a translation unit; for the per-file level a scoped thread per job is the whole implementation and it costs no dependency, so that is what this is.

Enums§

Jobs
How many jobs to run at once.

Functions§

run
Runs work over every item, and returns the results in input order.