From 7a6dd2ae565e2f80d81bc1b39e99dbadaa3bb40c Mon Sep 17 00:00:00 2001 From: Nandor Kracser Date: Wed, 21 Jun 2023 10:50:55 +0200 Subject: [PATCH] try building a shrinked version of the tcp metadata module --- .github/workflows/acceptance-test.yaml | 2 +- .github/workflows/ci.yaml | 2 +- Makefile | 6 ++++++ experimental/wasm-tcp-metadata/README.md | 10 ++++++++-- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/.github/workflows/acceptance-test.yaml b/.github/workflows/acceptance-test.yaml index 1fa142f8..e370dee9 100644 --- a/.github/workflows/acceptance-test.yaml +++ b/.github/workflows/acceptance-test.yaml @@ -47,7 +47,7 @@ jobs: - name: Build TCP metadata exchange filter run: | - make tcp-metadata-exchange-filter + make tcp-metadata-exchange-filter-shrinked - name: Deploy to kind cluster (istio-operator) run: | diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 692225ae..2e2dc786 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -46,7 +46,7 @@ jobs: - name: Build TCP metadata exchange filter run: | - make tcp-metadata-exchange-filter + make tcp-metadata-exchange-filter-shrinked - name: Run unit tests run: make test diff --git a/Makefile b/Makefile index 48ff1202..972015e1 100644 --- a/Makefile +++ b/Makefile @@ -58,3 +58,9 @@ tcp-metadata-exchange-filter: ## build the tcp-metadata-exchange-filter rustup target add wasm32-unknown-unknown cargo build --target wasm32-unknown-unknown --release cp target/wasm32-unknown-unknown/release/wasm_tcp_metadata.wasm pkg/istio/filters/tcp-metadata-exchange-filter.wasm + +.PHONY: tcp-metadata-exchange-filter-shrinked +tcp-metadata-exchange-filter-shrinked: ## build the smaller version of tcp-metadata-exchange-filter + rustup target add wasm32-unknown-unknown + cargo +nightly build -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort -j1 --release --target wasm32-unknown-unknown + cp target/wasm32-unknown-unknown/release/wasm_tcp_metadata.wasm pkg/istio/filters/tcp-metadata-exchange-filter.wasm diff --git a/experimental/wasm-tcp-metadata/README.md b/experimental/wasm-tcp-metadata/README.md index a3373fbd..d6a4d141 100644 --- a/experimental/wasm-tcp-metadata/README.md +++ b/experimental/wasm-tcp-metadata/README.md @@ -19,6 +19,12 @@ rustup component add rust-src --toolchain nightly-aarch64-apple-darwin Optimalize the binary size of the created module even further by running: ```bash +# Install wasm-opt +cargo install wasm-opt --locked +``` + +```bash +# Optimize for size wasm-opt -Os target/wasm32-unknown-unknown/release/wasm_tcp_metadata.wasm -o target/wasm32-unknown-unknown/release/wasm_tcp_metadata.wasm ``` @@ -31,7 +37,7 @@ git clone git@github.com:istio-ecosystem/wasm-extensions.git cd wasm-extensions ``` -Now start a Bazel container (use the specified image version, other versions simply don't work on Mac, and ARM: +Now start a Bazel container (use the specified image version, other versions simply don't work on Mac, and ARM): ```bash docker run -v $PWD:/tmp/work -w /tmp/work --rm -it --entrypoint bash gcr.io/bazel-public/bazel:5.4.0 @@ -44,4 +50,4 @@ build '//extensions/stats:stats.wasm' # This takes some time if you are on an AR cp bazel-bin/extensions/stats/stats.wasm . ``` -You can find the stats.wasm now in your `wasm-extensions` working directory. +You can find the `stats.wasm` now in your `wasm-extensions` working directory.