WebAssembly / WebAssembly/binaryen

wasp-opt makes bcrypt code slower

Open
#5,088 15 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
WebAssembly
Stars
8.6k
Forks
885
Avg merge
1d 19h
Merged PRs (30d)
69

Description

I'm not sure if this is issues you want to receive, but I ran into this and thought that it could be good to report. Feel free to close this if this is not relevant.

I'm compiling Openwall's BCrypt implementation into WASM with clang. I'm compiling with -O3 and -flto. Right out from clang I get the following performance:

wasm Openwall x 4.11 ops/sec ±0.13% (15 runs sampled)

When I then run wasm-opt --enable-bulk-memory -O3 on the resulting wasm file, the performance decreases:

wasm Openwall2 x 3.73 ops/sec ±0.06% (14 runs sampled)

I get the same results when passing -O4 to wasm-opt.

You can find my project here:

https://github.com/LinusU/cwasm-openwall-bcrypt

There is a Dockerfile that builds the entire project, so it's easy to experiment with passing different flags to clang. I'm using the lines below to add and run wasm-opt. Do note that these needs to be added after the clang invocation, since clang will automatically invoke wasm-opt if it's present in the path.

RUN curl -L https://github.com/WebAssembly/binaryen/releases/download/version_110/binaryen-version_110-x86_64-linux.tar.gz | tar xzk --strip-components=1 -C /
RUN wasm-opt --enable-bulk-memory -O3 bcrypt.wasm -o bcrypt.wasm

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the Dockerfile workflow with the reported wasm-opt --enable-bulk-memory -O3 command and compare its performance with the clang-produced wasm. Use the reported bcrypt.wasm input and optimization flags to isolate the slowdown. Done means identifying and addressing the optimization regression, with performance results showing the optimized output is not slower.

Written by the indexing model from the issue text.

Assessment

Tech stack
wasm
Domain
compilers, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.