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

8197991: Selecting many items in a TableView is very slow #673

Closed
wants to merge 12 commits into from

Conversation

abhinayagarwal
Copy link
Contributor

@abhinayagarwal abhinayagarwal commented Nov 17, 2021

This work improves the performance of MultipleSelectionModel over large data sets by caching some values and avoiding unnecessary calls to SelectedIndicesList#size. It further improves the performance by reducing the number of iterations required to find the index of an element in the BitSet.

The work is based on an abandoned patch submitted by @yososs

There are currently 2 manual tests for this fix.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8197991: Selecting many items in a TableView is very slow

Reviewers

Contributors

  • Naohiro Yoshimoto <yosbits@gmail.com>

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jfx pull/673/head:pull/673
$ git checkout pull/673

Update a local copy of the PR:
$ git checkout pull/673
$ git pull https://git.openjdk.java.net/jfx pull/673/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 673

View PR using the GUI difftool:
$ git pr show -t 673

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jfx/pull/673.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Nov 17, 2021

👋 Welcome back abhinayagarwal! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Ready for review label Nov 17, 2021
@mlbridge
Copy link

mlbridge bot commented Nov 17, 2021

Webrevs

@kevinrushforth
Copy link
Member

I closed #127 on which this PR is based.

@abhinayagarwal Please use the /contributor command to add @yososs as a contributor.

/reviewers 2

@openjdk
Copy link

openjdk bot commented Nov 18, 2021

@kevinrushforth
The number of required reviews for this PR is now set to 2 (with at least 1 of role reviewers).

@Maran23
Copy link
Member

Maran23 commented Nov 18, 2021

Just wondering, isn't it also possible to write some unit tests for the MultipleSelectionModel(Base) ?

@abhinayagarwal
Copy link
Contributor Author

/contributor add @yososs

@openjdk
Copy link

openjdk bot commented Nov 22, 2021

@abhinayagarwal Could not parse @yososs as a valid contributor.
Syntax: /contributor (add|remove) [@user | openjdk-user | Full Name <email@address>]. For example:

  • /contributor add @openjdk-bot
  • /contributor add duke
  • /contributor add J. Duke <duke@openjdk.org>

@abhinayagarwal
Copy link
Contributor Author

abhinayagarwal commented Nov 22, 2021

@Maran23 I don't know what would be an apt unit test as the PR changes implementation detail. If you have suggestions, please let me know.

There are 276 unit tests in test.javafx.scene.control.MultipleSelectionModelImplTest and all of them (excluding 4 ignored test cases) still pass with the changes made to this PR.

@kevinrushforth
Copy link
Member

I see that the /contributor command didn't work with the original contributor's GitHub username. You can instead take the contributor information from the HEAD commit of the pull request: Naohiro Yoshimoto yosbits@gmail.com.

@abhinayagarwal
Copy link
Contributor Author

/contributor add Naohiro Yoshimoto yosbits@gmail.com

@openjdk
Copy link

openjdk bot commented Nov 24, 2021

@abhinayagarwal
Contributor Naohiro Yoshimoto <yosbits@gmail.com> successfully added.

@abhinayagarwal
Copy link
Contributor Author

@kevinrushforth Is there something I can do to move this PR forward?

Copy link
Member

@kevinrushforth kevinrushforth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix looks good to me. I did leave a couple questions about the implementation.

The new manual tests need a copyright header, and I noted a few of the code formatting issues.

@kevinrushforth
Copy link
Member

Thanks for adding the manual test. I can confirm the performance gains. I ran the ListView test, clicked on one of the cells visible without scrolling, then pressed the "select to the end" operation. With the 70k cells defined by the test program that operation ran 13,715 times faster on my machine with this fix.

Copy link
Member

@kevinrushforth kevinrushforth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is very close to being ready to go in. I left one more inline comment about the invalidation of size. There is also a pending minor code formatting comment.

@kevinrushforth kevinrushforth self-requested a review January 6, 2022 18:27
Copy link
Member

@kevinrushforth kevinrushforth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix looks good. I left a few comments on the tests.

