Skip to content

Commit

Permalink
Cargo.toml: Set codegen-units = 1 for release (#563)
Browse files Browse the repository at this point in the history
This significantly improves code generation and optimization. In C,
translation units correspond to each `*.c` file, and thus things are
deliberately grouped together. In Rust, codegen units are chosen with a
heuristic and functions are assigned to a codegen unit (passed to LLVM).
Thus, to ensure related functions are in the same codegen unit (and are
thus inlineable), we should set this to 1. This will also make
optimization much more reliable, since a far away change can't suddenly
affect an optimization elsewhere.

We probably also want to look at enabling LTO (though we'll need to
enable LTO for `dav1d` for equivalent comparisons).
  • Loading branch information
kkysen authored Nov 11, 2023
2 parents b8c9b8e + c5017cd commit 6a37eb6
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,6 @@ bitdepth_16 = []
# unless we enable the basic optimizations (`opt-level = 1`),
# which don't increase compile-time that much.
opt-level = 1

[profile.release]
codegen-units = 1

0 comments on commit 6a37eb6

Please sign in to comment.