-
Notifications
You must be signed in to change notification settings - Fork 401
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
Cache and re-use type bindings for a completion invocation #2535
Conversation
The improvement here is huge. Goes from ~28s to ~2s on my machine, for completion response. Just 2 main questions for now :
|
Lazy resolving is a powerful tool to solve the problem. Just one thing I would like to mention: For now, updating the text edit during resolving is still not recommended in the spec, if we decide to go that way, we are on our own for the correctness. Personally, I think it's worth trying - considering the huge amount of boost we can get (~28s to ~2s). I believe the time cost can be even faster if we use the approach to other cases. But in case that one day the behavior of VS Code changes, which might break our completion functions. I would suggest that we introduce a switch of the completion behavior. The switch controls whether we will lazily resolve the completions. In that way, at least we have a fall back if the regression happens in the future. |
I have same question as @rgrunber has for the code action part. Are all the cancellation checks necessary? How does the perf looks like if we only keep the change for the completion resolving part? What about separating the change of adding cancellation checks for code actions to another PR? Because they are trying to solve the perf issue from different aspects. |
I will check this patch, but it isn't related to this patch.
I will separate them. |
@rgrunber @jdneo @CsCherrYY I have updated the PR. It includes only |
A related issue - #2453 |
#2453 (comment) implies we should be ok to lazily resolve. Either way, if we're doing it in other places, we should be fine to at least do it here also. Update: Jinbo's patch was about caching the type argument info for a constructor completion proposal. This patch completely avoid computing that until the resolve phase. That's why I thought maybe when we get that patch approved, it could provide some performance improvement without having to resolve lazily. |
9ad00f3
to
4e8ad3a
Compare
@rgrunber Well, my comment in that issue was not correct. (After I thought about it twice)😥 My understanding of the Dirk's response is that:
Which means we are violating the spec if we update the AFAIK, besides this PR and #2453, the generic server side snippet is also lazy resolved. Luckily, they are working fine in most cases. But there is no guarantee they will still work in the future. That's why I suggest having a setting to control the resolve behavior. With that setting exist, I'm feeling safe to leverage lazy resolve approach to more cases. |
@jdneo @rgrunber We should add |
@snjeza , so could we modify this change to check the resolve support capability contains the textEdit property ? Then clients can enable/disable. |
@rgrunber Right. See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#completionClientCapabilities
|
@snjeza your new change looks to save the same amount of time as before 🎉 . It makese sense to cache the known bindings for that particular instance of completion activation. However I'm not seeing any major benefit for publishing diagnostics. I'll try to see how much time is spent in that block of code you've removed. Looking at it, I'm not sure why we went from Update There's might be some improvement for Old: 604 638 669 699 714 748 786 823 923 961 1042 1255 5345 |
@rgrunber Could you try the following
You should test it using |
We used AST before we separated |
I'll try again with your suggestions. FWIW I did use the validation line when comparing. Either way, I'll have a closer look, and hopefully we can merge since the change should be more acceptable now. |
if (bindings.get(keys[0]) instanceof ITypeBinding) { | ||
return (ITypeBinding) bindings.get(keys[0]); | ||
} |
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.
To keep consistent as previous implementation, it can be
if (bindings.size() > 0) {
return (ITypeBinding) bindings.get(keys[0]);
}
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.
Fixed.
The publish diagnostics and typebinding cache are two different optimization, you may split them to different PRs. The typebinding cache is pretty straightforward, it's safe to merge first. |
fc6db2b
to
c0fcfe0
Compare
See #2574 |
@fbricon @rgrunber @testforstephen @jdneo @CsCherrYY I have updated the PR. |
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.
Looks good to me. Could you change the commit title to :
Cache and re-use type bindings for a completion invocation
Then feel free to merge.
Remove CoreASTProvider.getAST(...) from BaseDocumentLifeCycleHandler.publishDiagnostics(IProgressMonitor) - eclipse-jdtls#2535 Signed-off-by: Snjezana Peco <[email protected]>
test this please |
Signed-off-by: Snjezana Peco <[email protected]>
Remove CoreASTProvider.getAST(...) from BaseDocumentLifeCycleHandler.publishDiagnostics(IProgressMonitor) - eclipse-jdtls#2535 Signed-off-by: Snjezana Peco <[email protected]>
Remove CoreASTProvider.getAST(...) from BaseDocumentLifeCycleHandler.publishDiagnostics(IProgressMonitor) - #2535 Signed-off-by: Snjezana Peco <[email protected]>
A related issue - redhat-developer/vscode-java#2982
Steps to reproduce
See redhat-developer/vscode-java#2982 (comment)