allow reuse of cached provisional memos within the same cycle iteration during maybe_changed_after#954
Conversation
✅ Deploy Preview for salsa-rs canceled.
|
| .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.
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.
Nice, it reproduces on CI (but why only on CI?)
There was a problem hiding this comment.
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.
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_aftermaybe_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
Co-authored-by: Carl Meyer <carl@astral.sh>
|
I believe there are a few more bugs in
|
This is the same as #786 but during
maybe_changed_after.validate_same_iterationover pessimistically always returnsfalseif a cycle head is currently being checked withmaybe_changed_afterbecausemaybe_changed_afternever 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.