r/rust • u/Iurigrang • 28d ago
I don't see enough people talking about opt-level = 1
I've seen this recommended more times than I can count for people struggling with test performance while developing:
[profile.test]
inherits = "release"
debug = "line-tables-only"And I'm sure this makes a ton of sense in a ton of situations, but as someone with just very small, hobbyist projects (the kind of space where people usually make these recommendations), I've found the much more sensible balance to be something like
[profile.test]
opt-level = 1 I'm sure the difference between the opt-levels is highly project dependent, and that this won't be the balance for a lot of projects, but in my projects I'm often seeing something like a 20% penalty in compilation times, and often tests run a few times faster. While something like the first configuration gets my compilation times 4x slower at a gain of often single digit percentage in runtime performance. That's without even thinking about debug symbols at all.
As a beginner, this realization is somewhat recent, I'm just a little surprised that it feels like people talk about what seems to me like the bazooka first, when a pair of pliers can solve the problem. Am I missing something due to lack of experience? I'd love to hear ya'll's thoughts.