Hi Ogata,

I'm redirecting this RFR to core-libs-dev and nio-dev as it potentially affects 
all platforms and should be discussed there.

As for your proposal: I can generally understand that using volatile at this 
place hurts performance on the power platform and this should be improved. I 
however don't fully oversee if just removing the volatile qualifier is the only 
thing to do here. Maybe one should implement some double checked locking 
pattern around the static field bugLevel and its initialization from system 
properties? I guess during VM initialization multiple threads can got to this 
place and the volatile qualifier was added for synchronizing access to 
"bugLevel".

So, waiting for comments from other experts...

Best regards
Christoph

> -----Original Message-----
> From: ppc-aix-port-dev [mailto:ppc-aix-port-dev-
> boun...@openjdk.java.net] On Behalf Of Kazunori Ogata
> Sent: Dienstag, 27. Juni 2017 07:13
> To: jdk10-...@openjdk.java.net; ppc-aix-port-...@openjdk.java.net
> Subject: RFR: 8179527: Ineffective use of volatile hurts performance of
> Charset.atBugLevel()
> 
> Hi all, please review a change for JDK-8182743.
> 
> Bug report: https://bugs.openjdk.java.net/browse/JDK-8182743
> Webrev: http://cr.openjdk.java.net/~horii/8179527/webrev.00/
> 
> This change removes a "volatile" qualifier of a static variable used by
> Charset.atBugLevel() because it does not improve thread-safety of the code
> and it hurts performance on PPC (and should be the same in ARM, too).
> Removing the "volatile" improved performance by 26% in a POWER8 machine
> using following micro benchmark:
> 
> ------
> import java.io.*;
> import java.nio.ByteBuffer;
> import java.nio.charset.Charset;
> import java.util.ArrayList;
> 
> class ConvertTest {
>     static String str;
> 
>     public static void main(String[] args) {
>         byte buf[] = { 0x41 };
>         Charset fromCharset = Charset.forName("iso-8859-1");
> 
>         long start = System.currentTimeMillis();
> 
>         for(long i = 0; i < 100000000; i++)
>             str = new String(buf, 0, 1, fromCharset);
> 
>         long end = System.currentTimeMillis();
> 
>         System.out.println("Elapsed: "+(end-start)+" ms");
>     }
> }
> ------
> 
> 
> Regards,
> Ogata

Reply via email to