nodejs / nodejs/node

How to cache wasm module in nodejs, or it's already cached on startup ?

未关闭
#37,565 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

stale wasm
主要语言
JavaScript
星标
122k
派生
37.3k
平均合并
4 天 2 小时
30 天内合并 PR
283

描述

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

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先使用 require("../func/haversine") 和 require("haversinecalc") 重现计时比较,然后阅读链接的 wasm-bindgen issue,了解模块初始化的上下文。一个有用的结果是提供一份文档化的回答,解释相关的 Node.js 模块加载行为,以及如何将初始化与重复调用分开进行基准测试。

由索引模型根据 Issue 内容生成。

评估

技术栈
javascript, node.js, wasm
领域
backend, developer-experience
Issue 类型
文档
难度
3/5
预计耗时
1-2 天
活跃度
活跃
描述清晰度
需要澄清
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。