This Apache Maven plugin may optimize
your Bytecode
after compilation, to make it work faster.
Just add this to your pom.xml
file
(you must have Docker installed too):
<project>
[..]
<build>
<plugins>
<plugin>
<groupId>org.eolang</groupId>
<artifactId>hone-maven-plugin</artifactId>
<version>0.0.29</version>
<executions>
<execution>
<goals>
<goal>build</goal>
<goal>optimize</goal>
<goal>rmi</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
The plugin will do exactly the following:
- Take Bytecode
.class
files from thetarget/classes/
directory and copy all of them to thetarget/classes-before-hone/
directory (as a backup). - Using jeo-maven-plugin,
transform
.class
files to.xmir
format, which is EO in XML, and place them into thetarget/generated-sources/jeo-disassemble/
directory. - Using eo-maven-plugin,
convert
.xmir
files to.phi
files with π-calculus expressions, and place them into thetarget/generated-sources/phi/
directory. - Using normalizer,
apply a number of optimizations to π-calculus expressions in the
.phi
files and place new.phi
files into thetarget/generated-sources/phi-optimized/
directory. - Using eo-maven-plugin,
convert
.phi
files back to.xmir
files and place them into thetarget/generated-sources/unphi/
directory. - Using jeo-maven-plugin,
transform
.xmir
files back to Bytecode and place.class
files into thetarget/classes/
directory.
The effect of the plugin should be performance-positive (your code should work faster) along with no functionality degradation (your code should work exactly the same as it worked before optimizations). If any of these is not true, submit a ticket, we will try to fix.
Here is the result of the latest processing of a large Java class from JNA:
Input: com/sun/jna/Pointer.class
Size of .class: 22Kb (22Kb bytes)
Size of .xmir after disassemble: 1Mb (1Mb bytes, 29568 lines)
Size of .phi: 627Kb (627Kb bytes, 13486 lines)
Size of .xmir after unphi: 5Mb (5Mb bytes, 130843 lines)
Optimization time: 33min (1987884 ms)
jeo-maven-plugin:unroll-phi 1827.34 92.06%
eo-maven-plugin:xmir-to-phi 137.867 6.95%
eo-maven-plugin:phi-to-xmir 15.644 0.79%
jeo-maven-plugin:disassemble 1.926 0.10%
exec-maven-plugin:exec 1.679 0.08%
jeo-maven-plugin:assemble 0.46 0.02%
The results were calculated in this GHA job on 2025-01-21 at 13:18, on Linux with 4 CPUs.
Here is the result of the latest optimization of itself:
wrap-bytes.xsl 1588 27.56%
wrap-method-calls.xsl 1535 26.64%
normalize-bytes.xsl 1373 23.83%
atoms-with-bound-attrs.xsl 1266 21.97%
The results were calculated in this GHA job, on 2025-01-21 at 12:52, on Linux with 4 CPUs. For the sake of brevity, we show only the first 16 lines.
Fork repository, make changes, then send us
a pull request.
We will review your changes and apply them to the master
branch shortly,
provided they don't violate our quality standards. To avoid frustration,
before sending us your pull request please run full Maven build:
mvn clean install -Pqulice
You will need Maven 3.3+, Java 11+, and Docker installed.
The versions of EO and
JEO,
that we use, are defined in the in-docker-pom.xml
file.