Re: [v8-users] BSON to v8::Object performance issue

2017-11-15 Thread J Decker
I assume you're storing references to the objects as Persistent? All you need to do then is call SetWeak() https://v8docs.nodesource.com/node-0.10/d2/d78/classv8_1_1_persistent.html void MakeWeak (void *parameters, WeakReferenceCallback callback) the callback is called when the object is GC'd.

Re: [v8-users] BSON to v8::Object performance issue

2017-11-15 Thread Jean-Marc Le Roux
So I've found a solution to make things lazy: I set an accessor instead of decoding/setting the actual value. void getter(Local property, const PropertyCallbackInfo& info) { Isolate* isolate = info.GetIsolate(); const bson_t* document = reinterpret_cast( info.This()

Re: [v8-users] BSON to v8::Object performance issue

2017-11-15 Thread Jean-Marc Le Roux
> > Now it takes *30ms. That's still 5x faster* than the native code. 300ms. (not 30) On Wed, Nov 15, 2017 at 10:27 AM, Jean-Marc Le Roux < jeanmarc.ler...@aerys.in> wrote: > Thanks for the quick feedback! > > I rewrote the JS version to be closer to the native one: > > var array = []; > var

Re: [v8-users] BSON to v8::Object performance issue

2017-11-15 Thread Jean-Marc Le Roux
Thanks for the quick feedback! I rewrote the JS version to be closer to the native one: var array = []; var input = { "_id": { "$oid": "5a00bad8f759511811e030ba" }, "attributes": [ { "key": "smartshape.scene.node.path|default", "value": "/scene/Lot444.scene",