Full overhaul of Gradient's evaluation workers into a native, parallel, cache-controlled evaluator.
Today every evaluation runs a subprocess EvalWorker/EvalWorkerPool driving a single NixEvaluator over the Nix C API (nix-bindings), with a tryEval-based wildcard resolver, no parallelism across workers, and no control over the Nix eval-cache, it lives per-worker (embedded SQLite) and is thrown away on recycle, so every evaluation re-evaluates from cold and big evals blow up memory.
We want:
- Full control over the evaluation cache.
- The ability to split one flake's evaluation across multiple workers, with the eval cache cached into the Gradient instance so workers share it instead of each re-evaluating the same flake from scratch.
- A native parallel evaluator (no external binary) that isolates per-attribute failures and reclaims memory without restarting the whole process.
- Native evaluation stats/progress (no frontend in this issue, storage + proto only).
This is a from-scratch overhaul: expect breaking changes across gradient-proto, the database, and the API. Optimal results matter more than compatibility.
Builds on / references:
Detail per area in the comments below.
Full overhaul of Gradient's evaluation workers into a native, parallel, cache-controlled evaluator.
Today every evaluation runs a subprocess
EvalWorker/EvalWorkerPooldriving a singleNixEvaluatorover the Nix C API (nix-bindings), with atryEval-based wildcard resolver, no parallelism across workers, and no control over the Nix eval-cache, it lives per-worker (embedded SQLite) and is thrown away on recycle, so every evaluation re-evaluates from cold and big evals blow up memory.We want:
This is a from-scratch overhaul: expect breaking changes across
gradient-proto, the database, and the API. Optimal results matter more than compatibility.Builds on / references:
builtins.tryEvaldoesn't catchattribute missing/ type / infinite-recursion /abort/ I/O failures; a native per-attribute evaluator isolates these.ParallelEvalBuilder, per-threadEvalState, shared work queue,Receiver<JobResult>, memory-threshold restart, GC roots) and the C API expansion (libexpr-c: expose essential evaluator functions for derivation tree inspection NixOS/nix#15842 / C++ shim innix-bindings-sys).--check-cache-status,--max-memory-size, GC roots) and NotAShelf/nix-evaluator-stats (eval stats fromNIX_SHOW_STATS/NIX_COUNT_CALLS).Detail per area in the comments below.