nodejs / nodejs/node

Node-API performance

オープン
#49,922 コメント 8 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

feature request never-stale performance
主要言語
JavaScript
スター
122k
フォーク
37.3k
平均マージ
4日 2時間
マージ済み PR(30日)
283

説明

What is the problem this feature will solve?

Improve performance when creating large V8 objects which is critical since these must always be created on the main thread, blocking the event loop.

Currently, the overhead of each method is very significant - especially for the primitive operations such as simply setting a property.

As a very typical example of the current problem, you can consider these two methods for setting a property on an object:

napi_status napi_set_property(napi_env env,
                                          napi_value object,
                                          napi_value key,
                                          napi_value value);
napi_status napi_set_named_property(napi_env env,
                                          napi_value object,
                                          const char* utf8name,
                                          napi_value value);

Naively, one expects that using the first one will be faster when the key is already UTF-16. However calling this method requires to first call napi_create_string_utf16 and the combined overhead of the two calls offsets the single call of the second method when the key is not very long (which is usually the case).

What is the feature you are proposing to solve the problem?

Step 1: napi_set_named_property that takes UTF-16 (not needed, see below)

Step 2: Methods that can create in one call a whole array/object from a C data structure - especially ones for strings already encoded in UTF-16

What alternatives have you considered?

No response

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

Node-API のエントリポイント napi_set_property、napi_set_named_property、napi_create_string_utf16 から始め、次に、大規模な V8 オブジェクトとプリミティブなプロパティ操作がメインスレッドでどのように作成されるかを調査します。この issue ではファイルやテストが指定されていません。完了には、C データに基づく配列/オブジェクトの一括作成について定義された API の範囲と、提案された操作によって作成のオーバーヘッドが削減されることを示す証拠が必要です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
cpp, javascript, node.js
領域
api, backend
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
静か
明瞭さ
説明が足りない
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。