Files
RedBear-OS/src/cook.rs
T
vasilito 31c71859e1
redbear-ci / check (push) Has been cancelled
cook: dep-level parallel recipe cooking (concurrent independent recipes)
The cook orchestrator built recipes strictly serially — COOKBOOK_MAKE_JOBS only
parallelized within a single recipe's make, so cores sat idle during every
recipe's configure/link/small-file phases. src/cook/scheduler.rs (dep_levels)
was written for this but never wired in (the module wasn't even declared, so it
never compiled).

- Declare the scheduler module (src/cook.rs) so dep_levels + its 7 tests build.
- New COOKBOOK_COOK_JOBS setting (config.rs, default 1 = serial): how many
  recipes to cook concurrently.
- run_parallel_cook (repo.rs): partition recipes into topological dep-levels
  (same level = no inter-deps = safe concurrent), process levels in order behind
  a barrier, and within a level pull recipes from an atomic work-index across
   scoped worker threads. The make-job budget is divided per level so
  a lone heavyweight recipe (e.g. qtbase, alone at its level) still gets the full
  -j, while crowded levels share it — no oversubscription, no slowdown for
  serial-level recipes. Publishing stays a single batched step. Failure/nonstop
  semantics preserved; only engaged for  with cook_jobs>1 and >1 recipe.
- Safe because each recipe builds in its own target/stage/sysroot and a recipe's
  sysroot is assembled from its dependencies' (lower-level, already-complete)
  stage pkgars — read-only for concurrent siblings.
- package.rs: serialize packaging behind a global PACKAGE_LOCK. package() shares
  process-global state (the lazily-created pkgar signing key at
  build/id_ed25519.toml, name/metadata construction) that raced under concurrent
  cooks (corrupt key, mangled names like 'x.dev.dev'); packaging is cheap, so
  serializing it keeps the compile-parallelism win. Also make the package-name
  construction fail gracefully (Err, not unwrap-panic) so a bad name fails one
  recipe instead of crashing the whole scoped-thread build.

Validated: all-cached tree (COOK_JOBS=4) and a real concurrent build of 3
independent recipes (COOK_JOBS=3) both succeed and publish correctly.
2026-08-02 07:32:53 +03:00

13 lines
219 B
Rust

// avoid confusion with build.rs
pub mod cargo_path_deps;
pub mod cook_build;
pub mod fetch;
pub mod fetch_repo;
pub mod fs;
pub mod ident;
pub mod package;
pub mod pty;
pub mod scheduler;
pub mod script;
pub mod tree;