Skip to content

Conversation

@MichaReiser
Copy link
Contributor

@MichaReiser MichaReiser commented Oct 29, 2025

This fixes a bug in our fixpoint handling: the dependencies introduced by the cycle recovery function were recorded as dependencies of the outer function rather than the query with cycle handling.

This PR also requires that a cycle recovery function not introduce any new cycles, since it's unclear how to handle that.

I have the impression that we should probably to the same for cycle_initial but this is a bit trickier because we'd have to merge the input/outputs in execute_maybe_iterate. I also think it matters less because the dependencies are added to some query within the cycle and we always need to execute the cycle as a whole if any input it depends on changed. That's why I think it's probably fine if the dependencies are tracked by another cycle participant.

Test plan

I added a regression test, yay :)

Except... it revealed a bug with deep verify memo where we failed to remove the head when we early-returned. Luckily, this was easy to fix.

@netlify
Copy link

netlify bot commented Oct 29, 2025

Deploy Preview for salsa-rs canceled.

Name Link
🔨 Latest commit 686b929
🔍 Latest deploy log https://app.netlify.com/projects/salsa-rs/deploys/69055b9cc85e8400087954cc

@codspeed-hq
Copy link

codspeed-hq bot commented Oct 29, 2025

CodSpeed Performance Report

Merging #1018 will not alter performance

Comparing MichaReiser:cycle-fn-dependencies (686b929) with master (c762869)

Summary

✅ 13 untouched

@MichaReiser MichaReiser force-pushed the cycle-fn-dependencies branch 3 times, most recently from 1339754 to 0354267 Compare October 29, 2025 16:47
@MichaReiser MichaReiser requested review from carljm and ibraheemdev and removed request for carljm October 29, 2025 20:39
@MichaReiser MichaReiser marked this pull request as ready for review October 29, 2025 20:42
@MichaReiser MichaReiser requested a review from carljm October 29, 2025 20:44
"WillCheckCancellation",
"WillIterateCycle { database_key: query(Id(0)), iteration_count: IterationCount(5) }",
"WillCheckCancellation",
"DidValidateMemoizedValue { database_key: entry(Id(0)) }",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Before the fix, this incorrectly re-executed entry but not the cycle (which is what depends on the value).

With the fix in execute_maybe_iterate, it did re-execute the cycle, but it also re-executed entry, which is incorrect because query returns the same value (it can be backdated). Now, the behavior is what we want. entry does not get re-executed but the cycle is

@MichaReiser
Copy link
Contributor Author

@carljm or @ibraheemdev could either of you take a look at this PR. We need this change to correctly handle diverging queries.

@MichaReiser MichaReiser force-pushed the cycle-fn-dependencies branch from 470ee4c to 45158fc Compare November 1, 2025 00:55
@MichaReiser MichaReiser changed the title Track cycle function dependenciees as part of the cyclic query Track cycle function dependencies as part of the cyclic query Nov 1, 2025
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