mirror of
https://github.com/salsa-rs/salsa.git
synced 2025-01-22 21:05:11 +00:00
A generic framework for on-demand, incrementalized computation. Inspired by adapton, glimmer, and rustc's query system.
9df075b63c
Accumulators don't currently work across revisions due to a few bugs. This commit adds 2 tests to show the problems and reworks the implementation strategy. We keep track of when the values in an accumulator were pushed and reset the vector to empty when the push occurs in a new revision. We also ignore stale values from old revisions (but update the revision when it is marked as validated). Finally, we treat an accumulator as an untracked read, which is quite conservative but correct. To get better reuse, we would need to (a) somehow determine when different values were pushed, e.g. by hashing or tracked the old values; and (b) have some `DatabaseKeyIndex` we can use to identify "the values pushed by this query". Both of these would add overhead to accumulators and I didn'τ feel like doing it, particularly since the main use case for them is communicating errors and things which are not typically used from within queries. |
||
---|---|---|
.github/workflows | ||
book | ||
calc-example/calc | ||
components | ||
examples | ||
salsa-2022-tests | ||
src | ||
tests | ||
.dir-locals.el | ||
.gitignore | ||
bors.toml | ||
Cargo.toml | ||
FAQ.md | ||
LICENSE-APACHE | ||
LICENSE-MIT | ||
README.md | ||
RELEASES.md |
salsa
A generic framework for on-demand, incrementalized computation.
Obligatory warning
Very much a WORK IN PROGRESS at this point. Ready for experimental use but expect frequent breaking changes.
Credits
This system is heavily inspired by adapton, glimmer, and rustc's query system. So credit goes to Eduard-Mihai Burtescu, Matthew Hammer, Yehuda Katz, and Michael Woerister.
Key idea
The key idea of salsa
is that you define your program as a set of
queries. Every query is used like function K -> V
that maps from
some key of type K
to a value of type V
. Queries come in two basic
varieties:
- Inputs: the base inputs to your system. You can change these whenever you like.
- Functions: pure functions (no side effects) that transform your inputs into other values. The results of queries is memoized to avoid recomputing them a lot. When you make changes to the inputs, we'll figure out (fairly intelligently) when we can re-use these memoized values and when we have to recompute them.
Want to learn more?
To learn more about Salsa, try one of the following:
- read the heavily commented
hello_world
example; - check out the Salsa book;
- watch one of our videos.
Getting in touch
The bulk of the discussion happens in the issues and pull requests, but we have a zulip chat as well.