Skip to content

Commit

Permalink
Cargo.toml: Set codegen-units = 1 for release.
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 committed Nov 11, 2023
1 parent 8da7c48 commit c5017cd
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 c5017cd

Please sign in to comment.