RFR: 8377427: Reduce substring allocations in Color.web(String, double) [v7]

Michael Strauß mstrauss at openjdk.org
Thu Feb 19 17:49:26 UTC 2026


On Thu, 19 Feb 2026 17:18:02 GMT, Andy Goryachev <angorya at openjdk.org> wrote:

>>> some measurements of the improvement in parsing performance
>> 
>> I've run a JMH benchmark where I call `Color.web("rgb(x%, y%, z%)")` with random values. The strings are precomputed to make sure that I don't measure the string concatenation. Here are the results:
>> 
>> Benchmark                              Mode  Cnt     Score   Error   Units
>> ColorParsingPerfTest.parseColor(old)  thrpt    5   619,957 ± 5,670   ops/s
>> ColorParsingPerfTest.parseColor(new)  thrpt    5  1545,581 ± 13,451  ops/s
>> 
>> 
>>> more tests to demonstrate the correct behavior, esp. near transition points
>> 
>> Good point, I've added more tests especially around subnormals and limits.
>> 
>>> updated PR description (and possibly JBS as well) mentioning the new algorithm
>> 
>> I've mentioned the algorithm in the PR description.
>> 
>>> document the changes in behavior (a whitespace handling is one, are there other changes?)
>>> do the behavior differences cross the threshold for this to require a CSR?
>> 
>> `Color.web()` parses CSS numbers, so the current behavior is out of spec. This just brings it in line with the specification, which doesn't require a CSR.
>
> it looks like there is about 2x performance improvement for the method.  this is good, the question is - how many times the method is called in a typical application, and what is the actual impact of it?
> 
> granted, there are many more moving parts and uncertainties that depend on the concrete application, my question is whether the actual improvement is 0.1%, or 1%, or 10% ?

That would depend on the application. I don't really get the line of inquiry here. This change is:
1. Twice as fast, measured with a micro-benchmark
2. More correct with regard to the specification

If that's not enough to warrant inclusion, then so be it. But no one here will conduct studies with different kinds of applications, architectures, CSS usage patterns, and various definitions of performance.

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

PR Review Comment: https://git.openjdk.org/jfx/pull/2069#discussion_r2829271328


More information about the openjfx-dev mailing list