Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8238669

Long.divideUnsigned is extremely slow for certain values (Needs to be Intrinsic)

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b21
    • Verification:
      Not verified

      Description

      ADDITIONAL SYSTEM INFORMATION :
      MacOS Mojave 10.14.6
      OpenJDK 64-Bit Server VM (build 13+33, mixed mode, sharing)

      A DESCRIPTION OF THE PROBLEM :
      Long.divideUnsigned is very slow for dividend values larger than the signed maximum of Long.MAX_VALUE. 10x slow down when the dividend is larger than Long.MAX_VALUE (eg a negative signed value).

      This causes significant sporadic slow downs based on the data being processed

      Steps to reproduce:

      Using JMH... https://openjdk.java.net/projects/code-tools/jmh/

      @Benchmark public long divu64_slow(){
      return Long.divideUnsigned(Long.MAX_VALUE + 1, arg);
      }

      @Benchmark public long divu64_norm(){
      return Long.divideUnsigned(Long.MAX_VALUE, arg);
      }

      Expected Result:

      This should be just as fast or faster (some early CPUs execute IDIV faster than DIV) as java signed division. Just as important, speed should not show a 10x slow down based only slightly different dividend values.

      Performance Workaround:

      It would be very hard to meet the same performance in software as a native op provided by all modern CPUs.


        Attachments

          Issue Links

            Activity

              People

              Assignee:
              bpb Brian Burkhalter
              Reporter:
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: