nodejs / nodejs/node

Node-API performance

Offen
#49,922 8 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

feature request never-stale performance
Vorherrschende Sprache
JavaScript
Sterne
122k
Forks
37.3k
Ø Merge
4 T. 2 Std.
Gemergte PRs (30 T.)
283

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit den Node-API-Einstiegspunkten napi_set_property, napi_set_named_property und napi_create_string_utf16 und untersuche anschließend, wie große V8-Objekte und primitive Property-Operationen im Hauptthread erstellt werden. Das Issue nennt keine Dateien oder Tests; für den Abschluss wären ein definierter API-Umfang für die Erstellung von Arrays/Objekten aus C-Daten in großen Mengen sowie ein Nachweis erforderlich, dass die vorgeschlagenen Operationen den Erstellungsaufwand reduzieren.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
cpp, javascript, node.js
Bereich
api, backend
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Ruhig
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.