[PATCH] Improvements in jdk.internal.org.objectweb.asm.Type
Hello, several days ago I’ve proposed some improvements into asm library: - https://gitlab.ow2.org/asm/asm/commit/ef945457bc19dbc09c02bd21b52f1950990f33... - https://gitlab.ow2.org/asm/asm/commit/9b914d524b7fe7ea694fc11ec784e67133ba38... The patches were accepted and then it turned out the code I’ve patched is similar to what we have in JDK. So I propose the same changes to be accepted into JDK 12. They improve code by using more simple constructions and replacing redundant hand-written code with JDK-provided API. As of performance, usage of String::replace instead of handwritten replacement (see Type::appendDescriptor) is much faster and memory-effective (tested with JDK 11) even on simplest class names like java.lang.String: Benchmark Mode Cnt Score Error Units CharacterReplaceBenchmark.manualReplace avgt 25 57,036 ± 1,132 ns/op CharacterReplaceBenchmark.stringReplace avgt 25 17,648 ± 0,699 ns/op CharacterReplaceBenchmark.manualReplace:·gc.alloc.rate.norm avgt 25 112,000 ± 0,001 B/op CharacterReplaceBenchmark.stringReplace:·gc.alloc.rate.norm avgt 25 56,000 ± 0,001 B/op Corresponding benchmark available here: https://github.com/stsypanov/benchmarks/blob/master/benchmark-runners/src/ma... https://github.com/stsypanov/benchmarks/blob/master/benchmark-source/src/mai... Usage of String::substring instead of StringBuilder.append(CharSequence, int, int) (see Type::getDescriptor) is also faster and memory-effective, results described here: http://mail.openjdk.java.net/pipermail/core-libs-dev/2019-January/057834.htm... Also, is there any workload to measure effect of attached patch? Regards, Sergey Tsypanov
On 06/02/2019 21:26, Сергей Цыпанов wrote:
Hello,
several days ago I’ve proposed some improvements into asm library:
- https://gitlab.ow2.org/asm/asm/commit/ef945457bc19dbc09c02bd21b52f1950990f33... - https://gitlab.ow2.org/asm/asm/commit/9b914d524b7fe7ea694fc11ec784e67133ba38...
The patches were accepted and then it turned out the code I’ve patched is similar to what we have in JDK.
So I propose the same changes to be accepted into JDK 12. They improve code by using more simple constructions and replacing redundant hand-written code with JDK-provided API. I assume the JDK will get your performance fix at the next ASM refresh. We've tried to avoid changes to ASM where possible as it complicates upgrading. There are of course times when the JDK's copy of ASM is modified to support changes to the class file before they are finalized and in a ASM release but we usually don't apply other patches unless they are really needed.
-Alan
participants (2)
-
Alan Bateman
-
Сергей Цыпанов