• 0.14.2
  • $dateFormat.applyPattern("yyyy-MM-dd'T'hh:mm:ss'Z'")

hone:optimize

Full name:

org.eolang:hone-maven-plugin:0.14.2: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
<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: classes
User 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: false
User 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 .class files from optimization. If not specified, no .class files will be excluded.

Start them with "/target/classes".


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,phr
User 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.14.2
User Property: hone.image
<includes> String[] 0.1.0 Include patterns for .class files.

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".


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: 1
User 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: 500
User 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: none
User Property: hone.rules
<skip> boolean 0.1.0 Skip the execution, if set to TRUE.
Default: false
User Property: hone.skip
<smallSteps> boolean 0.3.0 Small steps or big steps?

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.


Default: false
User Property: hone.small-steps
<sudo> boolean 0.1.0 Whether to use "sudo" when executing Docker commands.
Default: false
User 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: 1
User 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: 999
User Property: hone.timeout

Parameter Details

<cache>

EO cache directory.
  • Type: java.io.File
  • Since: 0.1.0
  • Required: No
  • User Property: hone.cache

<classes>

Location of .class files to optimize inside the target directory.
  • Type: java.lang.String
  • Since: 0.8.0
  • Required: No
  • User Property: hone.classes
  • Default: classes

<debug>

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.

  • Type: boolean
  • Since: 0.11.0
  • Required: No
  • User Property: hone.debug
  • Default: false

<eoVersion>

EO version to use.
  • Type: java.lang.String
  • Since: 0.1.0
  • Required: No
  • User Property: hone.eo-version

<excludes>

Exclude patterns for .class files.

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>

List of extra rules to use for optimization, provided as YAML files.
  • Type: java.util.List<java.lang.String>
  • Since: 0.1.0
  • Required: No
  • User Property: hone.extra

<extraExtensions>

The list of all file extensions for the extra rules.
  • Type: java.lang.String
  • Since: 0.5.0
  • Required: No
  • User Property: hone.extra-extensions
  • Default: yml,yaml,phr

<grepIn>

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.

  • Type: java.lang.String
  • Since: 0.10.0
  • Required: No
  • User Property: hone.grep-in
  • Default: .*

<image>

Docker image to use.
  • Type: java.lang.String
  • Since: 0.1.0
  • Required: No
  • User Property: hone.image
  • Default: yegor256/hone:0.14.2

<includes>

Include patterns for .class files.

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>

JEO version to use.
  • Type: java.lang.String
  • Since: 0.1.0
  • Required: No
  • User Property: hone.jeo-version

<maxCycles>

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.

  • Type: int
  • Since: 0.4.0
  • Required: No
  • User Property: hone.max-cycles
  • Default: 1

<maxDepth>

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.

  • Type: int
  • Since: 0.4.0
  • Required: No
  • User Property: hone.max-depth
  • Default: 500

<rules>

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.

  • Type: java.lang.String
  • Since: 0.1.0
  • Required: No
  • User Property: hone.rules
  • Default: none

<skip>

Skip the execution, if set to TRUE.
  • Type: boolean
  • Since: 0.1.0
  • Required: No
  • User Property: hone.skip
  • Default: false

<smallSteps>

Small steps or big steps?

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>

Whether to use "sudo" when executing Docker commands.
  • Type: boolean
  • Since: 0.1.0
  • Required: No
  • User Property: hone.sudo
  • Default: false

<target>

The "target/" directory of Maven project.
  • Type: java.io.File
  • Since: 0.1.0
  • Required: No
  • User Property: hone.target
  • Default: ${project.build.directory}

<threads>

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.

  • Type: int
  • Since: 0.11.0
  • Required: No
  • User Property: hone.threads
  • Default: 1

<timeout>

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.

  • Type: int
  • Since: 0.11.0
  • Required: No
  • User Property: hone.timeout
  • Default: 999