yul-phaser - Man Page

manual page for yul-phaser 0.8.28

Synopsis

yul-phaser [options] <file>

Description

yul-phaser, a tool for finding the best sequence of Yul optimisation phases.

Reads <file> as Yul code and tries to find the best order in which to run optimisation phases using a genetic algorithm. Example: yul-phaser program.yul

Allowed options:

General

--help

Show help message and exit.

--input-files <PATH> Input files.

--prefix <CHROMOSOME>

Initial optimisation steps automatically applied to every input program. The result is treated as if it was the actual input, i.e. the steps are not considered a part of the chromosomes and cannot be mutated. The values of relative metric values are also relative to the fitness of a program with these steps applied rather than the fitness of the original program. Note that phaser always adds a 'hgo' prefix to ensure that chromosomes can contain arbitrary optimisation steps. This implicit prefix cannot be changed or or removed using this option. The value given here is applied after it.

--seed <NUM>

Seed for the random number generator.

--rounds <NUM>

The number of rounds after which the algorithm should stop. (default=no limit).

--mode <NAME> (=run-algorithm)

Mode of operation. The default is to run the algorithm but you can also tell phaser to do something else with its parameters, e.g. just print the optimised programs and exit.

AVAILABLE MODES:

* run-algorithm * print-optimised-programs * print-optimised-asts

Algorithm

--algorithm <NAME> (=GEWEP)

Algorithm

AVAILABLE ALGORITHMS:

* GEWEP * classic * random

--no-randomise-duplicates

By default, after each round of the algorithm duplicate chromosomes are removed fromthe population and replaced with randomly generated ones. This option disables this postprocessing.

--min-chromosome-length <NUM> (=100)

Minimum length of randomly generated chromosomes.

--max-chromosome-length <NUM> (=100)

Maximum length of randomly generated chromosomes.

--crossover <NAME> (=uniform)

Type of the crossover operator to use.

AVAILABLE CROSSOVER OPERATORS:

* single-point * two-point * uniform

--uniform-crossover-swap-chance <PROBABILITY> (=0.5)

Chance of two genes being swapped between chromosomes in uniform crossover.

Gewep Algorithm

--gewep-mutation-pool-size <FRACTION> (=0.25)

Percentage of population to regenerate using mutations in each round.

--gewep-crossover-pool-size <FRACTION> (=0.25)

Percentage of population to regenerate using crossover in each round.

--gewep-randomisation-chance <PROBABILITY> (=0.90000000000000002)

The chance of choosing gene randomisation as the mutation to perform.

--gewep-deletion-vs-addition-chance <PROBABILITY> (=0.5)

The chance of choosing gene deletion as the mutation if randomisation was not chosen.

--gewep-genes-to-randomise <PROBABILITY>

The chance of any given gene being mutated in gene randomisation. (default=1/max-chromosome-length)

--gewep-genes-to-add-or-delete <PROBABILITY>

The chance of a gene being added (or deleted) in gene addition (or deletion). (default=1/max-chromosome-length )

Classic Genetic Algorithm

--classic-elite-pool-size <FRACTION> (=0.25)

Percentage of population to regenerate using mutations in each round.

--classic-crossover-chance <FRACTION> (=0.75)

Chance of a chromosome being selected for crossover.

--classic-mutation-chance <FRACTION> (=0.01)

Chance of a gene being mutated.

--classic-deletion-chance <PROBABILITY> (=0.01)

Chance of a gene being deleted.

--classic-addition-chance <PROBABILITY> (=0.01)

Chance of a random gene being added.

Random Algorithm

--random-elite-pool-size <FRACTION>

Percentage of the population preserved in each round. (default=one individual, regardless of population size)

Population

--population <CHROMOSOMES>

List of chromosomes to be included in the initial population. You can specify multiple values separated with spaces or invoke the option multiple times and all the values will be included.

--random-population <SIZE>

The number of randomly generated chromosomes to be included in the initial population.

--population-from-file <FILE>

A text file with a list of chromosomes (one per line) to be included in the initial population.

--population-autosave <FILE>

If specified, the population is saved in the specified file after each round. (default=autosave disabled)

Metrics

--metric <NAME> (=relative-code-size)

Metric used to evaluate the fitness of a chromosome.

AVAILABLE METRICS:

* code-size * relative-code-size

--metric-aggregator <NAME> (=average)

Operator used to combine multiple fitness metric values obtained by evaluating a chromosome separately for each input program.

AVAILABLE METRIC AGGREGATORS:

* average * sum * maximum * minimum

--relative-metric-scale <EXPONENT> (=3)

Scaling factor for values produced by relative fitness metrics. Since all metrics must produce integer values, the fractional part of the result is discarded. To keep the numbers meaningful, a relative metric multiples its values by a scaling factor and this option specifies the exponent of this factor. For example with value of 3 the factor is 10^3 = 1000 and the metric will return 500 to represent 0.5, 1000 for 1.0, 2000 for 2.0 and so on. Using a bigger factor allows discerning smaller relative differences between chromosomes but makes the numbers less readable and may also lose precision if the numbers are very large.

--chromosome-repetitions <COUNT> (=1)

Number of times to repeat the sequence optimisation steps represented by a chromosome.

Metric Weights

--expression-statement-cost <COST> (=1)

--assignment-cost <COST> (=1)

--variable-declaration-cost <COST> (=1)

--function-definition-cost <COST> (=1)

--if-cost <COST> (=2)

--switch-cost <COST> (=1)

--case-cost <COST> (=2)

--for-loop-cost <COST> (=3)

--break-cost <COST> (=2)

--continue-cost <COST> (=2)

--leave-cost <COST> (=2)

--block-cost <COST> (=1)

--function-call-cost <COST> (=1)

--identifier-cost <COST> (=1)

--literal-cost <COST> (=1)

Cache

--program-cache

Enables caching of intermediate programs corresponding to chromosome prefixes. This speeds up fitness evaluation by a lot but eats tons of memory if the chromosomes are long. Disabled by default since there's currently no way to set an upper limit on memory usage but highly recommended if your computer has enough RAM.

Output

--show-initial-population

Print the state of the population before the algorithm starts.

--show-only-top-chromosome

Print only the best chromosome found in each round rather than the whole population.

--hide-round

Hide information about the current round (round number and elapsed time).

--show-cache-stats

Print information about cache size and effectiveness after each round.

--show-seed

Print the selected random seed.

Info

October 2024 yul-phaser 0.8.28