Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance of React SSR #57

Closed
manuschillerdev opened this issue May 25, 2022 · 4 comments
Closed

Performance of React SSR #57

manuschillerdev opened this issue May 25, 2022 · 4 comments

Comments

@manuschillerdev
Copy link

Although the React App is very small, the performance of rendering it via wasmedge-quickjs is rather slow, compared to rendering it via a local node process:

# macbook pro 2019, i7, 32GB RAM
❯ hyperfine "wasmedge --dir .:. ../../target/wasm32-wasi/release/wasmedge_quickjs.wasm dist/main.js" "node dist/main.js"
Benchmark #1: wasmedge --dir .:. ../../target/wasm32-wasi/release/wasmedge_quickjs.wasm dist/main.js
  Time (mean ± σ):      1.843 s ±  0.024 s    [User: 1.793 s, System: 0.032 s]
  Range (min … max):    1.807 s …  1.877 s    10 runs

Benchmark #2: node dist/main.js
  Time (mean ± σ):      54.5 ms ±   2.8 ms    [User: 42.9 ms, System: 8.9 ms]
  Range (min … max):    51.4 ms …  64.7 ms    51 runs

Summary
  'node dist/main.js' ran
   33.80 ± 1.76 times faster than 'wasmedge --dir .:. ../../target/wasm32-wasi/release/wasmedge_quickjs.wasm dist/main.js' 

Are there any options to improve the performance for SSR in wasm?

@L-jasmine
Copy link
Collaborator

sorry, node have jit, but wasmedge_quickjs.wasm not.
We are trying to faster

@manuschillerdev
Copy link
Author

Could something like https://github.com/bytecodealliance/wizer help with pre-compiling?

@juntao
Copy link
Member

juntao commented May 25, 2022

@manuschillerdev I want to make sure that you did wasmedgec on the wasmedge-quickjs.wasm file.

@manuschillerdev
Copy link
Author

manuschillerdev commented May 25, 2022

@juntao that massively sped things up!

wasmedgec target/wasm32-wasi/release/wasmedge_quickjs.wasm target/wasm32-wasi/release/wasmedge_quickjs_aot.wasm

cd example_js/react_ssr/

hyperfine "wasmedge --dir .:. ../../target/wasm32-wasi/release/wasmedge_quickjs_aot.wasm dist/main.js" "node dist/main.js"
Benchmark #1: wasmedge --dir .:. ../../target/wasm32-wasi/release/wasmedge_quickjs_aot.wasm dist/main.js
  Time (mean ± σ):     195.1 ms ±   2.2 ms    [User: 144.3 ms, System: 46.0 ms]
  Range (min … max):   192.5 ms … 200.2 ms    15 runs

Benchmark #2: node dist/main.js
  Time (mean ± σ):      55.6 ms ±   1.3 ms    [User: 43.2 ms, System: 9.5 ms]
  Range (min … max):    53.0 ms …  58.5 ms    49 runs

Summary
  'node dist/main.js' ran
    3.51 ± 0.09 times faster than 'wasmedge --dir .:. ../../target/wasm32-wasi/release/wasmedge_quickjs_aot.wasm dist/main.js'

now it's only 3 times slower than the native node process - roughly 10x faster than before :)

Could this be improved even further?

EDIT: this could be added to the readme as well - in case I didn't just missed it

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

No branches or pull requests

3 participants