RFR: JDK-8322964 Optimize performance of CSS selector matching [v2]
Marius Hanl
mhanl at openjdk.org
Fri Jan 12 12:23:34 UTC 2024
On Thu, 11 Jan 2024 22:36:58 GMT, John Hendrikx <jhendrikx at openjdk.org> wrote:
>> modules/javafx.graphics/src/main/java/com/sun/javafx/css/FixedCapacitySet.java line 94:
>>
>>> 92: return maximumCapacity == 0 ? empty()
>>> 93: : maximumCapacity == 1 ? new Single<>()
>>> 94: : maximumCapacity == 2 ? new Duo<>()
>>
>> I can confirm that most of the code in my application uses 1-2 styleclasses.
>> Since all controls have one styleclass by default (some even more, think about `TextInputControl` with `text-input` -> `TextField` with `text-field`), does it make sense to also implement a specialized `Triple` class?
>>
>> We also often add 2 more styleclasses, so 3 style classes seems like a usecase that happens quite often.
>> I also can confirm that 4 styleclasses or even more are very rare.
>> I only found one: (`.label` + 3 added from us)
>> 
>
> Thanks for having a look, it's good to have some more use cases from other applications! The sets are used both for the style classes on `Node`s but also the set of style classes in CSS selectors (multiple style classes in selectors are even more rare I think than multiple style classes on `Node`s).
>
> I think from a performance perspective, `Duo` and `Hashless` are likely very closely matched, but I can do some testing in that area. The reason I say this is that I only got a very minor boost from including `Duo`, but kept it because it is a bit more memory efficient.
>
> If you want, I'm also curious about how many styles are used in your application (you can see this by looking at the size of `StyleClassSet#styleClasses` after all styles are loaded).
I see, thanks for checking that out.
I checked the application, here is the result:
After starting the app:

After using it a little bit:

---
I also checked out Scenebuilder after using it a little bit:

-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/1316#discussion_r1450360838
More information about the openjfx-dev
mailing list