Skip to content

Bump Salsa revision manually for non-Salsa updates#1315

Open
lionel- wants to merge 1 commit into
oak/analysis-dbfrom
oak/manual-revision-bump
Open

Bump Salsa revision manually for non-Salsa updates#1315
lionel- wants to merge 1 commit into
oak/analysis-dbfrom
oak/manual-revision-bump

Conversation

@lionel-

@lionel- lionel- commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Branched from #1314
Part of #1212

Removes a FIXME that I left for non-Salsa inputs, like console inputs and diagnostics config. These updates manually triggered diagnostics out-of-band, which had the issue that ongoing diagnostics did not get cancelled by a Salsa bump. The concurrent diagnostics could publish out of order, resulting in stale results.

It's actually easy to bump the revision manually, which both cancels in flight diagnostics and ensures ordering. That's because the synthetic write:

  • Causes Salsa to trigger cancellation and park the caller until all readers are dropped
  • Refreshes diagnostics automatically via the revision check at the end of the main loop.

@lionel- lionel- requested a review from DavisVaughan July 3, 2026 13:54
/// completes and the newer batch is enqueued, any older pass has either unwound
/// with `Cancelled` or already produced its result. Changes to state that lives
/// outside oak (console inputs, diagnostics config) get the same barrier by
/// advancing the revision synthetically (see `WorldState::bump_revision`).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// advancing the revision synthetically (see `WorldState::bump_revision`).
/// advancing the revision synthetically (see [`WorldState::bump_revision`]).

if you want to linkify the doc comments

Comment on lines +509 to +513
// Refresh diagnostics if the configuration changed. The config lives
// outside Oak so we bump the revision manually.
if state.config.diagnostics != diagnostics_config {
tracing::info!("Refreshing diagnostics after configuration changed");
lsp::main_loop::diagnostics_refresh_all(state);
state.bump_revision();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Refresh diagnostics if the configuration changed. The config lives
// outside Oak so we bump the revision manually.
if state.config.diagnostics != diagnostics_config {
tracing::info!("Refreshing diagnostics after configuration changed");
lsp::main_loop::diagnostics_refresh_all(state);
state.bump_revision();
// Refresh diagnostics if the configuration changed. The config lives
// outside Oak so we bump the revision manually, causing diagnostics
// to refresh on the next tick.
if state.config.diagnostics != diagnostics_config {
tracing::info!("Bumping salsa revision after configuration changed");
state.bump_revision();

idk, feels more precise to me this way?

Comment on lines +530 to +532
// to refresh from here. The scopes live outside oak so we bump the revision
// manually.
state.bump_revision();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// to refresh from here. The scopes live outside oak so we bump the revision
// manually.
state.bump_revision();
// to refresh from here. The scopes live outside oak so we bump the revision
// manually, causing diagnostics to get refreshed on the next tick.
state.bump_revision();

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.

2 participants