[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-openjfx-dev
Subject:    Re: RFR: JDK-8322964 Optimize performance of CSS selector matching [v5]
From:       John Hendrikx <jhendrikx () openjdk ! org>
Date:       2024-02-25 22:28:12
Message-ID: xga5s9hkb96wrtWT4B2lxAPTxMciWiJaL9_0UbiqlIA=.e2df744e-2543-46d4-a4d1-839d00308bb6 () github ! com
[Download RAW message or body]

> Improves performance of selector matching in the CSS subsystem. This is done by \
> using custom set implementation which are highly optimized for the most common \
> cases where the number of selectors is small (most commonly 1 or 2). It also should \
> be more memory efficient for medium sized and large applications which have many \
> style names defined in various CSS files. 
> Due to the optimization, the concept of `StyleClass`, which was only introduced to \
> assign a fixed bit index for each unique style class name encountered, is no longer \
> needed. This is because style classes are no longer stored in a `BitSet` which \
> required a fixed index per encountered style class. 
> The performance improvements are the result of several factors:
> - Less memory use when only very few style class names are used in selectors and \
> styles from a large pool of potential styles (a `BitSet` for potentially 1000 \
>                 different style names needed 1000 bits (worst case)  as it was not \
>                 sparse).
> - Specialized sets for small number of elements (0, 1, 2, 3-9 and 10+)
> - Specialized sets are append only (reduces code paths) and can be made read only \
>                 without requiring a wrapper
> - Iterator creation is avoided when doing `containsAll` check thanks to the inverse \
>                 function `isSuperSetOf`
> - Avoids making a copy of the list of style class names to compare (to convert them \
> to `StyleClass` and put them into a `Set`) -- this copy could not be cached and was \
> always discarded immediately after... 
> The overall performance was tested using the JFXCentral application which displays \
> about 800 nodes on its start page with about 1000 styles in various style sheets \
> (and which allows to refresh this page easily).   
> On JavaFX 20, the fastest refresh speed was 121 ms on my machine.  With the \
> improvements in this PR, the fastest refresh had become 89 ms.  The speed \
> improvement is the result of a 30% faster `Scene#doCSSPass`, which takes up the \
> bulk of the time to refresh the JFXCentral main page (about 100 ms before vs 70 ms \
> after the change).

John Hendrikx has updated the pull request incrementally with one additional commit \
since the last revision:

  Optimize performance of OpenAddressed Set just in case it is ever used

-------------

Changes:
  - all: https://git.openjdk.org/jfx/pull/1316/files
  - new: https://git.openjdk.org/jfx/pull/1316/files/a33f797a..c388f23d

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jfx&pr=1316&range=04
 - incr: https://webrevs.openjdk.org/?repo=jfx&pr=1316&range=03-04

  Stats: 30 lines in 1 file changed: 20 ins; 7 del; 3 mod
  Patch: https://git.openjdk.org/jfx/pull/1316.diff
  Fetch: git fetch https://git.openjdk.org/jfx.git pull/1316/head:pull/1316

PR: https://git.openjdk.org/jfx/pull/1316


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic