Fix passing -O1 to build from `cargo test` 2020-10-opt-test
authorMatt Corallo <git@bluematt.me>
Mon, 5 Oct 2020 16:47:08 +0000 (12:47 -0400)
committerMatt Corallo <git@bluematt.me>
Mon, 5 Oct 2020 18:24:41 +0000 (14:24 -0400)
In 9e03087d6acbc876a5ad1c9b9d8746bf18d5ca86 we started setting
`opt-level` only on profile.test and not profile.dev. When that
commit was authored I tested only that rustc was being called with
opt-level set in its flags, not that the resulted run ran at the
speed I expected. It seems profile.test isn't applied properly to
dependencies or so, resulting in tests running much slower than
they do at profile.dev.opt-level=1.

Cargo.toml

index 03d58b202cf39ea5526d683711cff464e04b1c10..56f4ac32f3f629c3553adb07114e21370ee1c80b 100644 (file)
@@ -5,11 +5,13 @@ members = [
     "lightning-net-tokio",
 ]
 
-# Our tests do actual crypo and lots of work, the tradeoff for -O1 is well worth it
-[profile.test]
-opt-level = 1
-
+# Our tests do actual crypo and lots of work, the tradeoff for -O1 is well worth it.
+# Ideally we would only do this in profile.test, but profile.test only applies to
+# the test binary, not dependencies, which means most of the critical code still
+# gets compiled as -O0. See
+# https://doc.rust-lang.org/cargo/reference/profiles.html#profile-selection
 [profile.dev]
+opt-level = 1
 panic = "abort"
 
 [profile.release]