cargo-contract
cargo-contract copied to clipboard
Improve incremental build times of metadata
Currently, the incremental build of metadata has some initial overhead even if no changes at all where made to the project. This seems to be rooted in the fact that on every metadata build the crates index is updated and the project is relinked in release mode:
[1/5] Building cargo project
Finished release [optimized] target(s) in 0.13s
[2/5] Post processing wasm file
[3/5] Optimizing wasm file
[4/5] Generating metadata
Updating crates.io index
Compiling metadata-gen v0.1.0 (/var/folders/8g/_rkmq65n0qnf70c41xvp174h0000gn/T/cargo-contract_XrbNqZ/.ink/metadata_gen)
Finished release [optimized] target(s) in 1.96s
Running `target/release/metadata-gen`
[5/5] Generating bundle
The reason for that is unclear but I suspect that this temporary project is created anew every time the metadata is build. I therefore propose the following two changes to speed this up:
- Do not override the metadata project every time but rather keep in in place and "rsync" with the template, instead
- Build the metadata-gen without optimizations and debug info. I suspect that the build time will outweigh the running time of the project.
The second item is more controversial. It needs some benchmarking before switching.
Yes indeed the metadata-gen
project is generated anew each time, so most likely that is the root cause.
Build the metadata-gen without optimizations and debug info. I suspect that the build time will outweigh the running time of the project.
Indeed the running time is extremely short, would be worth some experimentation there.