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

ci: Track wasm size over time #4568

Merged
merged 3 commits into from
Dec 14, 2023
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
37 changes: 36 additions & 1 deletion nix/all-engines.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ in

buildInputs = [ pkgs.openssl.out ];
nativeBuildInputs = with pkgs; [
cargo
rustToolchain
SevInf marked this conversation as resolved.
Show resolved Hide resolved
git # for our build scripts that bake in the git hash
protobuf # for tonic
openssl.dev
Expand Down Expand Up @@ -114,4 +114,39 @@ in
'';
})
{ profile = "release"; };

packages.query-engine-wasm = lib.makeOverridable
({ profile }: stdenv.mkDerivation {
name = "query-engine-wasm";
inherit src;
inherit (self'.packages.prisma-engines) buildInputs configurePhase dontStrip;

nativeBuildInputs = self'.packages.prisma-engines.nativeBuildInputs ++ (with pkgs; [wasm-pack wasm-bindgen-cli jq binaryen]);

buildPhase = ''
cd query-engine/query-engine-wasm
HOME=$(mktemp -dt wasm-pack-home-XXXX) WASM_BUILD_PROFILE=${profile} ./build.sh
'';

installPhase = ''
cp -r pkg $out
'';
})
{ profile = "release"; };

packages.query-engine-wasm-gz = lib.makeOverridable
({ profile }: stdenv.mkDerivation {
name = "query-engine-wasm-gz";
inherit src;

buildPhase = ''
gzip -cn ${self'.packages.query-engine-wasm}/query_engine_bg.wasm > query_engine_bg.wasm.gz
'';

installPhase = ''
mkdir -p $out
cp query_engine_bg.wasm.gz $out/
'';
})
{ profile = "release"; };
}
4 changes: 3 additions & 1 deletion nix/publish-engine-size.nix
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@

${self'.packages.update-engine-size}/bin/update-engine-size \
${self'.packages.query-engine-bin-and-lib}/bin/query-engine \
${self'.packages.query-engine-bin-and-lib}/lib/libquery_engine.node
${self'.packages.query-engine-bin-and-lib}/lib/libquery_engine.node \
${self'.packages.query-engine-wasm-gz}/query_engine_bg.wasm.gz \
${self'.packages.query-engine-wasm}/query_engine_bg.wasm

git add "$CSV_PATH"
git commit --quiet -m "update engines size for $CURRENT_COMMIT_SHORT"
Expand Down
14 changes: 8 additions & 6 deletions query-engine/query-engine-wasm/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ OUT_JSON="${OUT_FOLDER}/package.json"
OUT_TARGET="bundler"
OUT_NPM_NAME="@prisma/query-engine-wasm"

# use `wasm-pack build --release` on CI only
if [[ -z "${BUILDKITE:-}" ]] && [[ -z "${GITHUB_ACTIONS:-}" ]]; then
BUILD_PROFILE="--dev"
else
BUILD_PROFILE="--release"
if [[ -z "${WASM_BUILD_PROFILE:-}" ]]; then
SevInf marked this conversation as resolved.
Show resolved Hide resolved
# use `wasm-pack build --release` by default on CI only
if [[ -z "${BUILDKITE:-}" ]] && [[ -z "${GITHUB_ACTIONS:-}" ]]; then
WASM_BUILD_PROFILE="dev"
else
WASM_BUILD_PROFILE="release"
fi
fi

# Check if wasm-pack is installed
Expand All @@ -25,7 +27,7 @@ then
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
fi

wasm-pack build $BUILD_PROFILE --target $OUT_TARGET --out-name query_engine
wasm-pack build "--$WASM_BUILD_PROFILE" --target $OUT_TARGET --out-name query_engine

sleep 1

Expand Down