Debug build performance

I write raytracer in rust and I notice that debug performance is 100 times slower then release performance which contradict my expectation 2 to 4 times.
I use nalgebra as linear algebra lib which I suspect that can cause the problem.
What do you think can cause such huge difference, what you will propose to me to increase debug performance (like build flags)

These are the default optimization levels:

[profile.dev]
opt-level = 0

[profile.release]
opt-level = 3

You can add them and change the dev opt-level to 1 or 2 to get somewhat better performance for somewhat slower compilation.

1 Like

This might also help you: https://users.rust-lang.org/t/cargo-build-dependencies-in-release-current-crate-in-debug

Edit: Just noticed the thread is quite old, the official docs are now at Profiles - The Cargo Book

1 Like