-
Notifications
You must be signed in to change notification settings - Fork 203
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
Only reload cache once for rope_autoimport
#463
Closed
tkrabel-db
wants to merge
2
commits into
python-lsp:develop
from
tkrabel-db:rope-config-change-enhancements
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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.
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.
In a situation when it's disabled and then re-enabled again later we should reload the cache. So we should change
ENABLED
tofalse
in theelse
case.BTW. I wasn't aware before that
_reload_cache
is called quite often (on file open and save). Knowing that, I suppose this is not really that much of a performance issue really... Sorry for not checking it properly beforeThere 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.
Well, I checked it myself and this indeed can be a performance issue. On a larger python venv with all the latest data science packages like pandas, sklearn and the sort, we have ~130 python packages in that venv, which takes 30sec for rope to scan if
memory = True
. That said, I see future work to make _reload_cache async, so that the language server is unblocked and can handle other requests while loading the cache.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.
Hm, thinking about this more, I start doubting the value of this PR.
workspace/didChangeConfiguration
is something I expect a user to set once during the session, not so often that it's worth adding a state machine to rope_autoimport now. And the inefficiencies won't be an issue anyway when rope is disabled. Also, when rope creates an index DB, reloading the cache is fast (~1 sec on 130 dependencies).On the other hand, the state machine added would get fairly complicated, making it harder to reason about the logic, and as code is more often read than written, I'm hesitant to add it just now. Let's wait for user feedback first.
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.
That said, I open a separate PR to fix the obvious bug in the code.
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.
It would be buggy without it. The user would disable cache and on enabling it later the cache would be stale.
Maybe a corner case but it would still result in incorrect behavior so I think we shouldn't ignore it.
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.
Oh, sorry, you meant it's an option to drop this whole PR rather than not addressing my comment. Yeah, that's probably fine too given how often the cache is reloaded anyway.
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.
Actuallly, this can happen several times in a single session (at least in Spyder) because users can enable/disable pycodestyle, pydocstyle or change their preferred auto-formatter provider in Spyder Preferences. And all that involves a
didChangeConfiguration
.Ok, so do you prefer to close this 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.
Yes, let's close this