Skip to content

Build Profiles

Many Rust Build Profiles are defined to optimize for different use cases.

Flowchart

As a general rule of thumb for what option to use, you can follow:

graph LR
    Start((**Start**)) --> Release("`
        Final Release?
        <small>(Slow compilation)</small>
    `")
    Release --> |No| UseDevelop([_develop_])
    Release --> |Yes| Flavor(Optimizing for)
    Flavor --> |Speed| Speed("`
        Best size and speeds?
        <small>(slowest compilation)</small>
    `")
    Flavor --> |Size| Size("`
        Smallest binary
        <small>(slower compilation)</small>
    `")
    Speed --> |No| UseFast([_fast_])
    Speed --> |Yes| UseFastest([_fastest_])
    Size --> |No| UseSmall([_small_])
    Size --> |Yes| UseSmallest([_smallest_])

Suggestion: Always use smallest for releases, plenty fast and portable 😉

Usage

project.build.profile = "fast"
pyaket build --profile fast
cargo build --profile fast

Benchmarks

Tests are made with this script, measuring:

  • Size: Base compiled binary size, only including the uv runtime.
  • Startup: Overhead until the python interpreter is called1.
  • Cold: Time to build without any prior cargo build cache.
  • Warm: Time to rebuild after a prior cargo build cache exists.

Apple

aarch64-apple-darwin

ProfileSizeStartupColdWarm
develop45.11 MB15.4 ms99.2 s11.2 s
fast33.78 MB10.9 ms183.5 s118.7 s
fastest29.88 MB10.3 ms290.1 s225.4 s
small29.69 MB11.1 ms113.3 s67.5 s
smallest23.23 MB10.7 ms190.1 s145.2 s

System: Macbook M2 Pro

Linux

x86_64-unknown-linux-gnu

ProfileSizeStartupColdWarm
develop59.03 MB32.2 ms65.7 s8.7 s
fast45.10 MB25.1 ms158.3 s100.7 s
fastest40.54 MB24.1 ms255.2 s198.7 s
small36.87 MB28.2 ms98.8 s57.1 s
smallest29.74 MB26.0 ms170.0 s132.3 s

System: Ryzen 9 5900X, 2x3200 MT/s DDR4 CL16 2Rx8


  1. Difference between system's python -c '' and pyaket -c ''