On 2021-01-09 Brett Okken wrote:
> This would seem to be a potential candidate for a multi-release
> jar[1], if you can figure out a reasonable way to get a build system
> to generate one.

I suppose it can be done. The build system uses Apache Ant. From some
sources I've understood that there are more modern alternatives but I
haven't had any interest or energy to learn more as Ant seems to still
work OK.

> The 4 uses I found of comparing byte[] could be refactored to call a
> new utility class to do the comparison. The "regular" implementation
> could be java 7 compatible, and the jdk 9 version would be in the
> META_INF folder.
> Even for the java 7 compatible version, it might be worth exploring
> how much improvement would come from using Unsafe to read int or long
> values from the byte[] and compare those.
> 
> For Hash234, I would think the whole class could be handled for the

All these sound like worth checking out.

On 2021-01-09 Brett Okken wrote:
> Here is a class which is compatible with jdk 7. It will use a
> MethodHandle to invoke Arrays.mismatch if that is found at runtime. If
> that is not found, it will see if it can find Unsafe to read 4 bytes
> at a time and compare as ints. If that cannot be found/loaded/invoked,
> it falls back to iterating over bytes and comparing one by one.
> 
> For jdk 9, the mismatch method could instead be implemented as:
> return Arrays.mismatch(a, aFromIndex, aFromIndex + length, b,
> bFromIndex, bFromIndex + length);

Thanks! There are several XZ Utils related tasks I hope to get done (of
which not all have been mentioned on xz-devel), so I won't think much
about XZ for Java in the near future, I'm sorry.

I assume that multi-release method has no performance overhead since
the runtime will load the best .class file and that's it. How the other
methods like using an utility class or looking for available methods at
runtime compare to pure multi-release method in terms of performance?
Perhaps this is a stupid question but I have so little Java experience
that I don't have a clue about this.

If you have time and interest, it would be valuable to know which
tricks provide the largest performance improvements. However, I repeat
that I cannot spend much time on this in the near future even though I
think it would be good to have such improvements in XZ for Java.

Thanks!

-- 
Lasse Collin  |  IRC: Larhzu @ IRCnet & Freenode

Reply via email to