用于类似 mongodb 的查询执行环境和多线程的 Javascript 引擎(或其他可嵌入语言)

发布于 2024-12-22 14:15:35 字数 476 浏览 1 评论 0原文

我需要一些可嵌入的语言来执行类似于 mongodb 中的查询执行的任务。语言应该很快,并且应该有 JIT 和解释器(对于 JIT 编译的频繁脚本和一次性运行的脚本),应该有内存运行时,我用特定的 API 函数(或类,等等)填充手动(没有任何“内置”的东西,比如 gettime、线程生成或类似的),它应该有 C API 并且应该在 ARM 上工作(MIPS 也很好),占用空间不要太大也很好(但是这个并不重要)。

我有两个候选者:

  1. Google V8。
  2. Spidermonkey(据我所知,IonMonkey 宣布支持 ARM)。

我之前没有经历过将语言嵌入到C项目中,所以我有几个问题:最近有传言说V8不是线程安全的,这个问题还存在吗?如果是这样,缺乏线程安全会在哪里导致问题?

另外,如果有人建议更适合我的要求的嵌入式语言(除了 lua 之外,我找不到与 js 相比的任何优势,除了我不关心的占用空间较小),我也会很高兴。

I need some embeddable language for tasks similar to query execution in mongodb. Language should be fast and it should have both JIT and interpreter (for frequent scripts that JIT-compiled and for one-time-run scripts too), should have in-memory runtime that I populate with specific API functions (or classes, whatever) by hand (and nothing "built-in" else like gettime, thread spawning or similar), it should have C API and it should work on ARM (MIPS also would be nice), not too big footprint also would be nice (but this is not critical).

I have two candidates:

  1. Google V8.
  2. Spidermonkey (There was IonMonkey's ARM support announced AFAIK).

I have not experienced embedding languages into C projects before so I have a few questions: recently there was a rumor that V8 is not thread-safe, is this problem still exists? If so, where that lack of thread-safe can cause problems?

Also I would be glad if anyone suggested embeddable language which is more suitable for my requirements (except lua, I can't find any advantages in comparison with js except smaller footprint about what I don't care).

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

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

发布评论

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

评论(1

旧伤还要旧人安 2024-12-29 14:15:35

我不确定 SpiderMonkey 的多线程嵌入能力与 V8 相比如何,但我确实知道 SpiderMonkey 可以做到这一点——我们在 dev.tech.js-engine 您可能想要向其发布后续问题。

我们在浏览器中的 Web Worker 实现为每个 Worker 使用一个运行时实例(您可以在单个进程中多次实例化运行时)——在过去几年中,我们已经放弃了多线程安全的单运行时方法,因为它对于Web 并显着增加了引擎的复杂性。

多道程序设计的替代方案也是异步、基于选择、从节点运行到完成的方法。

一点:我认为解释器并不是您的真正要求——您的要求是一次性代码的快速启动时间。 SpiderMonkey 有一个解释器,而 V8 没有,但 V8 有一个快速代码发射(我们倾向于称为“基线”)JIT 编译器,可以在该领域提供相当的性能。一般来说,这种能力是 Web 上 JS 的一个重要要求。 :-)

I'm not sure how SpiderMonkey's multithreading embeddability compares to V8's, but I do know that it's possible to do with SpiderMonkey -- we have a few multiprogramming embedders on dev.tech.js-engine that you may want to post followup questions to.

Our web workers implementation in the browser uses one runtime instance per worker (you can multiply instantiate the runtime in a single process) -- we've moved away from an multithread-safe single-runtime approach over the past few years because it's unnecessary for the web and adds a significant amount of complexity to the engine.

An alternative to multiprogramming is also the asynchronous, select-based, run-to-completion approach a la node.

A nit: I don't think an interpreter is really a requirement of yours -- your requirement is fast start up times for one-off code. SpiderMonkey has an interpreter and V8 does not, but V8 has a fast-code-emission (which we tend to call "baseline") JIT compiler that offers comparable performance in that area. That capability is an important requirement for JS on the web in general. :-)

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