GithubHelp home page GithubHelp logo

NodeJS vs Javy performance about javy HOT 4 CLOSED

mrdivyansh avatar mrdivyansh commented on June 30, 2024
NodeJS vs Javy performance

from javy.

Comments (4)

jeffcharles avatar jeffcharles commented on June 30, 2024

The short answer is that NodeJS uses the V8 JavaScript engine which can just in time (JIT) compile hot loops in JavaScript (like the while loop in your example) to native code while Javy uses the QuickJS interpreter to execute JavaScript which can't JIT-compile JavaScript to native code.

To provide a little more context, Javy doesn't compile your JavaScript to WebAssembly bytecode. A Wasm module produced by Javy contains a preinitialized QuickJS interpreter that's been compiled to WebAssembly bytecode and a QuickJS bytecode representation of your JavaScript source code. At runtime, Javy has the QuickJS interpreter run the QuickJS bytecode. When using Wasmtime as your runtime, Wasmtime uses the Cranelift compiler to convert the Wasm bytecode (the QuickJS interpreter and our code for loading the QuickJS bytecode into it) into native code, but it will never convert the JavaScript source into native code, instead relying on the QuickJS interpreter to execute the JavaScript bytecode.

Does that answer your question?

from javy.

louisvangeldrop avatar louisvangeldrop commented on June 30, 2024

I have noticed that if you do:

  1. wamrc -o index.aot index.wasm
  2. iwasm index.aot

gives an improvement of roughly 20% compared to: wasmtime index.wasm

There is also a gain is in the size difference of iwasm.exe+index.aot compared to wasmtime.exe+index.wasm.

from javy.

jeffcharles avatar jeffcharles commented on June 30, 2024

That's cool that AOT-compiling with WAMR is able to have that kind of difference. I tried AOT-compiling with Wasmtime and was only able to get a ~3% performance improvement for this specific program.

from javy.

jeffcharles avatar jeffcharles commented on June 30, 2024

I'm going to close this issue as the question has been answered. Please feel free to respond with any follow up questions!

from javy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.