-
Notifications
You must be signed in to change notification settings - Fork 505
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
8252935: Add treeShowing listener only when needed #185
8252935: Add treeShowing listener only when needed #185
Conversation
👋 Welcome back jhendrikx! A progress list of the required criteria for merging this PR into |
These listeners exist for a good reason. Removing them will almost certainly cause regressions in behavior. See JDK-8090322 as well as the follow-on fixes (since that was a rather involved fix in the first place). |
@kevinrushforth I don't propose to remove them, only to move them to where they are needed. Currently they are part of Node, which means all nodes, whether they need to know the state of the Window or not are registering a listener. However, only PopupWindow and the ProgressIndicatorSkin are registering a listener on this property (other uses are limited to a simple "isTreeShowing" checks which can be determined directly). It is very wasteful to have all nodes register this listener, as there are potentially tens of thousands of nodes. All of these nodes are listening on the exact same two properties (when there is only one Scene and Window), causing huge listener lists there. The listener is not registered in a lazy fashion (ie, only registered if something else is listening to the property downstream, like reactfx would do). This also means that when a Scene change or Window showing change occurs, thousands of nodes will receive a change event, but only 2 types of nodes are actually interested. The other nodes are just doing a lot of house keeping to keep watching the correct property (as there is an indirection from Scene to Window). Therefore my proposal is to have the two cases involved register their own listener on Scene and Window. There will not be any regressions. The two tests that currently fail in this PR are expected to fail as I commented out the listener code in the classes involved, but that can easily be fixed by adding the correct listeners there. I'll update it so you can see all tests will pass. |
4fd989d
to
8b62140
Compare
@kevinrushforth I've updated this PR now with proper listeners added in again for PopupWindow and ProgressIndicatorSkin. In short, the functionality to support the All tests pass, including the memory leak tests that failed before. The issue JDK-8090322 you mentioned actually cautioned for not adding such listeners for all nodes and seemed to propose the kind of solution I constructed here with a separate class for the
|
I have another working alternative, but won't make a PR for it until it is more clear which direction the TableView / TreeTableView performance fixes are going to take. The alternative would convert the This means the property stays a part of |
@hjohn Per this message on the openjfx-dev mailing list, I have filed a new JBS issue for this PR to use. Please change the title to:
|
/reviewers 2 |
@kevinrushforth |
Webrevs
|
So, will this actually get reviewed? |
Now that we are past RDP1 for JavaFX 16, this seems a good time to look at some of these performance issues. One of the challenges will be ensuring no regressions. I did a preliminary review of this, along with some testing, and it looks less scary than I was afraid it would be. The overall approach seems sound: preserve the Can you do the following?
|
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 left a few inline comments below.
modules/javafx.controls/src/main/java/javafx/scene/control/skin/ProgressIndicatorSkin.java
Outdated
Show resolved
Hide resolved
modules/javafx.controls/src/main/java/javafx/scene/control/skin/ProgressIndicatorSkin.java
Show resolved
Hide resolved
8b62140
to
5ac5d9e
Compare
Sorry about the force push, merging over a year of changes from master did not seem right to me. It was only for getting up to date, I will do the other commits normally. |
I hadn't seen that in practice yet, it looks really nice.
I put a test under I am planning to address the rest of the comments somewhere in the coming week. |
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.
The updated fix using registerChangeListener
and the test look good. I left a few mostly-minor comments.
tests/system/src/test/java/test/javafx/scene/NodeTreeShowingTest.java
Outdated
Show resolved
Hide resolved
tests/system/src/test/java/test/javafx/scene/NodeTreeShowingTest.java
Outdated
Show resolved
Hide resolved
tests/system/src/test/java/test/javafx/scene/NodeTreeShowingTest.java
Outdated
Show resolved
Hide resolved
modules/javafx.graphics/src/main/java/com/sun/javafx/scene/TreeShowingExpression.java
Outdated
Show resolved
Hide resolved
I think this change is complete now, including an integration test and tests on all new code. Please let me know if anything else needs to be done. |
This PR also seems to fix another issue JDK-8259558. Test program is attached to the bug. Time readings, without this fix, |
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.
Added couple minor comments and a suggestion.
Rest looks good to me, Observed no failures. It would be a great performance improvement for large scene applications.
modules/javafx.graphics/src/test/java/test/javafx/scene/TreeShowingExpressionTest.java
Outdated
Show resolved
Hide resolved
modules/javafx.graphics/src/main/java/com/sun/javafx/scene/TreeShowingExpression.java
Outdated
Show resolved
Hide resolved
modules/javafx.graphics/src/main/java/com/sun/javafx/scene/TreeShowingExpression.java
Outdated
Show resolved
Hide resolved
This is possible, as for each Node removed two listeners are also removed from the huge listener lists in Scene and Window (O(n) performance). Adding is not affected much as adding a listener to a huge list is not that costly. |
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 good to me.
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.
The updated test and fix look good. While fixing up the copyright years you lost the initial year on one of the files, so that needs to be restored. I'll approve it after that.
modules/javafx.graphics/src/main/java/javafx/scene/SubScene.java
Outdated
Show resolved
Hide resolved
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 good.
@arapte will need to re-approve
@hjohn This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 16 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@kevinrushforth, @arapte) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
/integrate |
/sponsor |
@kevinrushforth @hjohn Since your change was applied there have been 16 commits pushed to the
Your commit was automatically rebased without conflicts. Pushed as commit 4733824. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
This is a PoC for performance testing.
It contains commented out code in PopupWindow and ProgressIndicatorSkin and two tests are failing because of that.
This code avoids registering two listeners (on Scene and on Window) for each and every Node to support the aforementioned classes. The complete change should update these two classes to add their own listeners instead.
Progress
Issue
Reviewers
Download
$ git fetch https://git.openjdk.java.net/jfx pull/185/head:pull/185
$ git checkout pull/185