How to cache wasm module in nodejs, or it's already cached on startup ?
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 122k
- Forks
- 37.3k
- Avg merge
- 4d 2h
- Merged PRs (30d)
- 283
Description
according to this https://github.com/rustwasm/wasm-bindgen/issues/2473
Summary
I created comparison between manual javascript haversine function, and wasm based.
the result if i compared including the module initialization, wasm based getting much slower than javascript itself.
Additional Details
console.time("manual")
const haversinee = require("../func/haversine")
const src = {
lat: -7.0,
lng: 7.0
}
const dst = {
lat: -8.0,
lng: 8.0
}
console.log("manual js : "+ haversinee(src, dst, false))
console.timeEnd("manual")
console.time("wasm")
const {Point, haversine} = require("haversinecalc") // this is the problem
const src_p = new Point(-7.0,7.0)
const dst_p = new Point(-8.0,8.0)
console.log("using wasm : "+ haversine(src_p, dst_p))
console.timeEnd("wasm")
Result with module initialization included
manual js : 156581.10278754708
manual: 12.337ms
using wasm : 156581.10278754708
wasm: 18.109ms
Result without module initialization
manual js : 156581.10278754708
manual: 7.709ms
using wasm : 156581.10278754708
wasm: 0.287ms
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the timing comparison using require("../func/haversine") and require("haversinecalc"), then read the linked wasm-bindgen issue for the module-initialization context. A useful outcome would be a documented answer explaining the relevant Node.js module-loading behavior and how to benchmark initialization separately from repeated calls.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js, wasm
- Domain
- backend, developer-experience
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100