Skip to content

Bazel's wasm execution seems extremely slow #26975

@dzbarsky

Description

@dzbarsky

Description of the bug:

I needed to parse toml to json in a ruleset I was writing. I tried using wasm and noticed the runtime was around 10-20x slower than the python implementation. Standalone repro: https://github.com/dzbarsky/wasm-repro

Initial python implementation takes around 95ms to parse the file:

➜  wasm-repro git:(main) time python convert.py
{"package": [{"name"
94.03276443481445 ms
python convert.py  0.12s user 0.02s system 77% cpu 0.174 total

The wasm module takes 23ms when loaded into wazero, a different wasm runtime.

➜  wasm-repro git:(main) go build .
➜  wasm-repro git:(main) time ./wasm-repro     
2025/09/12 10:50:38 instantiate 78.14025ms
2025/09/12 10:50:38 {"package":[{"name":...
2025/09/12 10:50:38 convert time 23.9705ms
./wasm-repro  0.11s user 0.02s system 39% cpu 0.320 total

It takes 3 seconds when run via bazel's repository_ctx.execute_wasm:

➜  wasm-repro git:(main) time bazel build @wasm-repro//... --profile=/tmp/profile.json
DEBUG: /Users/dzbarsky/wasm-repro/convert.bzl:4:10: loading
DEBUG: /Users/dzbarsky/wasm-repro/convert.bzl:7:10: executing
DEBUG: /Users/dzbarsky/wasm-repro/convert.bzl:12:10: {"package":[{"name":...
DEBUG: /Users/dzbarsky/wasm-repro/convert.bzl:13:10: done
ERROR: <builtin>: fetching convert rule //:+_repo_rules+wasm-repro: java.io.IOException: convert rule //:+_repo_rules+wasm-repro must create a directory
ERROR: convert rule //:+_repo_rules+wasm-repro must create a directory
INFO: Elapsed time: 3.295s
INFO: 0 processes.
ERROR: Build did NOT complete successfully
bazel build @wasm-repro//... --profile=/tmp/profile.json  0.03s user 0.06s system 2% cpu 3.642 total
Image

Which category does this issue belong to?

No response

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

No response

Which operating system are you running Bazel on?

No response

What is the output of bazel info release?

No response

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse HEAD ?


If this is a regression, please try to identify the Bazel commit where the bug was introduced with bazelisk --bisect.

No response

Have you found anything relevant by searching the web?

No response

Any other information, logs, or outputs that you want to share?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2We'll consider working on this in future. (Assignee optional)help wantedSomeone outside the Bazel team could own thisteam-PerformanceIssues for Performance teamstype: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions