Skip to content

Commit

Permalink
Small optimisation to --profile dev wasm builds (paritytech#1851)
Browse files Browse the repository at this point in the history
`wasm-builder` was adjusted to default to building wasm blobs in
`release` mode even when cargo is in `debug` because `debug` wasm is too
slow.

A side effect of this was `.compact` and `.compact.compressed` getting
built when the dev is running build in `debug`, adding ~5s to the build
time of every wasm runtime.

I think it's reasonable to assume if the dev is running `debug` build
they want to optimise speed and do not care about the size of the wasm
binary. Compacting a blob has negligible impact on its actual
performance.

In this PR, I adjusted the behavior of the wasm builder so it does not
produce `.compact` or `.compact.compressed` wasm when the user is
running in `debug`. The builder will continue to produce the bloaty wasm
in release mode unless it is overriden with an env var.

As suggested by @koute in review, also refactored the
`maybe_compact_wasm_and_copy_blobs` into multiple funuctions, and
renamed things to better support RISC-V in the future.

---

There is no `T-runtime` label so @KiChjang told me to put `T1-FRAME` :)

---------

Co-authored-by: Koute <koute@users.noreply.github.com>
  • Loading branch information
liamaharon and koute authored Oct 25, 2023
1 parent 4e54f3d commit 634fa84
Show file tree
Hide file tree
Showing 2 changed files with 190 additions and 119 deletions.
4 changes: 2 additions & 2 deletions substrate/utils/wasm-builder/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,9 @@ fn build_project(
);

let (wasm_binary, wasm_binary_bloaty) = if let Some(wasm_binary) = wasm_binary {
(wasm_binary.wasm_binary_path_escaped(), bloaty.wasm_binary_bloaty_path_escaped())
(wasm_binary.wasm_binary_path_escaped(), bloaty.bloaty_path_escaped())
} else {
(bloaty.wasm_binary_bloaty_path_escaped(), bloaty.wasm_binary_bloaty_path_escaped())
(bloaty.bloaty_path_escaped(), bloaty.bloaty_path_escaped())
};

crate::write_file_if_changed(
Expand Down
Loading

0 comments on commit 634fa84

Please sign in to comment.