#computation #query #framework #salsa #key #generic #system

ra_ap_salsa

A generic framework for on-demand, incrementalized computation (experimental)

62 releases

new 0.0.264 Feb 17, 2025
0.0.261 Jan 28, 2025
0.0.251 Dec 30, 2024
0.0.246 Nov 25, 2024
0.0.207 Mar 25, 2024

#209 in Algorithms

Download history 4939/week @ 2024-10-28 3404/week @ 2024-11-04 3215/week @ 2024-11-11 3439/week @ 2024-11-18 2988/week @ 2024-11-25 3278/week @ 2024-12-02 3163/week @ 2024-12-09 2776/week @ 2024-12-16 1209/week @ 2024-12-23 1280/week @ 2024-12-30 3788/week @ 2025-01-06 2757/week @ 2025-01-13 3062/week @ 2025-01-20 2767/week @ 2025-01-27 3090/week @ 2025-02-03 3186/week @ 2025-02-10

12,294 downloads per month
Used in 25 crates (2 directly)

Apache-2.0 OR MIT

210KB
4K SLoC

salsa

A generic framework for on-demand, incrementalized computation.

Obligatory warning

This is a fork of https://github.com/salsa-rs/salsa/ adjusted to rust-analyzer's needs.

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:

Getting in touch

The bulk of the discussion happens in the issues and pull requests, but we have a zulip chat as well.

Dependencies

~2.2–7.5MB
~57K SLoC