Search View: Performance issues on remove and sort#3733
Search View: Performance issues on remove and sort#3733mehmet-karaman wants to merge 1 commit intoeclipse-platform:masterfrom
Conversation
|
@mehmet-karaman : please first create a ticket and explain the problem. |
2a62c61 to
73cab0d
Compare
dff7693 to
300ca6b
Compare
bundles/org.eclipse.search/newsearch/org/eclipse/search/ui/text/AbstractTextSearchResult.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.search/newsearch/org/eclipse/search/ui/text/AbstractTextSearchResult.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.search/newsearch/org/eclipse/search/ui/text/AbstractTextSearchViewPage.java
Outdated
Show resolved
Hide resolved
| if (!parents.isEmpty()) { | ||
| result.removeParents(parents); | ||
| if (others.isEmpty()) { | ||
| return; |
There was a problem hiding this comment.
This doesn't update UI, at least not for me.
I see the tree in the search view, select subtree, click on delete ... nothing happens at all now.
What is missing is the code that updates UI after this operation.
There was a problem hiding this comment.
I'm using exact this steps: #3735 (comment), should be reproducible for everyone.
There was a problem hiding this comment.
I hope i understood it correct, I have tried to record what is currently on my branch:
Videoprojekt.4.mp4
As explained in the reproduction scenario.. Could it be that you didn't checked out that commit?
There was a problem hiding this comment.
Please just follow steps I've provided.
There was a problem hiding this comment.
Now I got it.. It seems that the method AbstractTextSearchResult.removeElements(List<?>) gets called with wrong 'enclosing' elements.. My solution needs to take care on deeper folder structures and gather all IFiles..
There was a problem hiding this comment.
I've added a resource visitor which collects all IFiles inside of the selected 'enclosing' element.. Could be a better way to achieve this.. Maybe I should use the ContentProvider and navigate through the search results instead?
300ca6b to
fe5e861
Compare
bundles/org.eclipse.search/newsearch/org/eclipse/search/ui/text/AbstractTextSearchResult.java
Outdated
Show resolved
Hide resolved
fe5e861 to
7f02394
Compare
There was a problem hiding this comment.
Pull request overview
This PR addresses Search View performance and correctness when removing matches, by enabling batch removal at the “enclosing element” (e.g., file/resource) level and ensuring removals aren’t limited to only currently visible (element-limited) results.
Changes:
- Updated
AbstractTextSearchViewPage.internalRemoveSelected()to batch-remove matches by selectedIFile/IContainerresources before falling back to per-match removal for non-resource selections. - Added
AbstractTextSearchResult.removeElements(...)to remove all matches for selected elements via a single map-entry removal per element.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
bundles/org.eclipse.search/newsearch/org/eclipse/search/ui/text/AbstractTextSearchViewPage.java |
Adds resource-aware pre-processing in “Remove Selected Matches” to remove matches by file/container in a batch. |
bundles/org.eclipse.search/newsearch/org/eclipse/search/ui/text/AbstractTextSearchResult.java |
Introduces an element-based batch removal method to efficiently drop all matches for selected elements. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
bundles/org.eclipse.search/newsearch/org/eclipse/search/ui/text/AbstractTextSearchViewPage.java
Show resolved
Hide resolved
bundles/org.eclipse.search/newsearch/org/eclipse/search/ui/text/AbstractTextSearchViewPage.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.search/newsearch/org/eclipse/search/ui/text/AbstractTextSearchViewPage.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.search/newsearch/org/eclipse/search/ui/text/AbstractTextSearchResult.java
Outdated
Show resolved
Hide resolved
4cd364f to
b53503b
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
bundles/org.eclipse.search/newsearch/org/eclipse/search/ui/text/AbstractTextSearchViewPage.java
Show resolved
Hide resolved
bundles/org.eclipse.search/newsearch/org/eclipse/search/ui/text/AbstractTextSearchResult.java
Outdated
Show resolved
Hide resolved
17ec4af to
fc2f401
Compare
bundles/org.eclipse.search/newsearch/org/eclipse/search/ui/text/AbstractTextSearchResult.java
Outdated
Show resolved
Hide resolved
fc2f401 to
40ee202
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
|
|
||
| /** | ||
| * @return {@code true} if the result is not empty |
There was a problem hiding this comment.
The Javadoc description is incorrect or incomplete. It says "if the result is not empty" but should describe that this method checks if the specified element has any matches, not whether the entire result is not empty. Consider updating the documentation to something like "Returns true if the given element has matches" to clarify the method's purpose.
| * @return {@code true} if the result is not empty | |
| * Returns {@code true} if the given element has matches. |
| * | ||
| * @param elements | ||
| * the elements of which matches should be removed. | ||
| */ | ||
| void removeElements(List<?> elements) { |
There was a problem hiding this comment.
The removeElements method is package-private but appears to be a new API method that follows the pattern of other removal methods in this class (removeMatch, removeMatches, removeAll). All other removal methods in AbstractTextSearchResult are public. Consider making this method public for API consistency, and adding proper Javadoc documentation with @SInCE 3.18 tag and "Subclasses may extend this method" as seen in other removal methods. Alternatively, if this is intentionally internal-only, consider adding a comment explaining why it deviates from the pattern.
| * | |
| * @param elements | |
| * the elements of which matches should be removed. | |
| */ | |
| void removeElements(List<?> elements) { | |
| * <p> | |
| * Subclasses may extend this method. | |
| * </p> | |
| * | |
| * @param elements | |
| * the elements of which matches should be removed. | |
| * | |
| * @since 3.18 | |
| */ | |
| public void removeElements(List<?> elements) { |
bundles/org.eclipse.search/newsearch/org/eclipse/search/ui/text/AbstractTextSearchResult.java
Show resolved
Hide resolved
| List<IResource> elementsToRemove = new ArrayList<>(); | ||
| List<Object> others = new ArrayList<>(); | ||
| Object[] resultElements = result.getElements(); | ||
| for (Object selectedObj : selection) { | ||
| if (selectedObj instanceof IContainer container) { | ||
| for (Object resElement : resultElements) { | ||
| if (resElement instanceof IResource res && container.getFullPath().isPrefixOf(res.getFullPath()) | ||
| && res.getType() == IResource.FILE) { | ||
| elementsToRemove.add(res); | ||
| } | ||
| } | ||
| } else if (selectedObj instanceof IFile file) { | ||
| elementsToRemove.add(file); |
There was a problem hiding this comment.
The elementsToRemove list can contain duplicate IResource entries if a user selects both a container and a file within that container. When processing the container at line 1398-1404, all files under it are added; then if one of those files is also explicitly selected, it gets added again at line 1406. While removeElements handles this gracefully (the second removal is a no-op), this creates unnecessary work. Consider using a Set instead of a List for elementsToRemove, or checking if the file is already in the list before adding it at line 1406.
There was a problem hiding this comment.
This can happen. fElementsToMatches is removing the key and if its called second time it returns null which is also catched. So this is also obsolete.
Can be checked here: org.eclipse.search.ui.text.AbstractTextSearchResult.removeElements(List<?>)
- Implemented a batch removal of search matches - Search matches are removed from their parent, instead of one by one which causes performance issues - It's also fixing the problem, that all elements are removed instead only the visible elements (while all others are filtered by the limit number) - Replaces the ConcurrentHashMap.newKeySet() with the ConcurrentSkipListSet with the comparator and makes the additional sorting obsolete. - After this change, avoid using `size()` on values, because it is not more constant time operation, see `ConcurrentSkipListSet` javadoc. - Also comparator must be changed to consider different Match elements with same size and offsets in the set - otherwise the `ConcurrentSkipListSet` would lost them. - Added `AbstractTextSearchResult.hasMatches(Object element)` API for cases where match count not needed. - If possible, calls to `size()` changed to `isEmpty()` or omitted. Fixes eclipse-platform#3735 Co-authored-by: Andrey Loskutov <loskutov@gmx.de>
40ee202 to
7d37158
Compare
which causes performance issues
only the visible elements (while all others are filtered by the limit
number)
ConcurrentHashMap.newKeySet() with the ConcurrentSkipListSet with the
comparator and makes the additional sorting obsolete.
Fixes #3735