-
Notifications
You must be signed in to change notification settings - Fork 635
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
Improve UI responsiveness when doing node search #15773
Conversation
dirReader = writer != null ? writer.GetReader(applyAllDeletes: true) : DirectoryReader.Open(indexDir); | ||
Searcher = new(dirReader); | ||
} | ||
|
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.
@RobertGlobant20
I opted to initialize the Searcher (and dirReader) after every index modification that I could find.
Do you think I got them all ?
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, I think all of them were covered.
UI Smoke TestsTest: success. 11 passed, 0 failed. |
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 with one comment
@@ -627,6 +641,7 @@ internal void AddNodeTypeToSearchIndex(NodeSearchElement node, Document doc) | |||
SetDocumentFieldValue(doc, nameof(LuceneConfig.NodeFieldsEnum.Parameters), node.Parameters ?? string.Empty); | |||
|
|||
writer?.AddDocument(doc); | |||
InitializeIndexSearcher(); |
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.
Not sure if this specific call is needed due that usually after a node info is indexed (or all the nodes info were indexed ) we call CommitWriterChanges() - and this call is already calling the InitializeIndexSearcher() method.
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.
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.
We should have a perf test for this
dirReader = writer != null ? writer.GetReader(applyAllDeletes: true) : DirectoryReader.Open(indexDir); | ||
Searcher = new(dirReader); | ||
} | ||
|
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, I think all of them were covered.
Coudl you add a GIF showing the behavior of InCanvas Search and Library Search? |
{ | ||
dirReader = writer != null ? writer.GetReader(applyAllDeletes: true) : DirectoryReader.Open(indexDir); | ||
Searcher = new(dirReader); | ||
} |
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.
not sure if I should lock this, expecting concurrent access to Searcher
All the indexing changes will probably not happen while a user is actively searching ...
{ | ||
|
||
ctk.ThrowIfCancellationRequested(); |
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.
where do all these get caught?
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.
These get caught by the Task object that wraps the parent caller
Task.Run(() =>
{
return Search(query, searchCancelToken.Token);
}
this seems like a pretty good change, not too hard to reason about. Do you know if Lucene is itself spinning up new threads or using the thread pool, or touts itself as thread safe, or at least not requiring the main thread? Also, it just makes me think there's probably something interesting we can do with anticipating searches and performing them in parallel using autocomplete info in the future. |
{ | ||
var result = Entries.Where(e => { | ||
if (e.Name.Replace(" ", string.Empty).Equals(nodeName) && e.FullCategoryName.Equals(nodeCategory)) | ||
{ | ||
ctk.ThrowIfCancellationRequested(); |
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.
Where is this caught? Why can't the throw
be at the start of the FindModel
function?
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 wanted to short circuit the Where operation as well.
I will actually move it above the if, just to make the operation finish faster in case the if condition is not met
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 will put on at the beginning too
Thread safety
|
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.
Please check the InitializeIndexSearcher
call
@@ -627,6 +641,7 @@ internal void AddNodeTypeToSearchIndex(NodeSearchElement node, Document doc) | |||
SetDocumentFieldValue(doc, nameof(LuceneConfig.NodeFieldsEnum.Parameters), node.Parameters ?? string.Empty); | |||
|
|||
writer?.AddDocument(doc); | |||
InitializeIndexSearcher(); |
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.
Yeah, I am going to revert that part of the changes. It seems the indexing is affected even when doing searches (or weights of results, or something similar) |
Wrote up a quick fix #15797 . Normally i'd send it to the PR author's repo but this is in DynamoDS's so sent it another PR. |
Looks great. I'll check if it makes all the tests pass
THanks, that fixed the leftover failures |
Happy to hear that, should we include the ticket number into this PR? DYN-8045. Closed the other PR #15733 .
|
Performance tests passed https://master-5.jenkins.autodesk.com/job/Dynamo/job/DynamoPerformance-CI/job/master/2236/ |
* Bring back search performance improvement (DynamoDS#15789) * Stabilize tests pt2 (DynamoDS#15779) * DYN-7268 Improve UX when IDSDK is not installed on system running Dynamo (DynamoDS#15790) * Improve UI responsiveness when doing node search (DynamoDS#15773) Co-authored-by: chubakueno <[email protected]> --------- Co-authored-by: pinzart90 <[email protected]> Co-authored-by: Ashish Aggarwal <[email protected]> Co-authored-by: chubakueno <[email protected]>
Purpose
Run the canvas search in a separate thread to improve UI responsiveness.
This PR was created as an alternative to #15733
Summary of changes:
Moved the Lucene IndexSearcher initialization. Previously it was recreated on every search. Now it is created only after the index is modified.
Run in canvas search in a separate thread (thread pool)
Introduced a cancellation token throughout the search operations
New searches will cancel old ones and only update the UI if the search was successful(not cancelled)
These changes will be under a new feature flag
Left to do:
Add tests
Add to library view search and others (pm search, autocomplete )?
Declarations
Check these if you believe they are true
*.resx
filesRelease Notes
(FILL ME IN) Brief description of the fix / enhancement. Use N/A to indicate that the changes in this pull request do not apply to Release Notes. Mandatory section
Reviewers
(FILL ME IN) Reviewer 1 (If possible, assign the Reviewer for the PR)
(FILL ME IN, optional) Any additional notes to reviewers or testers.
FYIs
(FILL ME IN, Optional) Names of anyone else you wish to be notified of