Skip to main content

Module solver

Module solver 

Source
Expand description

Async parallel solver with work distribution.

Per parallel_review §2 / summary_review §2, the previous implementation cloned the entire DagArena once per worker chunk and spun an OS thread per chunk via std::thread::spawn. For a million-node DAG split into 16 chunks that’s 16 × ~88 B × 1 M ≈ 1.4 GB of redundant allocations and 16 native thread spawns.

The rewrite:

  1. Arena is shared read-only via Arc<DagArena>one Arc bump per fan-out instead of N clones.
  2. Tasks dispatch through crate::runtime::parallel_for_each, which uses dtact fibers (plan.md §4.3).
  3. evaluate_node is now iterative (worklist + value stack) instead of recursive — no more stack-overflow risk on deep expressions.

Structs§

FnEvalRegistry
Registry of function-pointer callbacks for parallel evaluation of SymbolKind::Function nodes.
OpEvalRegistry
Registry of operator-evaluation overrides for the parallel evaluator.

Functions§

evaluate_node
Evaluates a single DAG node against the variable bindings, iteratively.
evaluate_node_with_fns
Variant of evaluate_node that supports SymbolKind::Function nodes via a user-supplied FnEvalRegistry.
evaluate_node_with_overrides
Variant of evaluate_node_with_fns that also accepts an OpEvalRegistry for overriding built-in operator evaluation.
parallel_evaluate
Solves and evaluates a set of expression-leaf chunks in parallel.
parallel_evaluate_shared
Zero-clone parallel evaluator. The arena is shared read-only across all worker fibers via Arc; no per-chunk duplication.