Skip to content

Make File contents lazy#1271

Open
lionel- wants to merge 1 commit into
oak/salsa-28-rtask-unwindfrom
oak/salsa-29-optional-contents
Open

Make File contents lazy#1271
lionel- wants to merge 1 commit into
oak/salsa-28-rtask-unwindfrom
oak/salsa-29-optional-contents

Conversation

@lionel-

@lionel- lionel- commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Branched from #1269
Progress towards #1212

This PR implements ty's lazy model for storing sources. This should help keep memory under control, especially when we integrate library packages with the oak_sources cache.

  • File no longer stores the source string as a Salsa input, instead it includes a revision field, an optional override for when you do want to store a source (e.g. virtual files and open editors), and a lazy source_text() tracked query that reads from disk if needed. Failures return empty sources with an error logged, so the model degrades to empty contents. The query stores at most 128 sources in the Salsa cache, following our storage retention for parse trees.

  • oak_scan reads the file's mtime instead of the contents and store that as revision. The watcher's Changed/Created events bump the revision.

This makes the Salsa model a bit impure. If we miss a FS event, or it's lagging a bit, and re-read from disk at that point, we'll get invalid contents. It becomes possible for different queries to be inconsistent. Should be self-healing as long as we do get the events eventually. Since ty does this, I'm not too worried about this approach. The alternative is that we'll have to store all the sources of the entire dependency tree, which is likely a bit much especially if there are many Ark sessions live in the workspace (e.g. multiple notebooks, shiny apps, etc).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant