Comments (4)
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.
I have noticed that if you do:
- wamrc -o index.aot index.wasm
- 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.
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.
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)
- BigUint64Array some large numbers broken in wasm32-wasi HOT 2
- Uncaught Error: Dynamic require is not supported HOT 6
- Update to latest quickjs? HOT 3
- Avenues for rich host functions HOT 7
- Feature Request: Ability to Change Brotli Compression Level via CLI HOT 3
- Stop using cargo-wasi
- Support a WASI reactor target HOT 3
- Where can a dynamically linked WASM run? HOT 3
- Can javy receive command line args / env. Are they in scope? HOT 10
- Can't build javy main branch on Ubuntu 23.10 HOT 10
- imports HOT 7
- Imported functionallity from the host HOT 2
- Expose Rust structs to JavaScript as classes HOT 8
- [quickjs-wasm-sys] `JS_DupValue` is missing HOT 3
- [quickjs-wasm-rs] Should the closure passed to `wrap_callback` return `JSValueRef`? HOT 3
- Urgent help required : How to debug this ? Getting error at some line no in function.mjs HOT 6
- How to use Javy with asynchronous JavaScript code? (experimental_event_loop) HOT 5
- Errors in async top-level functions do not result in traps HOT 1
- Allow specifying which file descriptor is used in console.{log,err} from the CLI HOT 2
- accessing arguments.callee leads to TypeError: invalid property access HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from javy.