-
Notifications
You must be signed in to change notification settings - Fork 181
Do not re-verify already verified memoized value in cycle verification #851
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
Conversation
✅ Deploy Preview for salsa-rs canceled.
|
CodSpeed Performance ReportMerging #851 will not alter performanceComparing Summary
|
|
if heads_non_empty { | ||
// case 2 / 4 | ||
break 'cycle VerifyResult::Unchanged(inputs); | ||
} else if !first_iteration { |
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.
Is the elif !first_iteration
a semantic change?
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.
Yes, this is what causes the test changes you annotated as well below. I made that commit separately precisely to discuss (forgot to make a self review to start that discussion sorry). The change was made given the comment above declaring the 4 cases. Judging by case 3's description (the only one that actually continue
s the loop, we want to iterate it once more but we always re-add ourselves as the cylce head on this second iteration, meaning we will re-validate us once more (that is the cause for the duplicate DidValidateMemoizedValue
events) in the second iteration and then continue again for a third time before finally bailing out.
Given the wording of the comment I interpreted this as that we want to merely run this a second time but no more. This is probably something that @carljm should have a look at.
I can split this PR into its two commits if the first one looks good as is.
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.
This is a pretty big speed up on our benchmarks https://codspeed.io/astral-sh/ruff/branches/micha%2Ffixpoint-changes
It would be nice if the code reflected the 1...4 ordering a little more. Especially if 1.
could be first but this is a nit (which should also be the most likely branch taken at runtime)
@@ -882,7 +882,6 @@ fn cycle_unchanged() { | |||
[ | |||
"salsa_event(DidValidateMemoizedValue { database_key: min_iterate(Id(1)) })", | |||
"salsa_event(DidValidateMemoizedValue { database_key: min_panic(Id(2)) })", | |||
"salsa_event(DidValidateMemoizedValue { database_key: min_iterate(Id(1)) })", |
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.
Can you explain why we see behavior changes here?
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.
This is removing a redundant verification (min_iterate(1)
was already verified above), which is the point of the change as I understand it
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 like the &mut CycleHead
refactor. I think it helps clarify some things
735cd15
to
aa0ef5a
Compare
aa0ef5a
to
bb8dc08
Compare
Split out the first commit into #852 to leave the question of interest here |
bb8dc08
to
ef93d38
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.
This looks correct to and I verified that this doesn't introduce any new hangs but I'd prefer if Carl could take a look at this as well
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.
Very nice! This looks great to me.
@@ -882,7 +882,6 @@ fn cycle_unchanged() { | |||
[ | |||
"salsa_event(DidValidateMemoizedValue { database_key: min_iterate(Id(1)) })", | |||
"salsa_event(DidValidateMemoizedValue { database_key: min_panic(Id(2)) })", | |||
"salsa_event(DidValidateMemoizedValue { database_key: min_iterate(Id(1)) })", |
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.
This is removing a redundant verification (min_iterate(1)
was already verified above), which is the point of the change as I understand it
Unrelated to your PR but one thing I and carl discussed is that we should verify that its guarantee that we exit the loop after N iterations and don't loop forever (hang). |
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.
Did this fix the r-a hang?
No it did not |
Stacked on top of #852