incr
ossIncremental computation engine for Rust. Tracks dependencies between computations automatically and only reruns what's actually affected.
Most software recomputes everything from scratch whenever anything changes. Your CI rebuilds the whole project when you edit one file, your dashboard re-queries the whole database when one row updates. There are domain-specific fixes for this (React diffs the DOM, Salsa caches compiler queries, Materialize does incremental SQL) but if you just want to make your own code incremental, there’s nothing to reach for.
incr is a crack at solving that. It’s a Rust library (with Python bindings, pip install --pre incr-compute or incr-concurrent) that tracks dependencies between computations automatically and only reruns what’s actually affected by a change. The engine lives in incr-core and is parameterized over a concurrency strategy; two surface crates expose it: incr-compute (Local strategy, single-threaded, zero atomic-fence cost) and incr-concurrent (Shared strategy, Send + Sync, lock-free reads). Same public API, one-line dependency swap.
The compiler monomorphizes both paths from the same source, so neither crate subsidizes the other: single-threaded users pay no atomic-fence cost; concurrent users pay no extra indirection for the lock-free read path.
A graph can outlive its process. incr-persist keeps a log plus snapshots on pluggable backends, and memoized values are stored with their dependencies, so after a restart an entry verifies without rerunning while its inputs are unchanged. Memo checkpoints append only what changed since the last one and compact the chain into a full generation when it reaches 8 deltas or the deltas grow past a quarter of the base. Both Python wheels ship the persistence layer. rt.overlay() runs what-if reads: apply candidate changes, read the results, and on exit the base is restored exactly. incr-kube replaces kube-rs’s reflector Store<K> with an incrementally maintained view, so a controller’s selective queries stop scanning the whole cache. How it holds up in a live service is written up in incr in a live service.
Numbers
- ~105–220× faster for incremental collection inserts vs from-scratch recomputation
- ~108 ns/node propagation through function DAGs (chain of 100 nodes, single-threaded path)
- Ten collection operators:
filter,map,count,aggregate,reduce,sort_by_key,pairwise,window,group_by,join
Current version: 0.2.0-beta.12.
License: AGPL-3.0-only from 0.2.0-beta.12, with a commercial licence available; 0.2.0-beta.11 and earlier are Apache-2.0.