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.