-
Notifications
You must be signed in to change notification settings - Fork 172
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 reindex documents if declarations are being modified #2942
base: 11-29-index_documents_on_modification
Are you sure you want to change the base?
Only reindex documents if declarations are being modified #2942
Conversation
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
@@ -64,7 +64,6 @@ def initialize(index, dispatcher, parse_result, uri, collect_comments: false) | |||
:on_constant_path_or_write_node_enter, | |||
:on_constant_path_operator_write_node_enter, | |||
:on_constant_path_and_write_node_enter, | |||
:on_constant_or_write_node_enter, |
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.
This event was duplicated.
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.
Should we change Prism detect this and emit an error/warning?
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.
I'd rather make our cop smarter if we can avoid paying the price on every single listener instantiation.
41cc250
to
826bd1a
Compare
c103d7c
to
ea92bc7
Compare
@@ -64,7 +64,6 @@ def initialize(index, dispatcher, parse_result, uri, collect_comments: false) | |||
:on_constant_path_or_write_node_enter, | |||
:on_constant_path_operator_write_node_enter, | |||
:on_constant_path_and_write_node_enter, | |||
:on_constant_or_write_node_enter, |
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.
Should we change Prism detect this and emit an error/warning?
826bd1a
to
2251c9d
Compare
2251c9d
to
e5b8c20
Compare
ea92bc7
to
f299a65
Compare
Motivation
This PR tries to limit the amount of times we pay the price of reindexing the current document being modified by analyzing the context behind the last edit made to it.
Implementation
The idea of this approach is to remember the position of the last edit made to a document and the nature of the edit (insert, replace or delete).
Then, depending on the type of edit and what nodes exist under the position where the edit was made, we decide if reindexing is relevant or not.
To determine that, we look at the node under the cursor and, if it matches a node we use for indexing in the
DeclarationListener
, then we consider that we need to reindex.It's not perfect, so let me know if you have other ideas on how to determine this in a way that is:
Necessarily in this order because the whole point is to reduce the performance impact of having to reindex. If detecting whether we need to do it or not is equally as slow, then there's no point in doing it.
Automated Tests
Added some tests, but we should probably add more.