RFR: 8173585: Intrinsify StringLatin1.indexOf(char)

Andrew Dinn adinn at redhat.com
Fri Sep 18 12:42:23 UTC 2020


On 18/09/2020 12:06, Jason Tatton wrote:

> There are two separate things here:
> 1). Justification for the change itself:
> -The objective and justification for this patch is to bring the performance of StringLatin1 indexOf(char) in
>  line with StringUTF16 indexOf(char) for x86 and ARM64. This solves the problem as raised in
>  [JDK-8173585](https://bugs.openjdk.java.net/browse/JDK-8173585), and also on the [mailing
>  list](http://mail.openjdk.java.net/pipermail/jdk9-dev/2017-January/005539.html).

> 2). Discussion around future enhancements - concerning potential use of AVX-512 instructions and a more optimal
> implementation for short strings.
> -These would be separate JBS's I'm not advocating for/against this, they are just ideas separate from this JBS.
I don't agree that these two things are separable. Andrew's point
applies to both.

In the first case the problem is that the 'evidence' we have does not
testify to the possibility Andrew outlines. Both code examples used to
justify the idea StringLatin1.indexOf(char) will perform 'better' with
an AVX-based intrinsic are micro-benchmarks that do a lot of intensive
String manipulation and nothing else i.e. they won't get hit by the
possible cost of ramping up power for AVX because they make extensive
use of AVX and then stop. That's very unlikely to happen in a real world
case. So, the fact that this change removes the disparity seen with
these benchmarks is still not evidence for a general improvement.

So, I don't (yet) see a reason to make this change and the possibility
still stands that adopting this change may end up making most code that
uses StringLatin1.indexOf(char) worse.

It might be a good idea to consider finding some way to test whether the
cost Andrew has highlighted makes a difference  before committing this
change. I know the same argument might might be raised aginst the
existing intrinsics but surely that's an a fortiori argument for not
proceeding.

regards,


Andrew Dinn
-----------
Red Hat Distinguished Engineer
Red Hat UK Ltd
Registered in England and Wales under Company Registration No. 03798903
Directors: Michael Cunningham, Michael ("Mike") O'Neill



More information about the core-libs-dev mailing list