-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. This is removing a redundant verification ( |
||
]"#]]); | ||
|
||
a.assert_value(&db, 45); | ||
|
@@ -929,9 +928,7 @@ fn cycle_unchanged_nested() { | |
"salsa_event(DidValidateMemoizedValue { database_key: min_iterate(Id(1)) })", | ||
"salsa_event(DidValidateMemoizedValue { database_key: min_iterate(Id(3)) })", | ||
"salsa_event(DidValidateMemoizedValue { database_key: min_panic(Id(4)) })", | ||
"salsa_event(DidValidateMemoizedValue { database_key: min_iterate(Id(3)) })", | ||
"salsa_event(DidValidateMemoizedValue { database_key: min_panic(Id(2)) })", | ||
"salsa_event(DidValidateMemoizedValue { database_key: min_iterate(Id(1)) })", | ||
]"#]]); | ||
|
||
a.assert_value(&db, 45); | ||
|
@@ -992,14 +989,12 @@ fn cycle_unchanged_nested_intertwined() { | |
b.assert_value(&db, 60); | ||
|
||
db.assert_logs(expect![[r#" | ||
[ | ||
"salsa_event(DidValidateMemoizedValue { database_key: min_iterate(Id(1)) })", | ||
"salsa_event(DidValidateMemoizedValue { database_key: min_iterate(Id(3)) })", | ||
"salsa_event(DidValidateMemoizedValue { database_key: min_iterate(Id(4)) })", | ||
"salsa_event(DidValidateMemoizedValue { database_key: min_iterate(Id(3)) })", | ||
"salsa_event(DidValidateMemoizedValue { database_key: min_panic(Id(2)) })", | ||
"salsa_event(DidValidateMemoizedValue { database_key: min_iterate(Id(1)) })", | ||
]"#]]); | ||
[ | ||
"salsa_event(DidValidateMemoizedValue { database_key: min_iterate(Id(1)) })", | ||
"salsa_event(DidValidateMemoizedValue { database_key: min_iterate(Id(3)) })", | ||
"salsa_event(DidValidateMemoizedValue { database_key: min_iterate(Id(4)) })", | ||
"salsa_event(DidValidateMemoizedValue { database_key: min_panic(Id(2)) })", | ||
]"#]]); | ||
|
||
a.assert_value(&db, 45); | ||
} | ||
|
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 duplicateDidValidateMemoizedValue
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)