CSS Performance regression inTableColumnHeader.resizeColumnToFitContent
Robert Lichtenberger
r.lichtenberger at gmail.com
Thu Feb 1 12:00:32 UTC 2024
Hi,
We are seeing degraded performance in our production application
concerning the "fit to content" function of TableViews.
I've developed a little benchmark program that can be found at
https://gist.github.com/effad/9eebee0c1e86a8e605cb55ced9485dd4
Here's the last lines of data from runs against different JavaFX versions:
JFX 17.0.10+2 average run time: 848
JFX 18.0.1+2 average run time: 839
JFX 19.0.2+1 average run time: 1113
JFX 20.0.2+3 average run time: 1656
JFX 21.0.2+5 average run time: 2460
17 and 18 are almost the same.
The performance penalty of 19 most likely is due to (my own) PR in
https://github.com/openjdk/jfx/pull/757, which put's the cell used to
measure the needed width of the column into a row.
The penalties from 19 to 20 and 20 to 21 however are worse than that.
To investigate further I let the benchmark run (with no warmup, just 3
iterations and only 5000 rows) in the profiler Visual VM 2.1.7. Looking
at _the_ hotspot of the execution I can see that
javafx.scene.CssStyleHelper.transitionToState is consuming most of the
time. And I can see that this method is called:
~ 30.000 times in JFX 18
~ 45.000 times in JFX 19 (which is 3 iterations * 5000 rows more than in
JFX 18, as expected since we have an additional row whose css needs to
be applied)
~ 105.000 times in JFX 20
~ 105.000 times in JFX 21
In looking at my changes for PR 757, I noticed that there are calls to
cell.updateTableColumn(tc) and cell.updateTableView(tv) that need not be
within the loop iterating over the rows. When putting these two lines
before the loop, I was able to measure:
JFX 23-internal+0-2024-02-01-061822 average run time: 1119
which would be roughly at the performance lebel of JFX 19 again.
Interestingly, when profiling with this optimization I still get 105k
calls to transitionToState, but they seem to be much faster.
So I see two issues here:
a) A general CSS-related performance degradation
b) A potential to optimize resizeColumnToFitContent()
Is it ok to open two issues for that and provide a PR for b)? I have no
idea what to do about a), maybe someone with more experience in the CSS
stuff can look at it?
Thanks,
Robert
More information about the openjfx-dev
mailing list