Durable Incrementality
rust-analyzer.github.io
rust-analyzer.github.io
It’s cool that’s there’s quite a lot of it going on rust land. There’s this, I believe the rust compiler has a little differential dataflow thing, Frank McSherry has done a stack of cool stuff with the timely and differential dataflow libraries-some of which lives on in Materialize db.
Er, what? If you get 2 modifications before actually forcing the computation, the second won't have to mark anything since it will quickly see "this node is already dirty" and stop propagating the dirty flag upward.
The interesting optimizations to me are 1. when should nodes share a dirty flag, and 2. for what simplicity level should you just always redo the calculation (this is highly dependent on what kind of interpreter or compiler/runtime you're evaluating with).
The trick in comemo's blog post is to make the dependencies fine-grained, by tracking and only comparing what parts of them are actually used; while the trick here is to have functions depend on other outputs instead of the root input, so changes don't propagate all the way (+ laziness). But I'm sure some comemo functions are memoized on incremental computations, and salsa has some way to e.g. not recompute the entire AST when the source code changes.
I suspect there's also an issue where most incremental computations tend to invalidate way more than they need to; like if someone accidentally creates a function which takes a big array and an index, and only access the element at or a few elements around that index, but the anything in big array changing will cause it to be recomputed. So is there a system to profile what gets recomputed every time a query is run?
However, it would require dependencies to be tracked in both directions, so it's probably not possible to engineer it into Salsa, which seems to only track dependencies from consumer to producer.
I was going to blog about this design in detail, but never got around to it.