mapbox / mapbox/node-cpp-skel

[FUTURE] Write a comparison benchmark using `worker_threads` module

未关闭
#143 5 条评论 3 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
C++
星标
74
派生
9
PR 合并指标
30 天内没有已合并 PR

描述

v10.5.0 has a new `worker_threads` module that allows pure JS functions to run on a separate thread. The node-cpp-skel demonstrates doing this type of thing using C++, but the `worker_threads` module allows for it in pure JS. (https://nodejs.org/en/blog/release/v10.5.0/)

It would be useful to try to write an 🍏 to 🍏 (or as close as we can get) comparison benchmark of doing the same work in C++ threads vs JS threads using `worker_threads`. We would try to answer questions like:

- 🍒 Is performance of passing data (#69, #67) similar in with `worker_threads` vs using libuv directly in C++?
- 🍊 When combined (overhead of thread queuing, passing data to the thread, doing compute, getting data back) which approach is faster?

We could get at 🍒 by writing a benchmark that passes the same, large data, and does no compute in the thread. Instead that thread could just sleep for N seconds.

We could get at 🍊 by passing the same data and doing the same (as close as possible) compute, perhaps a Fibonacci (or some kind of classical compute intensive workload).

----

Depending on the results we will want to update https://github.com/mapbox/cpp/blob/master/node-cpp.md#why-create-a-node-addon which says:

> Why create a node addon?
> To port a C++ project to Node to expose a new interface for the tool (like Mapnik & Node Mapnik)
> Improve performance at scale where Node becomes the bottleneck (i.e. concurrency)

If JS is just as fast as C++, then we'll want to update that doc to mention `worker_threads` as a more ideal solution than writing a node addon to access the thread pool. If `JS/worker_threads` is slower than C++ then we'll probably want to add details to that doc about what types of workloads or performance situations we'd want to use C++ and which we'd want to consider `JS/worker_threads`

/cc @mapbox/core-tech

贡献指南

打开贡献指南

从这里开始

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

调研方向

首先检查 node-cpp-skel 示例和 issue 中链接的 node-cpp.md 部分,以及所引用的 worker_threads release 信息。为数据传递和计算定义可比较的 C++ 和 JavaScript worker 基准测试,然后使用其结果确定 node-cpp.md 是否需要更新指导。

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

评估

技术栈
cpp, javascript, node.js
领域
documentation, performance
Issue 类型
功能
难度
5/5
预计耗时
一周以上
活跃度
停滞
描述清晰度
基本清楚
新手友好度
25/100

把新 issue 发到你的邮箱

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