-
Notifications
You must be signed in to change notification settings - Fork 210
[performance] faster Tree expand - eclipse.platform.swt#901 #1331
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
Conversation
@SyntevoAlex should this happen for all platforms or only for Windows? |
Test Results 900 files + 15 900 suites +15 51m 40s ⏱️ + 13m 18s For more details on these failures, see this check. Results for commit 727c6be. ± Comparison against base commit c41b487. ♻️ This comment has been updated with latest results. |
Jface should be ws agnostic. |
That's true but still we can have platform switches in it if required. |
I suggest adding a code comment with explanation.
Doing it on all platforms won't hurt, I think. But I didn't test it myself. You could play with my |
i added comments and reverse order |
Good. Note that I didn't test anything. |
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.
Looks reasonable to me, but I didn't test it.
I also added the setRedraw(false) trick, which cuts downs setImage() and setText() time when i sort the Problems view with many elements. for example ~4000 elements org.eclipse.swt.widgets.Display.readAndDispatch () reduces from 1300ms to 600ms |
super.preservingSelection(updateCode, reveal); | ||
tree.setRedraw(true); |
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 setRedraw(true)
be in a finally block?
I've tried the test reproducing the problem I'm working on from #649 GTKNo regressions Before change210 ms to process 10000 items After change196 ms to process 10000 items MacOSSlowdown? Before the change53 ms to process 10000 items After the change110 ms to process 10000 items |
MacOS increased tree sizeThe change definitely increases a time to reveal an item in a large tree Before413 ms to process 100000 items After969 ms to process 100000 items |
@SyntevoAlex any idea? |
jukZi :-)
can you please figure out which of them does cause regression on Mac? |
#649 is WIP, there is nothing to combine, I've tested on master and on your branch
I don't have Windows env and have already covered Linux and MacOS
I've removed new
This is a major surprise - I assumed |
Performance tests do not work, but are necessary. Life is pain. |
on windows:
=> that test can not show that this PR can make some things faster, but also no regression |
@jukzi |
0458de6
to
73fb5e9
Compare
let forget about redraw(false), it's already set in org.eclipse.ui.internal.views.markers.UIUpdateJob.runInUIThread(IProgressMonitor) |
@jukzi have you tried using |
|
None of new UPDATE: confirmed, moving it to the old spot fixes one test (I only check one test) |
i will split that commit |
There is a hint in Tree: long gtk_row_has_child_toggled (long model, long path, long iter) {
/*
* Feature in GTK. The expanded state of a row that lost
* its children is not persisted by GTK. So, the row
* doesn't exhibit the expanded state after obtaining the
* children. The fix is to preserve the expanded state
* and use this callback, as it is invoked when a row has
* gotten the first child row or lost its last child row.
*/
int [] index = new int [1];
GTK.gtk_tree_model_get (modelHandle, iter, ID_COLUMN, index, -1);
if (index [0] >= items.length) return 0;
TreeItem item = items [index [0]];
if (item == null) return 0;
int childCount = GTK.gtk_tree_model_iter_n_children (modelHandle, item.handle);
if (childCount != 0 && item.isExpanded) {
OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, TEST_EXPAND_ROW);
GTK.gtk_tree_view_expand_row (handle, path, false);
OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, TEST_EXPAND_ROW);
}
return 0;
} But the condition was not used during my debugging. |
Idea - Tree does not recheck states of children when item is expanded. So if state did not stick to GTK model the first time, when its parent is expanded the expansion state is not reapplied. Effectively the tree only works as expected when it is manipulated in a way end user would - top to bottom. |
i created an experiment: https://github.com/eclipse-platform/eclipse.platform.ui/pull/1357/files |
sounds reasonable |
only unrelated test errors: #1351 |
Why is it not a bug in windows that expanding invisible childs is faster than expand visible ones? Just a thought ;-) |
Invisible things don't need to be drawn. |
I glanced at If you care to make a pure SWT snippet, I could spend a bit of time to check it with native debugger. |
@basilevs can you create a pure SWT reproducer for GTK? |
Following test fails on last line on GTK. If user manually "helps" to expand "item2" node, the test instantly passes. diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Tree.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Tree.java
index 0ad17d5..86ada48 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Tree.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Tree.java
@@ -1188,6 +1188,35 @@
new TreeItem(item_0, 0, 0);
assertEquals(10, item_0.getItemCount());
});
}
+@Test
+public void test_persistExpandStatusForInvisibleItems() throws InterruptedException {
+ tree.dispose();
+ tree = new Tree(shell, SWT.VIRTUAL);
+ setWidget(tree);
+ shell.setLayout(new FillLayout());
+ SwtTestUtil.openShell(shell);
+ int itemCount[] = new int[] {1};
+ List<TreeItem> dataRequests = new ArrayList<>();
+ tree.addListener(SWT.SetData, event -> {
+ TreeItem item = (TreeItem) event.item;
+ dataRequests.add(item);
+ item.setText("item"+itemCount[0]++);
+ item.setItemCount(1);
+ });
+ TreeItem item1 = new TreeItem(tree, SWT.NONE);
+ TreeItem item2 = item1.getItem(0);
+ TreeItem item3 = item2.getItem(0);
+ assertTrue(dataRequests.remove(item1));
+ assertTrue(dataRequests.remove(item2));
+ assertTrue(dataRequests.isEmpty());
+ item2.setExpanded(true);
+ assertTrue(dataRequests.isEmpty());
+ item1.setExpanded(true);
+ // Item 3 is now visible and should request data
+ SwtTestUtil.processEvents(10000, () -> !dataRequests.isEmpty());
+ assertFalse(dataRequests.isEmpty());
+}
+
} |
ignoring random fail #275 |
If items limit is enabled, clicking on expandable element adds all elements **before** the node, so the sort order is totally wrong and "expandable node" appears "in the middle" of the siblings. However, "hidden and now expanded" elements (if exists) should always be appended **to the end** of the shown children. This is a regression from 5930a51 / eclipse-platform#1331. The problem with the patch above is that it inserts all previously hidden elements at the zero index in the tree, but the tree **has already some children**, so instead of adding new elements below existing, the patch prepends them. Since eclipse-platform#1331 consists of only two changes (changed tree item creation order on expand and updated javadoc), this is revert the former one. Fixes eclipse-platform#1417
If items limit is enabled, clicking on expandable element adds all elements **before** the node, so the sort order is totally wrong and "expandable node" appears "in the middle" of the siblings. However, "hidden and now expanded" elements (if exists) should always be appended **to the end** of the shown children. This is a regression from 5930a51 / #1331. The problem with the patch above is that it inserts all previously hidden elements at the zero index in the tree, but the tree **has already some children**, so instead of adding new elements below existing, the patch prepends them. Since #1331 consists of only two changes (changed tree item creation order on expand and updated javadoc), this is revert the former one. Fixes #1417
If items limit is enabled, clicking on expandable element adds all elements **before** the node, so the sort order is totally wrong and "expandable node" appears "in the middle" of the siblings. However, "hidden and now expanded" elements (if exists) should always be appended **to the end** of the shown children. This is a regression from 5930a51 / eclipse-platform#1331. The problem with the patch above is that it inserts all previously hidden elements at the zero index in the tree, but the tree **has already some children**, so instead of adding new elements below existing, the patch prepends them. Since eclipse-platform#1331 consists of only two changes (changed tree item creation order on expand and updated javadoc), this is revert the former one. Fixes eclipse-platform#1417
eclipse-platform/eclipse.platform.swt#901