Skip to content
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

perf(dpp): reduce JS binding size by 3x #2396

Merged
merged 7 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,17 @@ jobs:
run: cargo binstall [email protected]
if: ${{ steps.check-artifact.outputs.exists != 'true' }}

- name: Install Binaryen
run: |
wget https://github.com/WebAssembly/binaryen/releases/download/version_121/binaryen-version_121-x86_64-linux.tar.gz -P /tmp
tar -xzf /tmp/binaryen-version_121-x86_64-linux.tar.gz -C /tmp
sudo cp -r /tmp/binaryen-version_121/* /usr/local/
if: ${{ steps.check-artifact.outputs.exists != 'true' }}

- name: Build packages
run: yarn build
env:
CARGO_BUILD_PROFILE: release

if: ${{ steps.check-artifact.outputs.exists != 'true' }}

- name: Set suffix
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/tests-build-js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ jobs:
run: cargo binstall [email protected]
if: ${{ steps.check-artifact.outputs.exists != 'true' }}

- name: Install Binaryen
run: |
wget https://github.com/WebAssembly/binaryen/releases/download/version_121/binaryen-version_121-x86_64-linux.tar.gz -P /tmp
tar -xzf /tmp/binaryen-version_121-x86_64-linux.tar.gz -C /tmp
sudo cp -r /tmp/binaryen-version_121/* /usr/local/
if: ${{ steps.check-artifact.outputs.exists != 'true' }}

- name: Build JS packages
run: yarn build
if: ${{ steps.check-artifact.outputs.exists != 'true' }}
Expand Down
2 changes: 1 addition & 1 deletion packages/wasm-dpp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ async-trait = "0.1.59"
bincode = "2.0.0-rc.3"
[profile.release]
lto = true
opt-level = 's'
opt-level = 'z'
[package.metadata.cargo-machete]
ignored = ["wasm-bindgen-futures"]
11 changes: 6 additions & 5 deletions packages/wasm-dpp/scripts/build-wasm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ fi
# EMCC_CFLAGS="-s ERROR_ON_UNDEFINED_SYMBOLS=0 --no-entry" cargo build --target=wasm32-unknown-emscripten --release
# EMCC_CFLAGS="-s ERROR_ON_UNDEFINED_SYMBOLS=0 --no-entry" wasm-bindgen --out-dir=wasm --target=web --omit-default-module-path ../../target/wasm32-unknown-emscripten/release/wasm_dpp.wasm

# TODO: Must be somehow preinstalled?
#if [ "$PROFILE" == "release" ]; then
# echo "Optimizing wasm using Binaryen"
# wasm-opt -Os "$OUTPUT_FILE" -o "$OUTPUT_FILE"
#fi
if command -v wasm-opt &> /dev/null; then
echo "Optimizing wasm using Binaryen"
wasm-opt -Oz "$OUTPUT_FILE" -o "$OUTPUT_FILE"
else
echo "wasm-opt command not found. Skipping wasm optimization."
fi
Loading