Crate2nix: Setting `codegenUnits` for all crates

I finally got around to attempting a benchmark using the fhir-sdk crate (one that I’ve been working with which consistently takes up a majority of the build time).

Unless I’ve somehow set codegen-units wrong (all I’m doing is setting the RUSTFLAGS environment variable to -Ccodegen-units=a number), increasing codegen-units beyond 1 actually makes the build slower.

All testing was performed on an AWS Graviton4 CPU with 16 cores allocated with Rust 1.81.0. Results are as follows:

  • 1 codegen unit: 34m 3s
  • 10 codegen units: 39m 6s
  • 16 codegen units: 40m 3s

Even setting -Zthreads=16 on a Nightly compiler had a negative effect.

More details are viewable at feat: nix flake for compiler benchmarking · drakon64/fhir-sdk@ac79c86 · GitHub.