Skip to content
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

Fix accumulated values for backdated queries #662

Merged
merged 2 commits into from
Jan 25, 2025

Conversation

Veykril
Copy link
Member

@Veykril Veykril commented Jan 24, 2025

Rebased version of #641

Copy link

netlify bot commented Jan 24, 2025

Deploy Preview for salsa-rs canceled.

Name Link
🔨 Latest commit 467983d
🔍 Latest deploy log https://app.netlify.com/sites/salsa-rs/deploys/6793ad15ad11860007df0232

Copy link

codspeed-hq bot commented Jan 24, 2025

CodSpeed Performance Report

Merging #662 will not alter performance

Comparing Veykril:veykril/push-wluqnwrsrsow (467983d) with master (cde9fbd)

Summary

✅ 9 untouched benchmarks

@@ -182,13 +202,19 @@ where
// valid, then some later input I1 might never have executed at all, so verifying
// it is still up to date is meaningless.
let last_verified_at = old_memo.verified_at.load();
let mut inputs = old_memo.revisions.accumulated_inputs.load();
Copy link
Member Author

Choose a reason for hiding this comment

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

This had to change from defaulting to Empty to the memo's value due to #636 as that changed the flag to track self and dependencies, instead of just dependencies. Notably this has a bigger implication though, it means a memo can never lose its Any accumulator status via verification, so if we the memo had a dependency that accumulated (which now no longer does) while not having accumulated itself we will still keep the flag as the memo having accumulated. (If am not making a mistake) I am not sure how bad this is, I feel like it shouldn't matter too much? It makes the optimization a bit less useful though I think this is a rather uncommon case to hit? @MichaReiser

Copy link
Contributor

@MichaReiser MichaReiser Jan 24, 2025

Choose a reason for hiding this comment

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

It makes the optimization less useful in an LSP case where it is very common to have many files that had some diagnostics at some point. For example, if you make edits to 20 files, each of those will have diagnostics (syntax) associated with it while making those edits, but they'll ultimately converge. I rarely close my editor. That means that these "stale" accumulated states keep adding up.

Why was it again that #636 had to change the tracking to track both self and its dependencies?

Copy link
Member Author

Choose a reason for hiding this comment

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

It makes the optimization less useful in an LSP case where it is very common to have many files that had some diagnostics at some point. For example, if you make edits to 20 files, each of those will have diagnostics (syntax) associated with it while making those edits, but they'll ultimately converge. I rarely close my editor. That means that these "stale" accumulated states keep adding up.

I would expect in the general case that if accumulations changed, that the general output of a given tracked function also changed though which will then reset the flag anyways. Your test here shows the case where that does not happen, but for that the accumulation producing run and the non accumulation producing run would need to produce the same memoized value to trigger this specific case here which does not sound like something that will happen too often imo.

Why was it again that #636 had to change the tracking to track both self and its dependencies?

Not sure, will have to dig into that whether that was accidentally or required.

Copy link
Contributor

@MichaReiser MichaReiser Jan 24, 2025

Choose a reason for hiding this comment

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

Good point. Although this can happen frequently with nested queries where the outer queries still produce the same result and it's only the inner queries that changed. E.g. some function local types changed, but the function return type remains unchanged.

It would be nice if it can be avoided but is also not critical. Adding a comment on why it doesn't use ::default might be useful (with a possible TOOD)

Copy link
Member Author

Choose a reason for hiding this comment

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

Restored the tracking behavior, it was accidental.

@Veykril Veykril force-pushed the veykril/push-wluqnwrsrsow branch from 51e64d7 to 496e076 Compare January 24, 2025 10:02
Copy link
Contributor

@MichaReiser MichaReiser left a comment

Choose a reason for hiding this comment

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

Nice and thanks for rebasing

@Veykril Veykril added this pull request to the merge queue Jan 25, 2025
Merged via the queue into salsa-rs:master with commit d32b3c1 Jan 25, 2025
10 checks passed
@Veykril Veykril deleted the veykril/push-wluqnwrsrsow branch January 28, 2025 06:54
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.

2 participants