-
Notifications
You must be signed in to change notification settings - Fork 197
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
Implement cached label resolution and label resolution limit #26
Merged
andfoy
merged 5 commits into
python-lsp:develop
from
krassowski:improve-jedi-completion-performance
Jul 13, 2021
Merged
Implement cached label resolution and label resolution limit #26
andfoy
merged 5 commits into
python-lsp:develop
from
krassowski:improve-jedi-completion-performance
Jul 13, 2021
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 task
@krassowski, thanks a lot for your help in improving the completion response time, do you know what is missing in this PR? |
I will rebase and add settings to schema. |
krassowski
force-pushed
the
improve-jedi-completion-performance
branch
from
July 13, 2021 18:03
6dd31cc
to
e00fcf9
Compare
krassowski
force-pushed
the
improve-jedi-completion-performance
branch
from
July 13, 2021 18:07
e00fcf9
to
647bf4e
Compare
Ok, that should be ready now. |
andfoy
reviewed
Jul 13, 2021
andfoy
approved these changes
Jul 13, 2021
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.
LGTM!
Thanks for the merge! I will be back with more improvements next week. |
krassowski
added a commit
that referenced
this pull request
Jul 14, 2021
This is a key change that should have been included in #26 but was left out by omission when porting the changes from my fork.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Implement labels cache for Jedi. When snippets are disabled the single most time-consuming thing for Jedi is
completion.get_signatures()
call which is used by to create a label of theCompletionItem
. See profiling in palantir/python-language-server#823 (comment)It is a known issue and is unlikely to be fixed upstream in Jedi (any time soon): davidhalter/jedi#1059 (comment).
The Jedi author recommended to:
get_signatures()
on ~ 10 completions. I set the default to 25; it can be changed usingresolve_at_most_labels
setting'pandas', 'numpy', 'tensorflow', 'matplotlib'
but we can expand this or add a setting to allow the user to customize it.This change, together with #25 was tested on my fork for over a month and found stable and providing a noticeable performance improvement as testified by users.
The improvement will not be seen if the snippets are used; we would need to cache snippets in the same way (basically avoid any call to
get_signatures()
. Please note that the "obvious" way of computingget_signatures()
asynchronously or caching the result is sadly not possible because those hold references to pickle files which get deleted in the meantime and everything would lead to bad crashes (we would need to acquire jedi lock but this proved to be very fragile in my experiments). Obviously, the string result of processingget_signatures()
can be cached (as happens with labels here).