-
Notifications
You must be signed in to change notification settings - Fork 144
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
[GTK] Optimize TreeItem constructor #882 #903
[GTK] Optimize TreeItem constructor #882 #903
Conversation
I would prefer some numbers here in the commit message. when inserting 100_000 items into the Tree using this code Tree tree = new Tree(shell, SWT.VIRTUAL);
for (int i = 0; i < 100_000; i++)
{
TreeItem item = new TreeItem(tree, 0);
item.setText("item#" + i);
} the speedup on my machine is 99.99sec -> 88.88sec |
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.
With these small issues fixed, I am willing to merge this PR.
bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java
Show resolved
Hide resolved
Please also rename commit to have |
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.
Now that this commit has more issues, I would rather remove it from PR for now.
@@ -33,6 +33,7 @@ | |||
Test_org_eclipse_swt_widgets_List.class, Test_org_eclipse_swt_widgets_Text.class, | |||
Test_org_eclipse_swt_widgets_ScrollBar.class, Test_org_eclipse_swt_widgets_Sash.class, | |||
Test_org_eclipse_swt_widgets_Tree.class, Test_org_eclipse_swt_widgets_TabFolder.class, | |||
org.eclipse.swt.tests.junit.performance.Test_org_eclipse_swt_widgets_Tree.class, |
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.
It is not appropriate to put performance tests into the main tests package.
Unit tests should run as fast as possible, and performance tests are slow by design.
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 should I put these tests to run them on CI?
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.
To my knowledge, there is no such place currently.
You can introduce new GitHub job maybe. But frankly I would rather not have it at all. Once problems are fixed, they are unlikely to come back. Yet you are going to burn hours of CPU time over years.
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.
Can leave them in for now and disable before merge to master?
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.
You can keep whatever you want on your branch.
You can create another PR for testing.
If you want this PR to be merged, remove tests.
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.
Removed the test from all suites for now.
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've investigated disabled performance tests and the problems "have came back". The test createComposites
Line 72 in 02c8a22
public void test_createComposites() { |
executes in seconds on Windows and Linux, but takes 28 minutes on Mac OS. It uses a disabled assertions library so would never fail even if it was enabled on CI though.
I've created a bug #912
...s/JUnit Tests/org/eclipse/swt/tests/junit/performance/Test_org_eclipse_swt_widgets_Tree.java
Show resolved
Hide resolved
With small fixes, commit with the fix is good to merge. I have used up my (rather small) time to look at someone else's PRs this week, so I could only review the next batch in a few days. Feel free to ask someone else to review, but it's not going to be too easy because there're very few active members currently. If you polish the first commit and don't introduce new problems, I can merge it when I see it. |
9ff75d4
to
df8e738
Compare
New commit message:
|
You still have spaces changed in |
Also, a nitpick: you added unneeded noise in commit message.
I would write
Can you see how much easier it is to understand without the noise? |
df8e738
to
84484eb
Compare
Added spaces before opening parentheses. Hard to spot. Is there a formatter configuration? I could not find one in contribution guide. |
New message:
|
Unfortunately you still have spaces changed. |
84484eb
to
466cb37
Compare
Fixed two more. |
Oh well. So that you're not upset by spaces, I'll forget it in this commit. |
Once CI finishes testing this PR, I will merge it. |
Just in case: master is not open yet for merging. |
Ahh, I always forget about that. Thanks for reminding. |
@SyntevoAlex thanks for the review. @iloveeclipse I've considered merging this in #902 meanwhile, but confused everyone with workflow discussion, so I'm not sure anymore 🤷 |
We have to wait till the official mail saying "master is open". |
I hope I didn't upset you too much with all the requests. Now that you understand SWT things a bit better, next PR will likely require fewer changes. |
@iloveeclipse while you're around, can I ask you about |
The requests were sensible. The workflow takes some getting used to. |
eclipse.platform.swt/bundles/org.eclipse.swt/Readme.md Lines 36 to 47 in 518769d
|
@basilevs you can now preserve this PR's git branch as is until it's merged. |
I can't say why it wasn't used but I personally prefer not to use it too, so I would prefer we would not introduce it. I've not seen yet code that would really need that ancient C feature that was by mistake added to Java. Thinking more about it, I believe SWT was created before this mistake happened to Java. |
Why do you consider it a mistake? |
In most places I saw an assert it was a lazy way to say "actually we should check that and somehow handle possible wrong flow, but let it go wrong in production code, it can't really happen". So either it can't happen and assert is not needed, or the code will run with wrong state in production with side effects we haven't tested, because in tests we use assertions and flow is different anyway. So either one uses defensive code style, and no assertions needed because all possible code paths are handled by regular code flow, or one uses assertions. |
Yes I can understand this logic. However, for every possible assert location, let's estimate the likelihood of things going wrong. So my point is that there are many cases where paying the cost for proper handling is not justified because the problem seems to be very unlikely, yet still I'm not 100% sure, so I add an assert. |
If I assume/assert something can't happen I throw |
master is not open. Please rebase your PR onto master so that tests are run, then I can merge it. |
As a result of the rebase, your commit |
In the future, don't merge master into your branch. Instead, rebase your branch onto master. |
Testing asymptotic execution times for operations over large trees.
iterator eclipse-platform#882 This change eliminates a single hotspot. The overall complexity of tree building and element reveal is still quadratic. Performance improvement is proven by running org.eclipse.swt.tests.junit.performance.Test_org_eclipse_swt_widgets_Tree.jfaceReveal() In test jfaceReveal[Shape: STAR, virtual: true]: 10_000 elements: 620_682_717ns -> 501_378_662ns 100_000 elements: 62_804_214_489ns -> 52_781_899_817ns (-16%)
05d3d5e
to
f5edd67
Compare
In master now. Thanks for your contribution! You can now rebase your other branch onto master. |
Next optimization step is #904 |
Add spaces before parentheses and brackets The defects are mentioned in eclipse-platform#903
This eliminates a single hotspot. The full complexity for tree building is still quadratic.
Profile before the fix:
Profile after the fix: