WebAssembly / WebAssembly/spec

The reference interpreter became up to 20 times slower after a87fffc

Open
#1,979 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
WebAssembly
Stars
3.5k
Forks
539
Avg merge
2d 1h
Merged PRs (30d)
13

Description

While experimenting with the reference interpreter on binaries produced by Kotlin, I noticed a huge performance degradation.
It seems it is due to some changes introduced in a87fffc.

To reproduce it, please run a wasm file index.wasm.zip in reference interpreter with the following command:

'wasm' index.wasm -t -e '(module instance) (invoke "_initialize") (invoke "runBoxTest")'

Here are some runs with different versions:

a87fffc

$ time '_build/a8/wasm.exe' index.wasm -t -e '(module instance) (invoke "_initialize") (invoke "runBoxTest")'
-- Running ("(input \"index.wasm\")")...
-- Parsing...
-- Running...
-- Loading (index.wasm)...
-- Decoding...
-- Running...
-- Decoding...
-- Checking...
-- Running ("(module instance) (invoke \"_initialize\") (invoke \"runBoxTest\")")...
-- Parsing...
-- Running...
-- Initializing...
-- Invoking function "_initialize"...
-- Invoking function "runBoxTest"...
1 : [i32]
'a8/wasm.exe'  -t -e   12.65s user 1.27s system 97% cpu 14.212 total

d0eee4a

$ time '_build/d0/wasm.exe' index.wasm -t -e '(module instance) (invoke "_initialize") (invoke "runBoxTest")'
-- Running ("(input \"index.wasm\")")...
-- Parsing...
-- Running...
-- Loading (index.wasm)...
-- Decoding...
-- Running...
-- Decoding...
-- Checking...
-- Running ("(module instance) (invoke \"_initialize\") (invoke \"runBoxTest\")")...
-- Parsing...
-- Running...
-- Initializing...
-- Invoking function "_initialize"...
-- Invoking function "runBoxTest"...
1 : [i32]
'_build/d0/wasm.exe'  -t -e   0.65s user 0.02s system 73% cpu 0.919 total

d79e5c8

$ time '_build/d7/wasm.exe' index.wasm -t -e '(module instance) (invoke "_initialize") (invoke "runBoxTest")'
-- Running ("(input \"index.wasm\")")...
-- Parsing...
-- Running...
-- Loading (index.wasm)...
-- Decoding...
-- Running...
-- Decoding...
-- Checking...
-- Running ("(module instance) (invoke \"_initialize\") (invoke \"runBoxTest\")")...
-- Parsing...
-- Running...
-- Initializing...
-- Invoking function "_initialize"...
-- Invoking function "runBoxTest"...
1 : [i32]
'_build/d7/wasm.exe'  -t -e   0.65s user 0.02s system 78% cpu 0.860 total

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

Use the provided index.wasm and the shown wasm command as the reproduction entry point. Compare builds at a87fffc, d0eee4a, and d79e5c8, then profile or bisect the regression. Done means the reference interpreter no longer shows the reported slowdown while preserving the command's result, 1 : [i32].

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
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.