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
Code completion sometimes shows stale results #3160
Comments
Changing /// The next modification stamp for a changed file in the [resourceProvider].
int overlayModificationStamp = DateTime.now().millisecondsSinceEpoch; Presumably also using that value directly as the stamp (instead of starting from it and increasing) would also work. I'm not sure whether one is better than the other (or if there's something better still). I tried to reproduce this in a test (by creating a second server so its variable would be reset to 0) without any luck (nor could I find where the modification stamp might be being used for the declarations). |
I don't know. My understanding is that having the same modification stamp shouldn't be enough to cause a bad cache hit because I thought we were using a hash for the cache key that included more than the modification stamp and therefore ought to have been different. But that wouldn't explain why changing the starting value for the modification stamps would fix the problem. @scheglov Do you have any thoughts?
The only problem with that is a purely theoretic one and very unlikely to occur in practice. If two modification stamps are generated (either in server or by an external process) before the clock ticks over then we could theoretically end up using the same stamp for two different versions of the code. Using an monotonically increasing counter whose value is significantly different from the clock time should eliminate even the remote possibility of these occurring. Out of curiosity, what happens if we start with a small but non-zero stamp value, such as |
Yes, I think we have a bug in available declarations. For performance reasons I attempted to use Starting |
Is there value in doing this (such as If I understand correctly, starting from milliseconds would require the user to modify more than one-file-per-millisecond on average in order to "overlap" the numbers with those used in a future session (or have multiple concurrent sessions with the same files being edited), so it would probably reduce the chance of it occurring to something very small. |
Correct. in production code the probability, while non-zero, is very low. The place it's more likely to be seen is in tests, but they's have to be tests that restarted server, and as far as I'm aware we don't have any tests like that other than the benchmark tests (and those don't modify files). I'm convinced. I think the product will be more stable if we make that change. |
I agree, doing this will make things better, and make the probability of issues very low. |
…econdsSinceEpoch Fixes Dart-Code/Dart-Code#3160. Change-Id: If57d37796dc36c06ec4bbd986719cecbbc1a98a9 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/187462 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Fixed by dart-lang/sdk@85aecd5, thanks! |
Here, notice
name5
that is defined in the file on the right is missing from the completion list:I can reproduce this by:
myfoo.dart
name6
)My theory is that this is related to using simple increasing integers as modified stamps (see here). When you open the file for the first time, the modification stamp is
0
or1
(depending on the order of opened files), and this is embedded in cached data. When you reopen the project, even after the file was modified, the new instance of the server again starts from0
and decides the cached data is still valid.@bwilkerson @scheglov does this sound plausible? I can repro both on LSP and the original protocol.
The text was updated successfully, but these errors were encountered: