[FUTURE] Write a comparison benchmark using `worker_threads` module
還沒有人認領這個 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
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 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