RFR: 8185886: Improve scrolling performance of TableView and TreeTableView

Nir Lisker nlisker at openjdk.java.net
Tue Feb 25 13:58:07 UTC 2020

On Tue, 25 Feb 2020 12:18:34 GMT, dannygonzalez <github.com+6702882+dannygonzalez at openjdk.org> wrote:

>> I haven't done a detailed review yet, but I worry about the memory consumption and performance of using a Map for the simple cases where there is only a single (or very small number) of listeners. These methods are used in many more places than just the TableView / TreeTableView implementation.
> Replying to @nlisker and @kevinrushforth general comments about the memory consumption of using a LinkedHashMap:
> I agree that at the very least these should be lazy initialised when they are needed and that we should initially allocate a small capacity and load factor.
> We could also have some sort of strategy where we could use arrays or lists if the number of listeners are less than some threshold (i.e. keeping the implementation with a similar overhead to the original) and then switch to the HashMap when it exceeds this threshold. This would make the code more complicated and I wonder if this is the worth the extra complexity.
> I know that in our application, the thousands of listeners unregistering when using a TableView was stalling the JavaFX thread. 
> I am happy to submit code that lazy initialises and minimises initial capacity and load factor as suggested or happy to take direction and suggestions from anyone with a deeper understanding of the code than myself.

I think that a starting point would be to decide on a spec for the listener notification order: is it specified by their registration order, or that is it unspecified, in which case we can take advantage of this for better performance. Leaving is unspecified and restricting ourselves to having it ordered is losing on both sides.


PR: https://git.openjdk.java.net/jfx/pull/108

More information about the openjfx-dev mailing list