hone:optimize
Full name:
org.eolang:hone-maven-plugin:0.20.3:optimize
Description:
Converts Bytecode to Bytecode in order to make it faster.
This goal takes every .class file from the target/classes/ directory, converts it to .xmir format (which is XML representation of EO), then converts .xmir to .phi (which is 𝜑-calculus), then optimizes it via phino, and then back to .xmir and to .class. As a result, you obtain optimized Bytecode in the target/classes/ directory, which supposedly works faster than before.
The entire optimization pipeline happens inside Docker container, which is run from the image specified in the image parameter. The image may either be pulled or built locally. We recommend pulling it from the Docker Hub with the help of the pull goal. Also, we recommend deleting the image after optimization is done, with the help of the rmi goal.
Attributes:
- The goal is not marked as thread-safe and thus does not support parallel builds.
- Since version:
0.1.0. - Binds by default to the lifecycle phase:
process-classes.
Optional Parameters
| Name | Type | Since | Description |
|---|---|---|---|
<alwaysWithDocker> |
boolean |
0.17.0 |
Run without Docker even if phino is available.
If this is set to true, Docker is used even if phino is available. It is recommended to keep this parameter to false, thus making the build faster if it's possible. Default: falseUser Property: hone.always-with-docker |
<cache> |
File |
0.1.0 |
EO cache directory. User Property: hone.cache |
<classes> |
String |
0.8.0 |
Location of .class files to optimize inside the target directory.Default: classesUser Property: hone.classes |
<debug> |
boolean |
0.11.0 |
Print all commands of all Bash scripts.
If this is set to true, all our internal bash scripts will start with set -x. This will lead to very verbose output but may help debug internal issues. Default: falseUser Property: hone.debug |
<eoVersion> |
String |
0.1.0 |
EO version to use. User Property: hone.eo-version |
<excludes> |
String[] |
0.1.0 |
Exclude patterns for .class files.
An array of patterns to exclude specific Start them with User Property: hone.excludes |
<extra> |
List<String> |
0.1.0 |
List of extra rules to use for optimization, provided as YAML files. User Property: hone.extra |
<extraExtensions> |
String |
0.5.0 |
The list of all file extensions for the extra rules. Default: yml,yaml,phrUser Property: hone.extra-extensions |
<grepIn> |
String |
0.10.0 |
Grep XMIR files to rewrite.
Using this regular expression, you can filter in (include) XMIR files that need to be rewritten. It's advised to use this regex to save time. This is a good example to filter in only the files that contain filter() and map() methods: "<o>(66-69-6C-74-65-72|6D-61-70)</o> Here, 66-69-6C-74-65-72 stands for the "filter" and 6D-61-70 for the "map", in hexadecimal format. Default: .*User Property: hone.grep-in |
<image> |
String |
0.1.0 |
Docker image to use. Default: yegor256/hone:0.20.3User Property: hone.image |
<includes> |
String[] |
0.1.0 |
Include patterns for .class files.
An array of patterns to include specific Start them with User Property: hone.includes |
<jeoVersion> |
String |
0.1.0 |
JEO version to use. User Property: hone.jeo-version |
<maxCycles> |
int |
0.4.0 |
How many rewriting cycles across all rules to tolerate at maximum?
This number doesn't need to be changed. However, it may be used for debugging. The larger the number, the longer optimization might take. We pass this number to phino as the --max-depth argument. Default: 1User Property: hone.max-cycles |
<maxDepth> |
int |
0.4.0 |
How many rewriting cycles per rule to tolerate at maximum?
This number doesn't need to be changed. However, it may be used for debugging. The larger the number, the longer optimization might take. We pass this number to phino as the --max-depth argument. Default: 500User Property: hone.max-depth |
<rules> |
String |
0.1.0 |
List of built-in rules to use for optimization.
For example, "simple,b*,!abc" would include the simple rule, all rules that start with the b character, and exclude the abc rule. In order to disable them all, simply set this parameter to none. If you enable them all with "*", your code most definitely will be corrupted, because some rules are for testing purposes only. Default: noneUser Property: hone.rules |
<skip> |
boolean |
0.1.0 |
Skip the execution, if set to TRUE. Default: falseUser Property: hone.skip |
<skipIfNoClasses> |
boolean |
0.16.0 |
Skip if no .class files found. Default: trueUser Property: hone.skip-if-no-classes |
<skipPhino> |
boolean |
0.15.0 |
Skip phino entirely.
If this is set to true, phino is not executed and no rewriting happens. Default: falseUser Property: hone.skip-phino |
<smallSteps> |
boolean |
0.3.0 |
Small steps or big steps?
Small steps mode will apply one rule at a time, producing separate Default: falseUser Property: hone.small-steps |
<sudo> |
boolean |
0.1.0 |
Whether to use "sudo" when executing Docker commands. Default: falseUser Property: hone.sudo |
<target> |
File |
0.1.0 |
The "target/" directory of Maven project. Default: ${project.build.directory}User Property: hone.target |
<threads> |
int |
0.11.0 |
How many threads to use for rewriting?
By default, it's a single-threaded process. However, it may be rather slow for large projects. It is recommended to use values that are close to the number of CPUs you have on your machine. If you set this parameter to zero, the number of threads will be set to the number of CPUs on the machine. Default: 1User Property: hone.threads |
<timeout> |
int |
0.11.0 |
How many seconds to spend on each .phi file at most?
If rewriting for a file takes longer than the timeout, the file remains untouched. The timeout doesn't lead to runtime failure but only to the file processing being skipped. Default: 999User Property: hone.timeout |
Parameter Details
<alwaysWithDocker>
If this is set to true, Docker is used even if phino is available. It is recommended to keep this parameter to false, thus making the build faster if it's possible.
- Type:
boolean - Since:
0.17.0 - Required:
No - User Property:
hone.always-with-docker - Default:
false
<cache>
- Type:
java.io.File - Since:
0.1.0 - Required:
No - User Property:
hone.cache
<classes>
target directory.- Type:
java.lang.String - Since:
0.8.0 - Required:
No - User Property:
hone.classes - Default:
classes
<debug>
If this is set to true, all our internal bash scripts will start with set -x. This will lead to very verbose output but may help debug internal issues.
- Type:
boolean - Since:
0.11.0 - Required:
No - User Property:
hone.debug - Default:
false
<eoVersion>
- Type:
java.lang.String - Since:
0.1.0 - Required:
No - User Property:
hone.eo-version
<excludes>
An array of patterns to exclude specific .class files from optimization. If not specified, no .class files will be excluded.
Start them with "/target/classes".
- Type:
java.lang.String[] - Since:
0.1.0 - Required:
No - User Property:
hone.excludes
<extra>
- Type:
java.util.List<java.lang.String> - Since:
0.1.0 - Required:
No - User Property:
hone.extra
<extraExtensions>
- Type:
java.lang.String - Since:
0.5.0 - Required:
No - User Property:
hone.extra-extensions - Default:
yml,yaml,phr
<grepIn>
Using this regular expression, you can filter in (include) XMIR files that need to be rewritten. It's advised to use this regex to save time. This is a good example to filter in only the files that contain filter() and map() methods:
"<o>(66-69-6C-74-65-72|6D-61-70)</o>
Here, 66-69-6C-74-65-72 stands for the "filter" and 6D-61-70 for the "map", in hexadecimal format.
- Type:
java.lang.String - Since:
0.10.0 - Required:
No - User Property:
hone.grep-in - Default:
.*
<image>
- Type:
java.lang.String - Since:
0.1.0 - Required:
No - User Property:
hone.image - Default:
yegor256/hone:0.20.3
<includes>
An array of patterns to include specific .class files for optimization. If not specified, all .class files will be included.
Start them with "/target/classes".
- Type:
java.lang.String[] - Since:
0.1.0 - Required:
No - User Property:
hone.includes
<jeoVersion>
- Type:
java.lang.String - Since:
0.1.0 - Required:
No - User Property:
hone.jeo-version
<maxCycles>
This number doesn't need to be changed. However, it may be used for debugging. The larger the number, the longer optimization might take. We pass this number to phino as the --max-depth argument.
- Type:
int - Since:
0.4.0 - Required:
No - User Property:
hone.max-cycles - Default:
1
<maxDepth>
This number doesn't need to be changed. However, it may be used for debugging. The larger the number, the longer optimization might take. We pass this number to phino as the --max-depth argument.
- Type:
int - Since:
0.4.0 - Required:
No - User Property:
hone.max-depth - Default:
500
<rules>
For example, "simple,b*,!abc" would include the simple rule, all rules that start with the b character, and exclude the abc rule.
In order to disable them all, simply set this parameter to none.
If you enable them all with "*", your code most definitely will be corrupted, because some rules are for testing purposes only.
- Type:
java.lang.String - Since:
0.1.0 - Required:
No - User Property:
hone.rules - Default:
none
<skip>
- Type:
boolean - Since:
0.1.0 - Required:
No - User Property:
hone.skip - Default:
false
<skipIfNoClasses>
- Type:
boolean - Since:
0.16.0 - Required:
No - User Property:
hone.skip-if-no-classes - Default:
true
<skipPhino>
If this is set to true, phino is not executed and no rewriting happens.
- Type:
boolean - Since:
0.15.0 - Required:
No - User Property:
hone.skip-phino - Default:
false
<smallSteps>
Small steps mode will apply one rule at a time, producing separate .phi files. This may be useful for debugging the rules. To the contrary, big steps mode will apply all rules at once, which is faster but less transparent for debugging.
- Type:
boolean - Since:
0.3.0 - Required:
No - User Property:
hone.small-steps - Default:
false
<sudo>
- Type:
boolean - Since:
0.1.0 - Required:
No - User Property:
hone.sudo - Default:
false
<target>
- Type:
java.io.File - Since:
0.1.0 - Required:
No - User Property:
hone.target - Default:
${project.build.directory}
<threads>
By default, it's a single-threaded process. However, it may be rather slow for large projects. It is recommended to use values that are close to the number of CPUs you have on your machine.
If you set this parameter to zero, the number of threads will be set to the number of CPUs on the machine.
- Type:
int - Since:
0.11.0 - Required:
No - User Property:
hone.threads - Default:
1
<timeout>
If rewriting for a file takes longer than the timeout, the file remains untouched. The timeout doesn't lead to runtime failure but only to the file processing being skipped.
- Type:
int - Since:
0.11.0 - Required:
No - User Property:
hone.timeout - Default:
999