-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add .cargo/config.toml with rustflags = -O to optimize test runtimes #3045
Conversation
Some of the jobs are slower, but they should be faster once our build cache has cached an optimised build. |
It looks like we're going over 75 minutes for Windows. That's because we're optimising a whole bunch of code we don't use much in the tests. I'll try with optimisation level 1 now ( We can also restrict the optimisation to just the halo2 crate. But I'm not sure how we automatically optimise its dependencies as well. https://doc.rust-lang.org/cargo/reference/config.html#profilenamepackagename |
The stateful tests will override these settings, because environmental variables take precedence over configs: So they'll continue to build with the higher optimisation level. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think turning on optimisations is going to work. We've tried optimisation levels 1 & 2, and they both make the builds much longer.
Let's serialize the generated proofs instead.
We can use the Halo2Proof
consensus serialization format, which is implemented here:
zebra/zebra-chain/src/primitives/proofs/halo2.rs
Lines 25 to 29 in 02526c3
impl ZcashSerialize for Halo2Proof { | |
fn zcash_serialize<W: io::Write>(&self, writer: W) -> Result<(), io::Error> { | |
zcash_serialize_bytes(&self.0, writer) | |
} | |
} |
Here's how we load data from a hex-encoded file in a lazy_static!
block:
zebra/zebra-test/src/vectors/block.rs
Lines 246 to 248 in 02526c3
pub static ref BLOCK_MAINNET_GENESIS_BYTES: Vec<u8> = | |
<Vec<u8>>::from_hex(include_str!("block-main-0-000-000.txt").trim()) | |
.expect("Block bytes are in valid hex representation"); |
Then we can deserialize typed data using code like:
zebra/zebrad/src/components/mempool/tests/vector.rs
Lines 370 to 372 in 0960e4f
let genesis_block: Arc<Block> = zebra_test::vectors::BLOCK_MAINNET_GENESIS_BYTES | |
.zcash_deserialize_into() | |
.unwrap(); |
The serialization should be the reverse of these steps, let me know if you have any trouble!
Motivation
When writing tests for #2645 , I created some tests that took over 5 minutes to run. When run with the rustc
-O
flag, they take ~30 seconds to run.Solution
Add a
.cargo/config.toml
config file to provide-O
as the rust flags for all compilations for our builds by default.Review
@jvff @teor2345