Re: RFR JDK-6321472: Add CRC-32C API

2014-10-17 Thread David Chase
On 2014-10-17, at 5:22 PM, Staffan Friberg wrote: > > The polynomial used for multiplication is different so while, as with all > CRCs, the algorithm is similar, but a different polynomial is used and the > final checksum will be different. Yes, I was misled by the comments. Wikipedia makes

Re: RFR JDK-6321472: Add CRC-32C API

2014-10-17 Thread Ulf Zibis
Am 18.10.2014 um 00:38 schrieb Staffan Friberg: Hi Ulf, Since the default method only calls a single method it will most likely be inlined. After inlining the check will be if (0 < 0 || b.length < 0 || 0 > b.length - b.length) { throw new ArrayIndexOutOfBoundsException();

Re: RFR JDK-6321472: Add CRC-32C API

2014-10-17 Thread Peter Levart
On 10/17/2014 08:58 PM, Staffan Friberg wrote: Here is a new webrev with the updates from Alan's and Peter's suggestions. http://cr.openjdk.java.net/~sfriberg/JDK-6321472/webrev.01 Hi Staffan, A few more comments... 217 if (Unsafe.ADDRESS_SIZE == 4) { 218

Re: RFR JDK-6321472: Add CRC-32C API

2014-10-17 Thread Staffan Friberg
Good point, looks like I was overly concerned about the null check and inlining of that method. I had to manually inline the slicing-by-8 loop to guarantee good performance. Removed the ENDIAN field and use ByteOrder.nativeOrder() directly instead. New webrev - http://cr.openjdk.java.net/~sfri

Re: RFR JDK-6321472: Add CRC-32C API

2014-10-17 Thread Staffan Friberg
Hi Ulf, Since the default method only calls a single method it will most likely be inlined. After inlining the check will be if (0 < 0 || b.length < 0 || 0 > b.length - b.length) { throw new ArrayIndexOutOfBoundsException(); } Which will be optimized away so only

Re: RFR JDK-6321472: Add CRC-32C API

2014-10-17 Thread Stanimir Simeonoff
Thanks Staffan, You're absolutely right. Funny enough I was absolutely sure compressed ops affected it. Thanks Stanimir On Sat, Oct 18, 2014 at 12:00 AM, Staffan Friberg < staffan.frib...@oracle.com> wrote: > Hi Stanimir, > > Unsafe.ADDRESS_SIZE is the size of a native pointer, and is not aff

Re: RFR JDK-6321472: Add CRC-32C API

2014-10-17 Thread Staffan Friberg
Hi David, Not sure what you mean with a bit flip. Calculating CRC32 and then flipping the result in some way? The polynomial used for multiplication is different so while, as with all CRCs, the algorithm is similar, but a different polynomial is used and the final checksum will be different.

Re: RFR JDK-6321472: Add CRC-32C API

2014-10-17 Thread David Chase
See also: http://cr.openjdk.java.net/~drchase/7088419/webrev.01/ This is the version that was not coded as an intrinsic, that also included fork/join. The crazy Intel instructions are accessed from native code, so you can get a feel for what the code looks like before it is converted to an intri

Re: RFR JDK-6321472: Add CRC-32C API

2014-10-17 Thread Staffan Friberg
Hi Stanimir, Unsafe.ADDRESS_SIZE is the size of a native pointer, and is not affected by how the JVM handles Java references on the heap. -- import sun.misc.Unsafe; public class AddressSize { public static void main(String[] args) { System.out.println("Address Size: " +

Re: RFR JDK-6321472: Add CRC-32C API

2014-10-17 Thread David Chase
On 2014-10-17, at 2:53 PM, Staffan Friberg wrote: > Fully agree that using Unsafe makes one sad. > > I'm just about to send out a new webrev with Alan's and Peter's comments, > once I have that done I will give using the NIO-Buffer API a second try to > see if using IntBuffer and LongBuffer i

Re: RFR JDK-6321472: Add CRC-32C API

2014-10-17 Thread Ulf Zibis
Am 17.10.2014 um 20:58 schrieb Staffan Friberg: Here is a new webrev with the updates from Alan's and Peter's suggestions. http://cr.openjdk.java.net/~sfriberg/JDK-6321472/webrev.01 I would not remove: 86 public void update(byte[] b) { 87 adler = updateBytes(adler, b, 0, b.l

Re: RFR JDK-6321472: Add CRC-32C API

2014-10-17 Thread Stanimir Simeonoff
Also, ede Unsafe.ADDRESS_SIZE == 4 That doesn't imply 32bit systems as with less than 32GiB (on 64bit) the default is using compressed options and the address size is still only 4bytes. I usually use something like this (in user space code) to detect the architecture private static final bool

Re: RFR JDK-6321472: Add CRC-32C API

2014-10-17 Thread Vitaly Davidovich
I wouldn't even bother with ENDIAN field; ByteOrder.nativeOrder(), which calls Bits.byteOrder(), which returns a static final field (modulo a null check) should get JIT compiled into just a read of Bits.byteOrder. If storing ByteOrder.nativeOrder() in a static final field actually makes a differen

Re: RFR JDK-6321472: Add CRC-32C API

2014-10-17 Thread Stanimir Simeonoff
Hi, I don't quite see the point of this line: private transient final static ByteOrder ENDIAN = ByteOrder.nativeOrder().equals(ByteOrder.BIG_ENDIAN) ? ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN; should be just private static final ByteOrder ENDIAN = ByteOrde

Re: RFR JDK-6321472: Add CRC-32C API

2014-10-17 Thread Staffan Friberg
On 10/17/2014 04:05 AM, Alan Bateman wrote: On 17/10/2014 02:42, Staffan Friberg wrote: Hi, This RFE adds a CRC-32C class. It implements Checksum so it will have the same API CRC-32, but use a different polynomial when calculating the CRC checksum. CRC-32C implementation uses slicing-by-8 t

Re: RFR JDK-6321472: Add CRC-32C API

2014-10-17 Thread Staffan Friberg
Fully agree that using Unsafe makes one sad. I'm just about to send out a new webrev with Alan's and Peter's comments, once I have that done I will give using the NIO-Buffer API a second try to see if using IntBuffer and LongBuffer is able to achieve similar performance. As I noted in my rep

Re: RFR JDK-6321472: Add CRC-32C API

2014-10-17 Thread Stanimir Simeonoff
Actually I was under the impression I had included the list. Getting it done w now. Overall if you want speed you go unsafe (bit sad) as the JIT may not remove the bound checks off the ByteBuffer. Unsafe is pretty ugly overall, though and personally I try to avoid it giving up performance. On 64b

Re: RFR JDK-6321472: Add CRC-32C API

2014-10-17 Thread Peter Levart
Hi Staffan, You're right. I thought ByteBuffer was more optimal in this respect. Regards, Peter On 10/17/2014 06:47 PM, Staffan Friberg wrote: Hi Peter, Thanks for reviewing. I have switched to the Integer methods. Was looking through that API but I was too stuck with the reflect and swap

Re: RFR JDK-6321472: Add CRC-32C API

2014-10-17 Thread Staffan Friberg
On 10/17/2014 01:46 AM, Peter Levart wrote: On 10/17/2014 03:42 AM, Staffan Friberg wrote: Hi, This RFE adds a CRC-32C class. It implements Checksum so it will have the same API CRC-32, but use a different polynomial when calculating the CRC checksum. CRC-32C implementation uses slicing-by

Re: RFR JDK-6321472: Add CRC-32C API

2014-10-17 Thread Vitaly Davidovich
In my experiments, ByteBuffer.wrap() with immediate use (e.g. BB.wrap (...).getInt (...)) does not trigger escape analysis (I.e. the BB is not eliminated). I suspect it's because wrap () is not trivial enough and compiler doesn't "see through" the noise there. Sent from my phone On Oct 17, 2014 4

Re: RFR JDK-6321472: Add CRC-32C API

2014-10-17 Thread Alan Bateman
On 17/10/2014 02:42, Staffan Friberg wrote: Hi, This RFE adds a CRC-32C class. It implements Checksum so it will have the same API CRC-32, but use a different polynomial when calculating the CRC checksum. CRC-32C implementation uses slicing-by-8 to achieve high performance when calculating

Re: Covariant overrides on the Buffer Hierarchy redux

2014-10-17 Thread Alan Bateman
On 17/10/2014 10:37, Paul Sandoz wrote: Hi, [Including compiler-dev, i am not on that list so please CC me if replying to just that list] I dropped this, then JVMLS got in the way... then J1 got in the way so i better get to this before Devoxx gets in the way... Richard, thanks for your

Re: [9] Review request : JDK-8059070: [TESTBUG] java/lang/invoke/LFCaching/LFMultiThreadCachingTest.java failed - timeout

2014-10-17 Thread Konstantin Shefov
Hi, I have updated the webrev: http://cr.openjdk.java.net/~kshefov/8059070/webrev.01/ -Konstantin 16.10.2014 17:24, Igor Ignatyev пишет: Konstantin, I haven't looked at code religiously, so I wouldn't say that I have reviewed it. however I have some comments, please see them inline. On 1

Re: Covariant overrides on the Buffer Hierarchy redux

2014-10-17 Thread Paul Sandoz
Hi, [Including compiler-dev, i am not on that list so please CC me if replying to just that list] I dropped this, then JVMLS got in the way... then J1 got in the way so i better get to this before Devoxx gets in the way... Richard, thanks for your continued patience. In the interim Richar

Re: RFR 8023173: FileOutputStream(FileDescriptor) does not respect append flag on Windows

2014-10-17 Thread Alan Bateman
On 06/10/2014 11:41, Ivan Gerasimov wrote: Hello everybody! The append mode is emulated on Windows, therefore we have to keep a flag indicating that. With the current implementation, the FileDescriptor does not know if the file were opened with O_APPEND, and the flag is maintained at the up

Re: RFR JDK-6321472: Add CRC-32C API

2014-10-17 Thread Peter Levart
On 10/17/2014 03:42 AM, Staffan Friberg wrote: Hi, This RFE adds a CRC-32C class. It implements Checksum so it will have the same API CRC-32, but use a different polynomial when calculating the CRC checksum. CRC-32C implementation uses slicing-by-8 to achieve high performance when calculat