Skip to content

Conversation

@Wilfred
Copy link
Contributor

@Wilfred Wilfred commented Jan 9, 2026

This was added in #801 but wasn't previously documented.

@netlify
Copy link

netlify bot commented Jan 9, 2026

Deploy Preview for salsa-rs ready!

Name Link
🔨 Latest commit 990f23d
🔍 Latest deploy log https://app.netlify.com/projects/salsa-rs/deploys/6969098d0fc56a0008f625ef
😎 Deploy Preview https://deploy-preview-1056--salsa-rs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@codspeed-hq
Copy link

codspeed-hq bot commented Jan 9, 2026

CodSpeed Performance Report

Merging this PR will not alter performance

Comparing Wilfred:document_cycle_fallback (990f23d) with master (b6398ec)

Summary

✅ 13 untouched benchmarks


## Fallback Values

You can use `cycle_result` to specify a fallback value if Salsa detects a cycle. Salsa will ignore all the other queries and use this value directly.
Copy link
Contributor

@MichaReiser MichaReiser Jan 9, 2026

Choose a reason for hiding this comment

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

To me it's not entirely clear what ignore all other queries means in this context. Are you trying to say that salsa discards the in-progress query result and instead returns fallback.

I think it might also be worth mentioning here that this can result in non-determinism because Salsa never enforces that all queries converge. But I don't fully remember the details here. But I think there was some discussion around it on the PR that introduced the feature

Copy link
Contributor Author

@Wilfred Wilfred Jan 9, 2026

Choose a reason for hiding this comment

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

@MichaReiser "ignore all other queries" is how it's described in #801 FWIW, and per #801 (comment) I think the final version of the PR is deterministic.

Are you trying to say that salsa discards the in-progress query result and instead returns fallback.

I think so? That's my understanding from a skim of the PR, but happy to tweak wording if you prefer something else :)

Copy link
Contributor

@MichaReiser MichaReiser Jan 9, 2026

Choose a reason for hiding this comment

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

I think the confusing part is the ignore all other queries. This makes it sound as if it throws away the result of any query called as part of the cyclic function. However, this is not the case. The only result that it throws away is the result of the cycle head (the query with the cycle_fallback), and instead, replaces the value with the fallback value.

Maybe an easier way to describe this is that a query with an cycle_result attribute always runs to completion, but its resulting value will be replaced with fallback value if it hits a cycle (instead of whatever value it ended up computing).

The non-determinism is described in this comment #798 (comment) (I think it's fine linking to that comment but it's worth pointing out that this is a limitation of this approach over proper fixpoint)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@MichaReiser just to confirm, that's a different PR -- #798 vs #801 -- does #801 also have non-determinism?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, they both have the same non-determinism

This was added in salsa-rs#801 but wasn't previously documented.
@Wilfred Wilfred force-pushed the document_cycle_fallback branch from ff28ff3 to 2fdfb3e Compare January 14, 2026 18:45
@Wilfred
Copy link
Contributor Author

Wilfred commented Jan 14, 2026

OK, expanded and clarified following the comments here.

}
```

Unlike fixpoint iteration, queries attributed with `cycle_fallback` also use their fallback value if
Copy link
Contributor

Choose a reason for hiding this comment

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

I learned more about cycle_fallback and am now convinced that it doesn't have any non-deterministic behavior. I updated the section here

@MichaReiser MichaReiser enabled auto-merge January 15, 2026 15:37
@MichaReiser MichaReiser added this pull request to the merge queue Jan 15, 2026
Merged via the queue into salsa-rs:master with commit c49e550 Jan 15, 2026
14 checks passed
@github-actions github-actions bot mentioned this pull request Jan 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants