summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorKenny Yuan <kaining.yuan@intel.com>2018-06-07 10:01:47 +0800
committerRod Vagg <rod@vagg.org>2018-08-16 11:38:52 +1000
commit4911c4e9fa4d97c85be8e20ef3cdefb8ba301719 (patch)
tree9d8107011db1a163c6fc27622d834c009cd30f5d /Makefile
parent0517cd850492e6dc760adf904b005522077e2fb9 (diff)
downloadnode-new-4911c4e9fa4d97c85be8e20ef3cdefb8ba301719.tar.gz
n-api: improve runtime perf of n-api func call
Added a new struct CallbackBundle to eliminate all GetInternalField() calls. The principle is to store all required data inside a C++ struct, and then store the pointer in the JavaScript object. Before this change, the required data are stored in the JavaScript object in 3 or 4 seperate pointers. For every napi fun call, 3 of them have to be fetched out, which are 3 GetInternalField() calls; after this change, the C++ struct will be directly fetched out by using v8::External::Value(), which is faster. Profiling data show that GetInternalField() is slow. On an i7-4770K (3.50GHz) box, a C++ V8-binding fun call is 8 ns, before this change, napi fun call is 36 ns; after this change, napi fun call is 20 ns. The above data are measured using a modified benchmark in 'benchmark/misc/function_call'. The modification adds an indicator of the average time of a "chatty" napi fun call (max 50M runs). This change will speed up chatty case 1.8x (overall), and will cut down the delay of napi mechanism to approx. 0.5x. Background: a simple C++ binding function (e.g. receiving little from JS, doing little and returning little to JS) is called 'chatty' case for JS<-->C++ fun call routine. This improvement also applies to getter/setter fun calls. Backport-PR-URL: https://github.com/nodejs/node/pull/21733 PR-URL: https://github.com/nodejs/node/pull/21072 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile1
1 files changed, 1 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index 9e1dbdbded..93e1831421 100644
--- a/Makefile
+++ b/Makefile
@@ -263,6 +263,7 @@ test-check-deopts: all
$(PYTHON) tools/test.py --mode=release --check-deopts parallel sequential -J
benchmark/misc/function_call/build/Release/binding.node: all \
+ benchmark/misc/function_call/napi_binding.c \
benchmark/misc/function_call/binding.cc \
benchmark/misc/function_call/binding.gyp
$(NODE) deps/npm/node_modules/node-gyp/bin/node-gyp rebuild \