JuliaCon 2020 (times are in UTC)

Salsa.jl: A framework for on-demand, incremental computation
07-29, 13:30–14:00 (UTC), Green Track

Salsa.jl is a framework for on-demand, incremental computation. This type of incremental computing is seen in modern compilers (for IDEs), database systems (to maintain queries), spreadsheets (to recompute values on edits) and web applications (for UIs). Salsa guides and simplifies writing such applications and ensures correctness by construction. We use Salsa at RelationalAI as the core of our highly responsive compiler and database product.


Incremental computation reframes the way we build responsive systems such as databases, compilers, ML applications, spreadsheets, and web apps. Performing the minimal amount of computation needed to update a result means avoiding re-running a full computation, boosting performance.

Modern compilers are one such challenging responsive system. Programmers expect tools (Atom, VSCode) to understand their programs while typing, and to provide syntax highlighting, cross-linking, error indicators, auto-completion and documentation. IDEs essentially need a full-blown compiler front-end. To facilitate this, modern compilers are no longer designed as batch compilers consisting of distinct passes, but rather with on-demand usage as a primary use case (eg by allowing cheaply type-checking a function while accepting errors).

To meet this challenge, state-of-the-art compilers employ generic frameworks for incremental computing. Rust uses the salsa framework (see this PLISS 2019 recording for an in-depth discussion).

In this talk, we introduce Salsa.jl, which is inspired by Rust's salsa. Salsa.jl (like incremental computing frameworks in general) takes away the guesswork in building efficient incremental systems through its automatic dependency tracking and cache invalidation via versioning. Salsa.jl also introduces novel incremental computation features such as maintaining computations, recursion, and improved dependency analysis. For example, thanks to Julia, Salsa is extensible and supports using existing automatic differentiation tools to maintain computations.

We use Salsa in production to build a declarative programming language and database system with fast incremental evaluation and immediate feedback. As a novel use-case, we show how Salsa makes it easy to implement a multi-stage language where compilation and evaluation are interleaved.

We show how to use Salsa to build a small on-demand compiler and an incremental spreadsheet that is correct by construction.

Salsa takes advantage of Julia's meta-programming features and design choices, such as macros, dynamic computation, multiple dispatch, excellent performance, and bias towards immutable data structures. This talk demonstrates that Julia is a remarkably pleasant and productive language for implementing compilers and for incremental computation more broadly.

Nathan Daly is a Software Engineer at RelationalAI. He was first introduced to the idea of contributing to JuliaLang as one small way to help fight climate change by making scientific computing a little bit easier: http://worrydream.com/ClimateChange