Skip to content

Unoptimized WASM output #292

Description

@guest271314

Here's the source code I used

import { readSync } from "node:fs";
const buffer = new Uint8Array(32);
readSync(0, buffer,  0, buffer.length );
process.stdout.write(buffer);

Here's the compilation command

SCRIPTC_NO_CACHE=1 SCRIPTC_CC=zigcc SCRIPTC_TARGET=wasm32-wasi bun x scriptc build hello.ts --keep-c --optimization release -o hello.wasm >/dev/null

Now, that spits out a 1.8 MiB WASM binary.

However, if I then do wasm2wat then wat2wasm starting with that same hello.wasm file, I get a 565.3 KiB WAT file and then a 53.1 KiB WASM file.

wabt-1.0.41/bin/wasm2wat hello.wasm -o hello.wat
wabt-1.0.41/bin/wat2wasm hello.wat -o hello1.wasm

Using wasm-opt directly on the hello.wasm file I get down to 46.9 KiB

wasm-opt hello.wasm -Os --strip-debug --vacuum -o hello2.wasm

Two questions arise for me:

  1. How to determine if QuickJS NG is embedded in the resulting WASM binary?
  2. How to optimize the WASM binary output so that is roughly matches the output of wasm-opt?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions