用于类似 mongodb 的查询执行环境和多线程的 Javascript 引擎(或其他可嵌入语言)
我需要一些可嵌入的语言来执行类似于 mongodb 中的查询执行的任务。语言应该很快,并且应该有 JIT 和解释器(对于 JIT 编译的频繁脚本和一次性运行的脚本),应该有内存运行时,我用特定的 API 函数(或类,等等)填充手动(没有任何“内置”的东西,比如 gettime、线程生成或类似的),它应该有 C API 并且应该在 ARM 上工作(MIPS 也很好),占用空间不要太大也很好(但是这个并不重要)。
我有两个候选者:
- Google V8。
- 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:
- Google V8.
- 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定 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. :-)