Skip to content

Commit

Permalink
docs: improve optimizer_runs documentation to be more accurate (#8875)
Browse files Browse the repository at this point in the history
improve optimizer_runs documentation
  • Loading branch information
zerosnacks committed Sep 16, 2024
1 parent 81349ed commit 41d4e54
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
6 changes: 5 additions & 1 deletion crates/cli/src/opts/build/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ pub struct CompilerArgs {
#[serde(skip)]
pub optimize: bool,

/// The number of optimizer runs.
/// The number of runs specifies roughly how often each opcode of the deployed code will be
/// executed across the life-time of the contract. This means it is a trade-off parameter
/// between code size (deploy cost) and code execution cost (cost after deployment).
/// An `optimizer_runs` parameter of `1` will produce short but expensive code. In contrast, a
/// larger `optimizer_runs` parameter will produce longer but more gas efficient code.
#[arg(long, value_name = "RUNS")]
#[serde(skip_serializing_if = "Option::is_none")]
pub optimizer_runs: Option<usize>,
Expand Down
11 changes: 10 additions & 1 deletion crates/config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,16 @@ pub struct Config {
pub offline: bool,
/// Whether to activate optimizer
pub optimizer: bool,
/// Sets the optimizer runs
/// The number of runs specifies roughly how often each opcode of the deployed code will be
/// executed across the life-time of the contract. This means it is a trade-off parameter
/// between code size (deploy cost) and code execution cost (cost after deployment).
/// An `optimizer_runs` parameter of `1` will produce short but expensive code. In contrast, a
/// larger `optimizer_runs` parameter will produce longer but more gas efficient code. The
/// maximum value of the parameter is `2**32-1`.
///
/// A common misconception is that this parameter specifies the number of iterations of the
/// optimizer. This is not true: The optimizer will always run as many times as it can
/// still improve the code.
pub optimizer_runs: usize,
/// Switch optimizer components on or off in detail.
/// The "enabled" switch above provides two defaults which can be
Expand Down

0 comments on commit 41d4e54

Please sign in to comment.