节点wasi vs产生儿童过程

发布于 2025-01-30 19:18:19 字数 628 浏览 2 评论 0原文

nodejs docs

WASI API提供了WebAssembly系统接口规范的实现。 WASI通过类似Posix的功能的集合使Sandboxed WebAssembly应用程序访问了基础操作系统。

我的问题是:

使用WASI API的最大好处是什么,例如,覆盖了其他一些儿童过程或运行非Nodejs代码的类似方法

我必须假设它比产卵过程更快,或者由于本机API而使用一些带有绑定的C代码。

也许我只是误解了WASI背后的整个想法,因为这使WASM如此出色的部分是可以使用服务器端,完整的吹制编程语言(大部分)的能力,就像所有<所有< a href =“ https://esbuild.github.io/” rel =“ nofollow noreferrer”>疯狂的工具我们已经看到了go/rust。

这是为了在本机中运行wasm的好处,同样,与运行子过程相比,有什么好处?

In the NodeJS docs it states the following:

The WASI API provides an implementation of the WebAssembly System Interface specification. WASI gives sandboxed WebAssembly applications access to the underlying operating system via a collection of POSIX-like functions.

My question is:

What is the biggest benefit of using the WASI API over, say, spawing some other child process or similar methods of running non-nodejs code?

I would have to assume it's faster than spawning a child process, or using some C code with bindings due to the native-api.

Maybe I'm simply misunderstanding the entire idea behind WASI, which is plausable, given that part of what makes WASM so amazing is the ability to use a server-side, full blown programming language on the web (mostly), like all the crazy tools we've seen with Go/Rust.

Is this more so for the benefit of running WASM in node, natively, and again, if so, what are the benefits compared to running child processes?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

聊慰 2025-02-06 19:18:19

当前最大的好处是跨平台支持。您不需要为您支持的每个平台编译孩子流程;只需为WASM/WASI编译一次即可。

将来它也将变得更加安全,因为这样的过程是正确的。但是,显然Node尚未SandBox WASI文件系统访问。

速度是WASM/WASI的主要下行。它比本地慢2倍。

其他大弊端:

  • 尚无多线程支持。
  • 无法使用本地OS API(如果不在Wasi中,则拧紧)。
  • 这是实验性的。
  • 它是沙盒(有时您不想要的)。
  • 许多缺失的功能,例如难以捕获Stdout。

The biggest benefit currently is cross platform support. You don't need to compile your child process for every platform you support; just compile it once for WASM/WASI.

In future it will also be more secure because then the process is sandboxes properly. However apparently Node doesn't sandbox WASI filesystem access yet.

Speed is the main downside of WASM/WASI. It's about 2x slower than native.

Other big downsides:

  • No multi-threading support yet.
  • Can't use native OS APIs (if it isn't in WASI you're screwed).
  • It's experimental.
  • It's sandboxed (sometimes you don't want that).
  • Lots of missing features, e.g. difficult to capture stdout.
思念绕指尖 2025-02-06 19:18:19

我最终从这里删除的帖子得到了答案。

用真正高级的话来说,WASI只是WASM的(系统)接口。

我最终找到了

就像WebAssembly是概念机的汇编语言一样,WebAssembly需要一个用于概念操作系统的系统接口,而不是任何单个操作系统。这样,它可以在所有不同的OSS上运行。

这就是WASI - WebAssembly平台的系统接口。

I ended up getting my answer from a post here that was removed.

In really high-level terms, WASI is simply an (systems) interface for WASM.

I ended up finding this short 'article', if you will, super helpful too!

Just as WebAssembly is an assembly language for a conceptual machine, WebAssembly needs a system interface for a conceptual operating system, not any single operating system. This way, it can be run across all different OSs.

This is what WASI is — a system interface for the WebAssembly platform.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文