Skip to content

Wasmer Backend#3

Open
Robert-MacWha wants to merge 27 commits intomainfrom
wasmer-tests
Open

Wasmer Backend#3
Robert-MacWha wants to merge 27 commits intomainfrom
wasmer-tests

Conversation

@Robert-MacWha
Copy link
Copy Markdown
Owner

@Robert-MacWha Robert-MacWha commented Dec 22, 2025

  • Create worker pool to avoid initializing new wasm workers on every call
  • Pre-compile the wasm module for the browser bridge
  • Setup async transport for the host-side to avoid busy waiting
  • Make shared pipes asyncRead
  • Test wasmtime

@Robert-MacWha
Copy link
Copy Markdown
Owner Author

For reference, I backported the wasm benchmark to the main branch and ran it.

    Warming up for 3.0000 s
    Collecting 100 samples in estimated 5.4294 s (600 iterations)
    prime_sieve_small       time:   [9.0147 ms 9.0750 ms 9.1400 ms]
                            change: [−63.510% −62.667% −61.854%] (p = 0.00 < 0.05)
                            Performance has improved.
    Found 1 outliers among 100 measurements (1.00%)
      1 (1.00%) high severe
    Warming up for 3.0000 s
    Collecting 100 samples in estimated 250.43 s (100 iterations)
    prime_sieve_large       time:   [2.5124 s 2.5153 s 2.5182 s]
                            change: [+4939.9% +5424.9% +5846.7%] (p = 0.00 < 0.05)
                            Performance has regressed.
    Found 2 outliers among 100 measurements (2.00%)
      2 (2.00%) low mild
    Warming up for 3.0000 s
    Collecting 100 samples in estimated 5.0897 s (600 iterations)
    ping                    time:   [8.4130 ms 8.4561 ms 8.5089 ms]
                            change: [−83.722% −80.062% −76.639%] (p = 0.00 < 0.05)
                            Performance has improved.
    Found 7 outliers among 100 measurements (7.00%)
      1 (1.00%) high mild
      6 (6.00%) high severe
    Warming up for 3.0000 s
    Collecting 100 samples in estimated 5.9057 s (200 iterations)
    lifecycle               time:   [29.634 ms 29.888 ms 30.170 ms]
                            change: [−62.435% −52.511% −43.983%] (p = 0.00 < 0.05)
                            Performance has improved.

Results are insane. Before is wasmer, after is wasmi. The overhead of wasmer + setting up web workers is currently like +50%, which isn't great. But the compute-limited performance is actually incredible. A 5.5k% increase? Wow, I clearly need to stick with this and make it work.

@Robert-MacWha
Copy link
Copy Markdown
Owner Author

Another thing - on native:

  • prime_sieve_small: ~147 µs
  • prime_sieve_large: ~9.2 ms (Difference: ~9 ms)

And in WASM:

  • prime_sieve_small: ~46 ms
  • prime_sieve_large: ~58 ms (Difference: ~12 ms)

The compute is taking ~10ms in either case. There's just a 40ms startup cost in the wasm benchmark. Let's hope we can reduce that.

@Robert-MacWha
Copy link
Copy Markdown
Owner Author

Robert-MacWha commented Dec 25, 2025

Continued improvements. Not as much as I would have liked, but definitely acceptable. Still ~3x wasmi's lightning-fast startup times. It honestly might be worthwhile having both runtimes. But 20ms isn't that long, so maybe not. Think now I'm done and will try this in tlock to see how the revm plugin behaves, plus make sure there aren't any integration issues (didn't change up the API too much I think?).

 Failed to import previous benchmark Error("EOF while parsing a value", line: 1, column: 0)
Warming up for 3.0000 s
Collecting 100 samples in estimated 6.5139 s (200 iterations)
prime_sieve_small       time:   [29.473 ms 30.305 ms 31.237 ms]
Found 3 outliers among 100 measurements (3.00%)
  2 (2.00%) high mild
  1 (1.00%) high severe
Warming up for 3.0000 s
Collecting 100 samples in estimated 8.5232 s (200 iterations)
prime_sieve_large       time:   [40.255 ms 40.927 ms 41.641 ms]
Found 1 outliers among 100 measurements (1.00%)
  1 (1.00%) high mild
Warming up for 3.0000 s
Collecting 100 samples in estimated 5.9300 s (200 iterations)
ping                    time:   [30.538 ms 31.569 ms 32.664 ms]
Found 2 outliers among 100 measurements (2.00%)
  2 (2.00%) high mild
Warming up for 3.0000 s
Collecting 100 samples in estimated 6.7190 s (200 iterations)
lifecycle               time:   [32.440 ms 32.706 ms 33.011 ms]
Found 5 outliers among 100 measurements (5.00%)
  2 (2.00%) high mild
  3 (3.00%) high severe
Warming up for 3.0000 s
Collecting 100 samples in estimated 8.4451 s (200 iterations)
call_many               time:   [41.687 ms 42.478 ms 43.308 ms]
Found 2 outliers among 100 measurements (2.00%)
  2 (2.00%) high mild

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant