I using Substrate-template-node
to build pallet and my laptop have Core-i7 chip, but the time to build is range from 9-12 minutes. So, when I change code and have to wait to build and run.
So, my question is Is there anyway to build faster?
Substrate and Polkadot Stack Exchange is a question and answer site for developers building blockchains with the Substrate SDK. It only takes a minute to sign up.
Sign up to join this communitySome answers recommend to build with --release
or with a production profile. But this misses the point of the original question. If you do this the build will actually take longer due to a number of additional optimizations that are applied!
You should consider the difference between using cargo build
and cargo check
:
This will essentially compile the packages without performing the final step of code generation, which is faster than running cargo build.
(from the cargo-check
docs)
So if you e.g. just want to check for compiler errors cargo check
is already sufficient.
If you're really in need for faster binary builds then having a beefy remote machine on which you execute the build via cargo-remote
can be an option. There are also reports that using a local sccache
installation + setting the environment variable RUSTC_WRAPPER="sccache"
speeds this process up due to the additional caching done through sccache
.
If you are building a pallet testing just the pallet instead of building the entire thing is better. Just run cargo check -p your_pallet_name
.
cargo test -p your_pallet_name
would run just your pallets tests.
Mar 30, 2022 at 12:47
cargo build --profile production
then you will appreciate how much fastercargo build --release
is.SKIP_WASM_BUILD
can be used to only build the code in native mode. Which OS are you using? Different linkers can help a bit. An AMD 5950x can help a lot.cargo check
that can be done first which is a lot faster, and faster still if you're in the directory of the pallet as it has less to build.cargo build --profile production
:error: profile 'production' is not defined