JDK-8158695 : Remove fork to xxcodeArrayLoop() and xxcodeBufferLoop() in sun.nio.cs coders
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.nio.charsets
  • Priority: P3
  • Status: Closed
  • Resolution: Won't Fix
  • OS: generic
  • CPU: generic
  • Submitted: 2016-06-05
  • Updated: 2018-03-03
  • Resolved: 2018-03-02
Related Reports
Blocks :  
Relates :  
Description
Use same code on heap buffers and direct buffers.
Snippet of current code:
        protected CoderResult decodeLoop(ByteBuffer src,
                                         CharBuffer dst)
        {
            if (src.hasArray() && dst.hasArray())
                return decodeArrayLoop(src, dst);
            else
                return decodeBufferLoop(src, dst);
        }

Since access to heap buffers and direct buffers is now optimized via Unsafe [1], there is no more need to separately optimize the code for heap buffers and direct buffers.
[1] https://bugs.openjdk.java.net/browse/JDK-8149469
Comments
This is because blocking bug JDK-6509032 is still open. So please wait for decision about this bug.
03-03-2018

It appears there is still "huge" performance gap between two paths.
02-03-2018

The performance difference measured with simple jmh test http://cr.openjdk.java.net/~sherman/8158695/CoderBM.java --------------------------------------------------------------------------------------------------- Benchmark (size) Mode Cnt Score Error Units CoderBM.decode_1b 16 avgt 25 28.081 ���� 0.497 ns/op CoderBM.decode_1b 64 avgt 25 50.248 ���� 0.725 ns/op CoderBM.decode_1b 128 avgt 25 83.394 ���� 1.541 ns/op CoderBM.decode_1b 1024 avgt 25 2045.491 ���� 52.089 ns/op CoderBM.decode_1b_d 16 avgt 25 60.797 ���� 1.455 ns/op CoderBM.decode_1b_d 64 avgt 25 192.349 ���� 1.961 ns/op CoderBM.decode_1b_d 128 avgt 25 364.714 ���� 5.104 ns/op CoderBM.decode_1b_d 1024 avgt 25 5164.228 ���� 72.871 ns/op CoderBM.decode_2b 16 avgt 25 60.026 ���� 0.947 ns/op CoderBM.decode_2b 64 avgt 25 176.283 ���� 3.041 ns/op CoderBM.decode_2b 128 avgt 25 320.565 ���� 6.471 ns/op CoderBM.decode_2b 1024 avgt 25 2324.600 ���� 47.717 ns/op CoderBM.decode_2b_d 16 avgt 25 83.520 ���� 1.458 ns/op CoderBM.decode_2b_d 64 avgt 25 273.272 ���� 5.138 ns/op CoderBM.decode_2b_d 128 avgt 25 529.118 ���� 8.066 ns/op CoderBM.decode_2b_d 1024 avgt 25 4009.080 ���� 40.577 ns/op CoderBM.decode_3b 16 avgt 25 90.600 ���� 1.110 ns/op CoderBM.decode_3b 64 avgt 25 271.089 ���� 3.854 ns/op CoderBM.decode_3b 128 avgt 25 518.080 ���� 10.487 ns/op CoderBM.decode_3b 1024 avgt 25 3849.770 ���� 135.530 ns/op CoderBM.decode_3b_d 16 avgt 25 112.736 ���� 4.619 ns/op CoderBM.decode_3b_d 64 avgt 25 376.692 ���� 4.839 ns/op CoderBM.decode_3b_d 128 avgt 25 746.886 ���� 14.594 ns/op CoderBM.decode_3b_d 1024 avgt 25 5812.793 ���� 131.102 ns/op CoderBM.encode_1b 16 avgt 25 28.480 ���� 0.765 ns/op CoderBM.encode_1b 64 avgt 25 50.390 ���� 0.921 ns/op CoderBM.encode_1b 128 avgt 25 75.633 ���� 1.730 ns/op CoderBM.encode_1b 1024 avgt 25 1134.872 ���� 21.153 ns/op CoderBM.encode_1b_d 16 avgt 25 86.910 ���� 6.641 ns/op CoderBM.encode_1b_d 64 avgt 25 328.981 ���� 21.754 ns/op CoderBM.encode_1b_d 128 avgt 25 622.159 ���� 41.565 ns/op CoderBM.encode_1b_d 1024 avgt 25 6108.166 ���� 360.201 ns/op CoderBM.encode_2b 16 avgt 25 46.654 ���� 0.675 ns/op CoderBM.encode_2b 64 avgt 25 113.075 ���� 3.347 ns/op CoderBM.encode_2b 128 avgt 25 181.821 ���� 3.170 ns/op CoderBM.encode_2b 1024 avgt 25 1155.515 ���� 13.561 ns/op CoderBM.encode_2b_d 16 avgt 25 134.463 ���� 4.264 ns/op CoderBM.encode_2b_d 64 avgt 25 483.731 ���� 19.453 ns/op CoderBM.encode_2b_d 128 avgt 25 984.608 ���� 34.332 ns/op CoderBM.encode_2b_d 1024 avgt 25 4723.584 ���� 89.975 ns/op CoderBM.encode_3b 16 avgt 25 71.780 ���� 2.511 ns/op CoderBM.encode_3b 64 avgt 25 228.089 ���� 4.989 ns/op CoderBM.encode_3b 128 avgt 25 442.122 ���� 7.545 ns/op CoderBM.encode_3b 1024 avgt 25 3255.853 ���� 68.356 ns/op CoderBM.encode_3b_d 16 avgt 25 165.805 ���� 5.055 ns/op CoderBM.encode_3b_d 64 avgt 25 602.102 ���� 17.638 ns/op CoderBM.encode_3b_d 128 avgt 25 1195.218 ���� 22.336 ns/op CoderBM.encode_3b_d 1024 avgt 25 6467.635 ���� 82.568 ns/op
02-03-2018