On Tue, 17 Mar 2026 04:22:31 GMT, chuckyschluz <[email protected]> wrote:
>> my limited testing shows no difference between pure #2109 and merged with >> this PR... will continue testing. > > @andy-goryachev-oracle > > [JDK8311505Test.java](https://github.com/user-attachments/files/26042227/JDK8311505Test.java) > > This tests `TableView` and `TreeTableView` as these are the only objects > that should receive any benefit from this PR. The changes I made to > `MultipleSelectionModelBase` are not used anywhere in JFX except in > `ControlUtils`, which in turn is only used for `TableView` and > `TreeTableView`. > > This PR fixes the deselection problem in both `TableView` and > `TreeTableView`. `TreeTableView` select all is still slow. > [JDK-8181411](https://bugs.openjdk.org/browse/JDK-8181411) > > `TableView`: > > Item Count | Master Select | Fixed Select | Select Improv. | Master Deselect > | Fixed Deselect | Deselect Improv. > -- | -- | -- | -- | -- | -- | -- > 16,384 | 7ms | 7ms | — | 83ms | 4ms | ~20x > 32,768 | 13ms | 13ms | — | 331ms | 7ms | ~47x > 65,536 | 25ms | 18ms | ~1.4x | 1,283ms | 9ms | ~142x > 131,072 | 63ms | 31ms | ~2.0x | 5,142ms | 16ms | ~321x > 262,144 | 195ms | 82ms | ~2.3x | 20,526ms | 31ms | ~662x > > `TreeTableView`: > > Item Count | Master Select | Fixed Select | Select Improv. | Master Deselect > | Fixed Deselect | Deselect Improv. > -- | -- | -- | -- | -- | -- | -- > 16,384 | 310ms | 295ms | — | 81ms | 2ms | ~40x > 32,768 | 1,451ms | 1,448ms | — | 315ms | 3ms | ~105x > 65,536 | 6,505ms | 7,702ms | — | 1,247ms | 8ms | ~155x > 131,072 | 37,034ms | 49,681ms | — | 5,045ms | 13ms | ~388x > 262,144 | 260,019ms | 278,258ms | — | 20,025ms | 33ms | ~606x > > I presume the slight regression in `TreeTableView` select is attributed to > constructing the added indices `List<Integer>`, but I am confused why it > helps with `TableView`. I can probably make it a bit faster by passing a raw > `int[]` array instead of a `List<Integer>`. > Thank you @chuckyschluz for measuring the improvement, very nice! > > I also noticed creation of the list - I wonder if it can be replaced with a > more optimal data structure? > > For example, a `BitSet` is not only the most compact data structure in this > case, but it also makes it unnecessary to sort and deduplicate the indexes. > What do you think? I'll try it tonight and post some new numbers. After reviewing `TreeTableView`, I believe the bottleneck is the `O(N)` traversal of the tree in `TreeUtil.getItem` that must be done `N` times for `selectAll` . This can be addressed with another utility method like `TreeItem<T> getNextItem(TreeItem<T> item)`, which would traverse the tree exactly one time. This would also be helpful for `selectRange` or anything else that requires sequential access. ------------- PR Comment: https://git.openjdk.org/jfx/pull/2100#issuecomment-4077280607