private void clearSelection(ListView listView) {
long t = System.currentTimeMillis();
listView.getSelectionModel().clearSelection();
System.out.println("time:"+ (System.currentTimeMillis() - t));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still pending.

tests/manual/controls/SelectTableViewTest.java Outdated Show resolved Hide resolved
tests/manual/controls/SelectTableViewTest.java Outdated Show resolved Hide resolved
Copy link
Member

@kevinrushforth kevinrushforth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

Copy link
Collaborator

@aghaisas aghaisas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code changes look good.
I tested on Mac. This PR drastically improves the selection time for the provided manual test.

@openjdk
Copy link

openjdk bot commented Jan 10, 2022

@abhinayagarwal 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:

8197991: Selecting many items in a TableView is very slow

Co-authored-by: Naohiro Yoshimoto <yosbits@gmail.com>
Reviewed-by: kcr, aghaisas

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 35 new commits pushed to the master branch:

  • be3b3bd: 8279328: CssParser uses default charset instead of UTF-8
  • 487e4b1: 8267059: Gradle :clean and :apps tasks fail on Windows if ANT_HOME contains spaces
  • 32f21ff: 8234921: Add DirectionalLight to the selection of 3D light types
  • 1feba1f: 8279396: Define version in .jcheck/conf
  • c705bd4: 8203463: [Accessibility, Narrator] NPE in TableView
  • 303bcdb: 8279078: Update copyright header for files modified in 2021
  • 1f10c63: 8273096: Add support for H.265/HEVC to JavaFX Media
  • 18063ad: 8231601: Update CONTRIBUTING.md to clarify process for contributing features plus Skara changes
  • 5422a5a: 8278860: Streamline properties for Monocle
  • 4c5bf44: 8278905: JavaFX: EnumConverter has a typo in the toString method
  • ... and 25 more: https://git.openjdk.java.net/jfx/compare/f939d094e3f02575c77a12c3a986d5f601a65a1d...master

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, @aghaisas) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added the ready Ready to be integrated label Jan 10, 2022
@abhinayagarwal
Copy link
Contributor Author

/integrate

@openjdk openjdk bot added the sponsor Ready to sponsor label Jan 11, 2022
@openjdk
Copy link

openjdk bot commented Jan 11, 2022

@abhinayagarwal
Your change (at version 30fb31c) is now ready to be sponsored by a Committer.

@nlisker
Copy link
Collaborator

nlisker commented Jan 11, 2022

/sponsor

@openjdk
Copy link

openjdk bot commented Jan 11, 2022

Going to push as commit 8c4f966.
Since your change was applied there have been 35 commits pushed to the master branch:

  • be3b3bd: 8279328: CssParser uses default charset instead of UTF-8
  • 487e4b1: 8267059: Gradle :clean and :apps tasks fail on Windows if ANT_HOME contains spaces
  • 32f21ff: 8234921: Add DirectionalLight to the selection of 3D light types
  • 1feba1f: 8279396: Define version in .jcheck/conf
  • c705bd4: 8203463: [Accessibility, Narrator] NPE in TableView
  • 303bcdb: 8279078: Update copyright header for files modified in 2021
  • 1f10c63: 8273096: Add support for H.265/HEVC to JavaFX Media
  • 18063ad: 8231601: Update CONTRIBUTING.md to clarify process for contributing features plus Skara changes
  • 5422a5a: 8278860: Streamline properties for Monocle
  • 4c5bf44: 8278905: JavaFX: EnumConverter has a typo in the toString method
  • ... and 25 more: https://git.openjdk.java.net/jfx/compare/f939d094e3f02575c77a12c3a986d5f601a65a1d...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Jan 11, 2022
@openjdk openjdk bot closed this Jan 11, 2022
@openjdk openjdk bot removed ready Ready to be integrated rfr Ready for review sponsor Ready to sponsor labels Jan 11, 2022
@openjdk
Copy link

openjdk bot commented Jan 11, 2022

@nlisker @abhinayagarwal Pushed as commit 8c4f966.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

8 participants