eclipse-platform / eclipse.platform.ui

Eclipse Platform
https://projects.eclipse.org/projects/eclipse.platform
Eclipse Public License 2.0
81 stars 189 forks source link

UI freeze when searching over large files. Search View Filter viewer limit is not applied for children in TreeViewer. #2279

Closed raghucssit closed 1 month ago

raghucssit commented 2 months ago

This issue is already reported here. Please close this one on Bugzilla as duplicate. https://bugs.eclipse.org/bugs/show_bug.cgi?id=575271

UI freezes over around 12 seconds if have a large search result in the second level tree onwards. The reason is Search View Filter viewer limit is not applied for children. Use below snippet to generate 100k files with searchable text in it. Initiate File Search with text text here

      public static void main(String[] args) throws IOException {
                Path folder = Paths.get("...");
                if (!Files.deleteIfExists(folder)) {
                    Files.createDirectory(folder);
                }
                int n = 100_000;
                String baseContent = "text here";
                for (int i = 0; i < n; ++i) {
                        System.out.println("Writing file " + i);
                        StringBuilder content = new StringBuilder();
                        int k = 1;
                        if (i == 1001) {
                            k = 1000;
                        }
                        for (int j = 0; j < k; ++j) {
                            content.append(baseContent);
                            content.append(" n");
                            content.append(i);
                            content.append(System.lineSeparator());
                        }
                        String fileName = "file" + i + ".txt";
                        Path file = folder.resolve(fileName);
                        try {
                                Files.write(file, content.toString().getBytes());
                        } catch (IOException e) {
                                System.err.println("Failed to write file: " + fileName);
                                e.printStackTrace();
                        }
                }
        }
jukzi commented 2 months ago

Can you please provide screenshot how you search and what the result looks like? Is this a linux issue only?

raghucssit commented 2 months ago

This is on linux. I did not test on windows. UI will not show not responding but nothing can be performed on UI for 12 seconds and more.

100k files in PE. PE don't freeze because there is global viewer limit. 100k-pe

Search results view tries to expand the dir node to select first match. 100k-sv

iloveeclipse commented 1 month ago

After playing a bit more with search view after merged changes I saw two things:

1) We still have a full hang (forever on the example with 100.000 files here) after doing "F5" (run the current search again) - this is because the view update code calls AbstractTextSearchResult.getMatchCount() on every element to update and that traverses every match... 2) The tree mode in the search view doesn't show that the matches were filtered from the view, but table mode does it. This is more relevant now, because we filter more aggressive (not only the first level) and user might wonder "where are all the 1.000.000 matches gone".

I will push a PR addressing both issues in a moment.

iloveeclipse commented 1 month ago

See https://github.com/eclipse-platform/eclipse.platform.ui/pull/2320

BeckerWdf commented 1 month ago

Once we have fixe this. Is this something we should also put into the New & Noteworthy document? It's not a new feature but improving performance / reducing UI freezes is always "noteworthy" from my point of view. ;-)

jukzi commented 1 month ago

we had performance improvements in every version. But at the same time we have so many regressions that it feels odd to praise xyz got faster while people complain uvw became worse.

iloveeclipse commented 1 month ago

All planned fixes merged, closing.