-
Notifications
You must be signed in to change notification settings - Fork 185
allow reuse of cached provisional memos within the same cycle iteration during maybe_changed_after
#954
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
allow reuse of cached provisional memos within the same cycle iteration during maybe_changed_after
#954
Conversation
✅ Deploy Preview for salsa-rs canceled.
|
@@ -377,7 +377,7 @@ where | |||
let wait_result = ingredient | |||
.wait_for(zalsa, cycle_head.database_key_index.key_index()); | |||
|
|||
if !wait_result.is_cycle_with_other_thread() { | |||
if !wait_result.is_cycle() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trying to remember why I explicitly added is_cycle_with_other__thread
in 30f6eb4
(#882)
It suggests that it is to fix a panic but there's no failing test :( Maybe it only failed on CI?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, it reproduces on CI (but why only on CI?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I initially restricted the logic here to only apply when this leads to a cross-thread cycle because the cycle_panic
test started to hang on Github actions.
Restricting this logic to multi-threaded cycle does fix the test-hang but it's over restrictive. The alternative fix that I added now (the if below the huge comment) accomplishes the same without making any assumptions about on how many threads the cycle runs.
An alternative fix is to change maybe_changed_after
to push the current query in deep_verify_memo
. While I think that this would have the nice added benefit that our query stack traces are more accurate (they also show queries running `maybe_changed_after), it does have the significant downside that pushing a new query isn't free and we would have to pay that cost for all queries, not just queries participating in cycles.
That's why I opted for this fix instead.
CodSpeed Performance ReportMerging #954 will degrade performances by 4.91%Comparing Summary
Benchmarks breakdown
|
db.assert_logs(expect![[r#" | ||
[ | ||
"salsa_event(WillExecute { database_key: min_panic(Id(2)) })", | ||
"salsa_event(WillExecute { database_key: min_panic(Id(1)) })", | ||
"salsa_event(WillExecute { database_key: min_iterate(Id(0)) })", | ||
"salsa_event(WillIterateCycle { database_key: min_iterate(Id(0)), iteration_count: IterationCount(1), fell_back: false })", | ||
"salsa_event(WillExecute { database_key: min_panic(Id(1)) })", | ||
"salsa_event(WillExecute { database_key: min_panic(Id(2)) })", | ||
]"#]]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The output before the fix:
"salsa_event(WillExecute { database_key: min_panic(Id(1)) })",
"salsa_event(WillExecute { database_key: min_panic(Id(2)) })",
"salsa_event(WillExecute { database_key: min_panic(Id(2)) })", <- unnecesary
"salsa_event(WillExecute { database_key: min_panic(Id(2)) })", <- unnecesary
"salsa_event(WillExecute { database_key: min_iterate(Id(0)) })",
"salsa_event(WillIterateCycle { database_key: min_iterate(Id(0)), iteration_count: IterationCount(1), fell_back: false })",
"salsa_event(WillExecute { database_key: min_panic(Id(1)) })",
"salsa_event(WillExecute { database_key: min_panic(Id(2)) })",
validate_same_iteration
slow path for maybe_changed_after
maybe_changed_after
No idea what's up with codspeed. This code doesn't exercise any fixpoint iteration logic |
f9225e6
to
67efabe
Compare
67efabe
to
c2f4827
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thank you!
Co-authored-by: Carl Meyer <[email protected]>
I believe there are a few more bugs in
|
This is the same as #786 but during
maybe_changed_after
.validate_same_iteration
over pessimistically always returnsfalse
if a cycle head is currently being checked withmaybe_changed_after
becausemaybe_changed_after
never pushes the current query on the stack.This PR addresses the issue by comparing the cycle head's iteration with the latest memo iteration for that cycle head. This is the same as we already did for a cycle that spans multiple threads.