Skip to content
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

[win] Slow Tree expand #901

Open
jukzi opened this issue Nov 24, 2023 · 7 comments
Open

[win] Slow Tree expand #901

jukzi opened this issue Nov 24, 2023 · 7 comments
Labels
help wanted Extra attention is needed performance Performance issue

Comments

@jukzi
Copy link
Contributor

jukzi commented Nov 24, 2023

For example when showing the quick-type hierarchy of java.lang.Object multiple seconds are spend in SWT expanding the tree.
most time is spend in CallWindwProc that follows each TreeItem.setExpanded()'s OS.SendMessage (hwnd, OS.TVM_EXPAND.
I don't get why it is that slow since org.eclipse.jface.viewers.AbstractTreeViewer.inputChanged(Object, Object) sets tree.setRedraw(false); before that.
Help wanted.
Screenshot from Sampling:
image

@jukzi jukzi added help wanted Extra attention is needed performance Performance issue labels Nov 24, 2023
@vogella
Copy link
Contributor

vogella commented Nov 24, 2023

See also #882

@SyntevoAlex
Copy link
Member

If you make a snippet, I could profile it with native profiler.
I remember that Tree likes to calculate scrollbars even with tree.setRedraw(false).
It's likely that the problem will go away if you expand items while parent is collapsed, and in the very end expand parent.

@jukzi
Copy link
Contributor Author

jukzi commented Nov 27, 2023

It's likely that the problem will go away if you expand items while parent is collapsed, and in the very end expand parent.

I don't have a snippet, but when i move setExpanded() after expanding the children, performance problem is gone. :-) And i don't see a visual difference. Thanks.

@laeubi
Copy link
Contributor

laeubi commented Nov 27, 2023

It's likely that the problem will go away if you expand items while parent is collapsed, and in the very end expand parent.

Could this be made somehow in the JFace impl to perform it in such a way by default?

@jukzi
Copy link
Contributor Author

jukzi commented Nov 27, 2023

Could this be made somehow in the JFace impl to perform it in such a way by default?

Absolutely. See my proposed PR. @SyntevoAlex After doing so the next hotspot (2seconds )is in CallWindwProc inside org.eclipse.swt.widgets.Tree.createItem() is there a trick against that too? It also happens while the tree's redraw is disabled.

@SyntevoAlex
Copy link
Member

You might want to read code comments here

* The fastest way to insert many items is:
* <ol>
* <li>Use {@link Tree#setRedraw} to disable drawing during bulk insert</li>
* <li>Insert every item at index 0 (insert them in reverse to get the same result)</li>
* <li>Collapse the parent item before inserting (gives massive improvement on Windows)</li>
* </ol>
*

and here
* The fastest way to insert many items is:
* <ol>
* <li>Use {@link Tree#setRedraw} to disable drawing during bulk insert</li>
* <li>Collapse the parent item before inserting (gives massive improvement on Windows)</li>
* </ol>

jukzi pushed a commit to jukzi/eclipse.platform.ui that referenced this issue Nov 28, 2023
* move setExpanded() after expanding the children
* insert every item at index 0 (in reverse order)

eclipse-platform/eclipse.platform.swt#901
@vogella
Copy link
Contributor

vogella commented Nov 28, 2023

cc @basilevs

jukzi pushed a commit to jukzi/eclipse.platform.ui that referenced this issue Nov 30, 2023
* move setExpanded() after expanding the children
* insert every item at index 0 (in reverse order)

eclipse-platform/eclipse.platform.swt#901
jukzi pushed a commit to jukzi/eclipse.platform.ui that referenced this issue Nov 30, 2023
* move setExpanded() after expanding the children
* insert every item at index 0 (in reverse order)

eclipse-platform/eclipse.platform.swt#901
jukzi pushed a commit to jukzi/eclipse.platform.ui that referenced this issue Nov 30, 2023
* move setExpanded() after expanding the children
* insert every item at index 0 (in reverse order)

eclipse-platform/eclipse.platform.swt#901
jukzi pushed a commit to jukzi/eclipse.platform.ui that referenced this issue Dec 1, 2023
* move setExpanded() after expanding the children
* insert every item at index 0 (in reverse order)

eclipse-platform/eclipse.platform.swt#901
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed performance Performance issue
Projects
None yet
Development

No branches or pull requests

4 participants