RFR: 8185886: Improve scrolling performance of TableView and TreeTableView
kcr at openjdk.java.net
Tue Feb 25 00:47:20 UTC 2020
On Mon, 24 Feb 2020 23:45:03 GMT, Nir Lisker <nlisker at openjdk.org> wrote:
>> Optimisation to ExpressionHelper.Generic class to use Sets rather than Arrays to improve listener removal speed.
>> This was due to the removal of listeners in TableView taking up to 50% of CPU time on the JavaFX Application thread when scrolling/adding rows to TableViews.
>> This may alleviate some of the issues seen here:
>> TableView has a horrific performance with many columns #409
>> JDK-8088394 : Huge memory consumption in TableView with too many columns
>> JDK-8166956: JavaFX TreeTableView slow scroll performance
>> JDK-8185887: TableRowSkinBase fails to correctly virtualise cells in horizontal direction
>> OpenJFX mailing list thread: TableView slow vertical scrolling with 300+ columns
> modules/javafx.base/src/main/java/com/sun/javafx/binding/ExpressionHelper.java line 194:
>> 193: private Map<InvalidationListener, Integer> invalidationListeners = new LinkedHashMap<>();
>> 194: private Map<ChangeListener<? super T>, Integer> changeListeners = new LinkedHashMap<>();
>> 195: private T currentValue;
> Two comments on this:
> 1. The old implementation initialized these lazily, so we might want to preserve that behavior. I think it is reasonable since in most cases an observable won't have both types of listeners attached to it.
> 2. Since we're dealing wither performance optimizations here, we should think about what the `initialCapcity` and `loadFactor` of these maps should be, as it can greatly increase performance when dealing with a large amount of entries.
Adding to this, we need to ensure that the simple case of a few listeners doesn't suffer memory bloat. It may make sense to initially allocate a Map with a small capacity and load factor, and then reallocate it if someone adds more than a certain number of listeners.
More information about the openjfx-dev