You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently msgpack.unpack(), converts the msgpack_object from C/C++ lib into a V8 object visiting the msgpack_object entirely with recursion.
Such an approach is known to be ~ 3.5 times slower than JSON.parse(). I could get approximately the same performance on nodejs 7.5 with msgpack 1.0.2.
In msgpack.cc, the recursive implementation of msgpack_to_v8 repeatedly calls Nan::New.
Building the V8 object is the most expensive part and disabling V8 object creation (C library msgpack_unpack) still being called, I could get encouraging numbers:
suggesting that most of the time is spent to build a V8 object.
In some use cases where the full object is not needed or not repeatedly accessed, better performance could be achieved wrapping the msgpack_object struct within a V8 object with getters of computed property names (not sure how transparent that can be).
If an msgpack_object representing:
varo={"a" : 1,"b" : 2,"c" : [1,2,3]};
is given, o.c[1] only creates and returns a number instead of the full object structure.
Assumption is to have less overhead and performance comparable to direct use of C library.
Was this ever tried? Does it make sense at all?
The text was updated successfully, but these errors were encountered:
Currently
msgpack.unpack()
, converts themsgpack_object
from C/C++ lib into a V8 object visiting themsgpack_object
entirely with recursion.Such an approach is known to be ~ 3.5 times slower than
JSON.parse()
. I could get approximately the same performance on nodejs 7.5 with msgpack 1.0.2.In
msgpack.cc
, the recursive implementation ofmsgpack_to_v8
repeatedly callsNan::New
.Building the V8 object is the most expensive part and disabling V8 object creation (C library
msgpack_unpack
) still being called, I could get encouraging numbers:json: 723.140ms msgpack: 458.431ms
median out of 10 runs of:
suggesting that most of the time is spent to build a V8 object.
In some use cases where the full object is not needed or not repeatedly accessed, better performance could be achieved wrapping the
msgpack_object
struct within a V8 object with getters of computed property names (not sure how transparent that can be).If an
msgpack_object
representing:is given,
o.c[1]
only creates and returns a number instead of the full object structure.Assumption is to have less overhead and performance comparable to direct use of C library.
Was this ever tried? Does it make sense at all?
The text was updated successfully, but these errors were encountered: