RFR: JDK-8322964 Optimize performance of CSS selector matching [v2]
John Hendrikx
jhendrikx at openjdk.org
Fri Jan 12 14:08:36 UTC 2024
On Fri, 12 Jan 2024 12:20:22 GMT, Marius Hanl <mhanl at openjdk.org> wrote:
>> 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:
> 
Thanks, it looks like a bit less classes are in use when compared to JFXCentral (which has about 1000), but still quite a lot. With `BitSet` that means if style classes are referenced that happen to have a high bit set, it creates an array to hold 400 bits (using 8 longs). When few style classes are active, the sets provided by `FixedCapacitySet` will be often smaller and (due to the other optimizations as well) faster. 8 longs is sufficient to hold 8 or 16 style name references depending on the JVM (32/64 bit, compressed pointers y/n).
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/1316#discussion_r1450495992
More information about the openjfx-dev
mailing list