Skip to content

Make PEP 517 profile tests more resilient to cargo profiles#2902

Merged
konstin merged 1 commit intomainfrom
konsti/pep517-tests-cargo-profiles
Dec 29, 2025
Merged

Make PEP 517 profile tests more resilient to cargo profiles#2902
konstin merged 1 commit intomainfrom
konsti/pep517-tests-cargo-profiles

Conversation

@konstin
Copy link
Copy Markdown
Member

@konstin konstin commented Dec 28, 2025

A trick for faster rust compilation from the official book is to avoid generating debug information by default (https://doc.rust-lang.org/cargo/guide/build-performance.html#reduce-amount-of-generated-debug-information).

To apply this for globally, or to use this for projects that already have a .cargo/config.toml, we can add the following to ~/.cargo/config.toml:

[profile.dev]
debug = "line-tables-only"

[profile.dev.package."*"]
debug = false

[profile.debugging]
inherits = "dev"
debug = true

or simply:

[profile.dev]
debug = false

This effect is larger for more complex projects with more dependencies, but also noticeable for maturin. On my machine, a fresh debug build goes from 14.6s to 9s, hyperfine --prepare "touch src/archive_source.rs" "cargo build" goes from 960ms to 870ms.

This breaks the PEP 517 profile test because the log message looks different:

Finished `dev` profile [unoptimized] target(s) in 8.84s

To make the test more resilient to all sorts of global profile changes, we instead check in the target directory which profiles were built.

A trick for faster rust compilation from the official book is to avoid generating debug information by default (https://doc.rust-lang.org/cargo/guide/build-performance.html#reduce-amount-of-generated-debug-information).

To apply this for globally, or to use this for projects that already have a `.cargo/config.toml`, we can add the following to `~/.cargo/config.toml`:
```toml
[profile.dev]
debug = "line-tables-only"

[profile.dev.package."*"]
debug = false

[profile.debugging]
inherits = "dev"
debug = true
```

or simply:

```toml
[profile.dev]
debug = false
```

This effect is larger for more complex projects with more dependencies, but also noticeable for maturin. On my machine, a fresh debug build goes from 14.6s to 9s, `hyperfine --prepare "touch src/archive_source.rs" "cargo build"` goes from 960ms to 870ms.

This breaks the PEP 517 profile test because the log message looks different:

```
Finished `dev` profile [unoptimized] target(s) in 8.84s
```

To make the test more resilient to all sorts of global profile changes, we instead check in the target directory which profiles were built.
@messense messense force-pushed the konsti/pep517-tests-cargo-profiles branch from ee4fed4 to ea0677d Compare December 29, 2025 13:59
@konstin
Copy link
Copy Markdown
Member Author

konstin commented Dec 29, 2025

The emscripten failure is unrelated.

@konstin konstin enabled auto-merge (squash) December 29, 2025 15:16
@konstin konstin disabled auto-merge December 29, 2025 15:16
@konstin konstin merged commit f0ba631 into main Dec 29, 2025
43 of 45 checks passed
@konstin konstin deleted the konsti/pep517-tests-cargo-profiles branch December 29, 2025 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant